# Platform configuration # # Select the platform by setting the define below either by command # line arguments, # e.g. rpmbuild -ba --define "build_rh7 1" apcupsd.spec # or by manually setting it to 1 in this file, # e.g. %define rh7 1 # # If you want the usb version, use: # e.g. rpmbuild -ba --define "build_usb 1" --define "build_rh7 1" apcupsd.spec # or by manually setting it to 1 in this file, # e.g. %define usb 1 # # Note, to build, you need: # Release_Notes-%{version}-%{release}.tar.gz in your # rpm SOURCES directory, and the tar file must contain # Release_Notes-%{version}-%{release}.txt # %define rh7 0 %{?build_rh7:%define rh7 1} %define rh8 0 %{?build_rh8:%define rh8 1} %define rh9 0 %{?build_rh9:%define rh9 1} # all FC releases to date %define fedora_core 0 %{?build_fedora_core:%define fedora_core 1} # RedHat Enterprise and all clones %define rhel3 0 %{?build_rhel3:%define rhel3 1} %define rhel4 0 %{?build_rhel4:%define rhel4 1} # Vine Linux %define vine 1 %{?build_vine:%define vine 1} # SuSE 9.x and 10.x %define suse 0 %{?build_suse:%define suse 1} # Mandrake and Mandriva %define mdk 0 %{?build_mdk:%define mdk 1} # this sets up the config files for usb but usb driver is built regardless %define usb 1 %{?build_usb:%define usb 1} %define pwrfaildir %{_sysconfdir}/apcupsd Summary: APC UPS Power Control Daemon for Linux Name: apcupsd Version: 3.12.4 Release: 0vl1 #Vendor: APC UPS Daemon Team #Distribution: The apcupsd Team Packager: NOGUCHI Shoji URL: http://www.apcupsd.com Source0: http://www.spcupsd.com/%{name}-%{version}.tar.gz Source1: Release_Notes-%{version}-1.tar.gz Patch0: %{name}-%{version}-ipv6.patch Group: System Environment/Daemons License: GPL v2 BuildRoot: %{_tmppath}/%{name}-root BuildRequires: gd-devel, ncurses-devel, ghostscript %if %{rh7} BuildRequires: glibc-devel >= 2.2, libjpeg-devel, libpng-devel, zlib-devel, freetype-devel %else BuildRequires: glibc-devel >= 2.3 %endif %if ! %{suse} && ! %{mdk} BuildRequires: tetex BuildRequires: tetex-latex %endif %if %{suse} BuildRequires: tetex BuildRequires: latex2html %endif %if %{mdk} BuildRequires: tetex BuildRequires: latex2html BuildRequires: tetex-dvips BuildRequires: ghostscript-dvipdf %endif %if %{fedora_core} BuildRequires: latex2html %endif %description Apcupsd can be used for controlling most APC UPSes. During a power failure, apcupsd will inform the users about the power failure and that a shutdown may occur. If power is not restored, a system shutdown will follow when the battery is exausted, a timeout (seconds) expires, or the battery runtime expires based on internal APC calculations determined by power consumption rates. If the power is restored before one of the above shutdown conditions is met, apcupsd will inform users about this fact. Some features depend on what UPS model you have (simple or smart). %if %{usb} %package usb %else %package std %endif Provides: apcupsd Requires: perl, ncurses %if %{fedora_core} || %{suse} || %{mdk} || %{rhel4} || %{vine} Requires: gd >= 2.0 %else Requires: gd < 2.0 %endif %if %{rh7} Requires: glibc >= 2.2, libjpeg, libpng, zlib, freetype %else Requires: glibc >= 2.3 %endif Summary: APC UPS Power Control Daemon for Linux Group: System Environment/Daemons %if %{usb} %description usb %else %description std %endif Apcupsd can be used for controlling most APC UPSes. During a power failure, apcupsd will inform the users about the power failure and that a shutdown may occur. If power is not restored, a system shutdown will follow when the battery is exausted, a timeout (seconds) expires, or the battery runtime expires based on internal APC calculations determined by power consumption rates. If the power is restored before one of the above shutdown conditions is met, apcupsd will inform users about this fact. Some features depend on what UPS model you have (simple or smart). %if %{usb} This package is built with USB support. %else This package is built with standard serial port support. %endif %prep %setup -q -b 1 %patch0 -p1 %{__cat} < apcupsd.logrotate %{_var}/log/apcupsd.events { missingok copytruncate notifempty } EOF %build %configure \ --prefix=%{_prefix} \ --sbindir=%{_syssbindir} \ --sysconfdir=%{_sysconfdir}/apcupsd \ --with-cgi-bin=%{_sysconfdir}/apcupsd/cgi \ --enable-cgi \ --enable-pthreads \ --enable-net \ --enable-master-slave \ --enable-apcsmart \ --enable-dumb \ --enable-usb \ --enable-powerflute \ %if %{vine} --with-distname=redhat \ %endif %if %{usb} --with-serial-dev= \ --with-upstype=usb \ --with-upscable=usb %endif %{__make} %if %{usb} cd examples %{__make} hid-ups cd ../ %endif # build pdf manual #cd doc/latex #%%{__make} #cd ../../ %install [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %{__mkdir_p} $RPM_BUILD_ROOT%{_initrddir} %{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/cgi %{__make} \ DESTDIR=$RPM_BUILD_ROOT \ install %{__install} -m0744 platforms/apccontrol \ $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/apccontrol %if ! %{suse} && ! %{mdk} && ! %{vine} %{__install} -m0755 platforms/redhat/apcupsd $RPM_BUILD_ROOT%{_initrddir} %endif %if %{vine} %{__sed} -e 's/redhat/vine/g' platforms/redhat/apcupsd > platforms/redhat/apcupsd.vine %{__install} -m0755 platforms/redhat/apcupsd.vine $RPM_BUILD_ROOT%{_initrddir}/apcupsd %endif %if %{suse} %{__install} -m0755 platforms/suse/apcupsd $RPM_BUILD_ROOT%{_initrddir} %endif %if %{mdk} %{__install} -m0755 platforms/mandrake/apcupsd $RPM_BUILD_ROOT%{_initrddir} %endif %if ! %{mdk} %{__rm} $RPM_BUILD_ROOT%{_initrddir}/halt %{__rm} $RPM_BUILD_ROOT%{_initrddir}/halt.old %endif %if %{usb} %{__install} -m0744 examples/hid-ups \ $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/hid-ups %{__install} -m0744 examples/make-hiddev \ $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/make-hiddev %endif %{__install} -D -m0644 apcupsd.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/apcupsd %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %if %{usb} %files usb %defattr(-,root,root) %{_sysconfdir}/apcupsd/make-hiddev %{_sysconfdir}/apcupsd/hid-ups %else %files std %defattr(-,root,root) %endif %doc COPYING DISCLAIMER ReleaseNotes ChangeLog ../Release_Notes-%{version}-1.txt %dir %{_sysconfdir}/apcupsd %dir %{_sysconfdir}/apcupsd/cgi %config(noreplace) %{_initrddir}/apcupsd %config(noreplace) %{_sysconfdir}/logrotate.d/apcupsd %config(noreplace) %{_sysconfdir}/apcupsd/apccontrol %config(noreplace) %{_sysconfdir}/apcupsd/changeme %config(noreplace) %{_sysconfdir}/apcupsd/commfailure %config(noreplace) %{_sysconfdir}/apcupsd/commok %config(noreplace) %{_sysconfdir}/apcupsd/onbattery %config(noreplace) %{_sysconfdir}/apcupsd/offbattery %config(noreplace) %{_sysconfdir}/apcupsd/apcupsd.conf %config(noreplace) %{_sysconfdir}/apcupsd/hosts.conf %config(noreplace) %{_sysconfdir}/apcupsd/multimon.conf %config(noreplace) %{_sysconfdir}/apcupsd/masterconnect %config(noreplace) %{_sysconfdir}/apcupsd/mastertimeout %{_sysconfdir}/apcupsd/apcupsd.css %{_sysconfdir}/apcupsd/cgi/* %{_syssbindir}/* %attr(-,root,man) %{_mandir}/*/* %if %{usb} %pre usb %else %pre std %endif %if %{usb} %post usb %else %post std %endif # get rid of any 3.6.2 stuff %{__rm} -f /etc/rc.d/rc[0-6].d/[KS]20apcups %{__rm} -f %{_initrddir}/apcups # add our links if [ "$1" -ge 1 ] ; then /sbin/chkconfig --add apcupsd fi # are we Red Hat or SuSE? # Mandrake already handles apcupsd if [ -s /etc/redhat-release -o -s /etc/vine-release -o -s /etc/SuSE-release -o -s /etc/whitebox-release ]; then %{__cp} -f %{_initrddir}/halt %{_initrddir}/halt.old %{__awk} '# Stuff left over from a previous apcupsd, remove it /^# See if this is a powerfail situation\./ { do { getline } while (length($0) != 0) getline } # We insert the new apcupsd code just before the following line /^# Now halt or reboot\./ { print "# See if this is a powerfail situation. # ***apcupsd***" print "if [ -f %{pwrfaildir}/powerfail ]; then # ***apcupsd***" print " echo # ***apcupsd***" print " echo \"APCUPSD will now power off the UPS\" # ***apcupsd***" print " echo # ***apcupsd***" print " %{pwrfaildir}/apccontrol killpower # ***apcupsd***" print " echo # ***apcupsd***" print " echo \"Please ensure that the UPS has powered off before rebooting\" # ***apcupsd***" print " echo \"Otherwise, the UPS may cut the power during the reboot!!!\" # ***apcupsd***" print " echo # ***apcupsd***" print "fi # ***apcupsd***" print "" } # Everything else is duplicated { print } ' %{_initrddir}/halt.old > %{_initrddir}/halt %{__chmod} 744 %{_initrddir}/halt fi # Undo things a bit %if %{usb} %preun usb %else %preun std %endif if [ $1 = 0 ] ; then # remove startup links /sbin/chkconfig --del apcupsd # are we Red Hat or SuSE? # Mandrake already handles apcupsd if [ -s /etc/redhat-release -o -s /etc/vine-release -o -s /etc/SuSE-release -o -s /etc/whitebox-release ]; then cp -f %{_initrddir}/halt %{_initrddir}/halt.old %{__awk} '# Stuff added by apcupsd, remove it /^# See if this is a powerfail situation\./ { do { getline } while (length($0) != 0) getline } # Everything else is duplicated { print } ' %{_initrddir}/halt.old > %{_initrddir}/halt %{__chmod} 744 %{_initrddir}/halt fi fi %changelog * Fri May 05 2006 D. Scott Barninger - update build requirments to include ghostscript - update fedora_core build requirements to include latex2html * Sun Apr 23 2006 D. Scott Barninger - add pdf manual to doc package - remove redundant code for std and usb packages - add powerflute * Sat Apr 22 2006 D. Scott Barninger - clean up build defines, add rhel4 * Sat Jan 21 2006 D. Scott Barninger - release 3.12.2 update docs * Sun Sep 18 2005 D. Scott Barninger - Change deprecated Copyright tag to License * Tue Jun 07 2005 Adam Kropelin - Rename mainsback.in to offbattery.in so default power loss/return actions - are symmetrical. * Sat Apr 30 2005 D. Scott Barninger - fix typo in rh7 dependencies * Sat Mar 12 2005 D. Scott Barninger - clean up halt insertion code, add check for whitebox-release - remove cruft that has been commented out for a long time - add pwrfaildir as variable - correct SuSE initdir - add libjpeg libpng zlib freetype dependencies for RH7 * Sun Nov 28 2004 D. Scott Barninger - correct awk insertion in halt script for SuSE * Fri Nov 05 2004 D. Scott Barninger - change Mandrake logic in preun and post scriptlets to if;then;fi * Sun Oct 31 2004 D. Scott Barninger - add Mandrake support * Wed Aug 04 2004 D. Scott Barninger - changed location of apcupsd.css to /etc/apcupsd from /etc/apcupsd/cgi - corrected typo introduced in SuSE configuration for initdir definition * Sun Apr 25 2004 D. Scott Barninger - add SuSE configuration * Sat Apr 24 2004 D. Scott Barninger - tidy up doc includes, add release notes * Mon Mar 08 2004 D. Scott Barninger - added additional clean of buildroot to beginning of install section - corrected post install routines for nicer chkconfig * Sat Jan 17 2004 D. Scott Barninger - added build of net driver to configure - moved usb driver build into both packages - set --with-serial-dev= to blank so will find any device and removed rh7 patch * Sat Jan 10 2004 D. Scott Barninger - added build tags for rh8 rh9 fedora_core and wb3 - cleaned up dependancies and Requires by platform * Thu Jan 1 2004 D. Scott Barninger - removed rh_version from package names - added platform build configuration section to beginning of file * Sat Nov 08 2003 Scott at fairfieldcomputers dot com - expanded usb devices from 0-9 to 0-15 * Fri Nov 07 2003 Scott at fairfieldcomputers dot com - corrected device path for usb devices to /dev/usb and added patch for - rh7 builds to make it /dev/usb/hid in /etc/apcupsd/apcupsd.conf * Sat Oct 18 2003 Scott at fairfieldcomputers dot com - added master-slave, apcsmart and dumb to configure options * Sun Sep 14 2003 Scott at fairfieldcomputers dot com - added rm commands during install to remove halt scripts created - in the build root * Mon May 11 2003 Scott at fairfieldcomputers dot com - combined layout for usb/serial builds * Thu Jan 16 2003 Scott at fairfieldcomputers dot com - Update spec to new source layout - Added masterconnect and mastertimout to files section - Changed make install-apcupsd and make install-cgi to make install * Wed Sep 05 2001 kern at sibbald dot com - Applied very nice patch to this spec by Giulio Orsero * Thu Sep 14 2000 kern at sibbald dot com - Many thanks to Fredrik Persson and Neil Darlow for helping me write this spec file. - Basic spec by Kern Sibbald