UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / platforms / mandrake / apcupsd.spec.in
blobcbefbc4c1bd6257017a6366949fa9206fb2b885f
1 # Platform configuration
2 #
3 # Select the platform by setting the define below either by command
4 # line arguments,
5 # e.g. rpmbuild -ba --define "build_suse 1" apcupsd.spec
6 # or by manually setting it to 1 in this file,
7 # e.g. %define suse 1
9 # If you want the gapcmon package, use:
10 # e.g. rpmbuild -ba --define "build_gapcmon 1" --define "build_suse 1" apcupsd.spec
11 # or by manually setting it to 1 in this file,
12 # e.g. %define gapcmon 1
14 # If you want the (obsolete) NET-SNMP driver, use:
15 # e.g. rpmbuild -ba --define "build_snmp 1" --define "build_suse 1" apcupsd.spec
16 # or by manually setting it to 1 in this file,
17 # e.g. %define snmp 1
18 # The modern SNMP driver is always enabled since it has no dependencies.
20 # Note, to build, you need:
21 # Release_Notes-%{version}-%{release}.tar.gz in your
22 # rpm SOURCES directory, and the tar file must contain
23 # Release_Notes-%{version}-%{release}.txt
26 # basic defines for every build
27 %define _version @VERSION@
28 %define _release 1
30 #--------------------------------------------------------------------------
31 # it should not be necessary to change anything below here for a release
32 # except for patch macros in the setup section if used
33 #--------------------------------------------------------------------------
35 %define pwrfaildir @PWRFAILDIR@
36 %define halpolicydir /usr/share/hal/fdi/policy/20thirdparty
38 # third party packagers
39 %define _packager D. Scott Barninger <barninger@fairfieldcomputers.com>
40 %{?contrib_packager:%define _packager %{contrib_packager}}
42 %define rh7 0
43 %{?build_rh7:%define rh7 1}
45 %define rh8 0
46 %{?build_rh8:%define rh8 1}
48 %define rh9 0
49 %{?build_rh9:%define rh9 1}
51 # all FC releases to date
52 %define fedora_core 0
53 %{?build_fedora_core:%define fedora_core 1}
55 # RedHat Enterprise and all clones
56 %define rhel3 0
57 %{?build_rhel3:%define rhel3 1}
58 %define rhel4 0
59 %{?build_rhel4:%define rhel4 1}
60 %define rhel5 0
61 %{?build_rhel5:%define rhel5 1}
63 # SuSE 9.x and 10.x
64 %define suse 0
65 %{?build_suse:%define suse 1}
67 # Mandrake and Mandriva
68 %define mdk 0
69 %{?build_mdk:%define mdk 1}
71 %if ! %{suse}
72 %define suse_version 0
73 %endif
75 %if %{suse}
76 %define initdir /etc/rc.d
77 %else
78 %define initdir /etc/rc.d/init.d
79 %endif
81 # set destination directories for multimon
82 %define cgidir /var/www/cgi-bin
83 %if %{suse}
84 %define cgidir /srv/www/cgi-bin
85 %endif
87 # set ownership of files
88 %define binowner root
89 %define bingroup root
90 %define dataowner apache
91 %define datagroup apache
92 %if %{suse}
93 %define dataowner wwwrun
94 %define datagroup www
95 %endif
97 # should we build gapcmon, requires gtk2 >= 2.4
98 %define gapcmon 0
99 %{?build_gapcmon:%define gapcmon 1}
101 # should we build net-snmp driver
102 %define snmp 0
103 %{?build_snmp:%define snmp 1}
105 Summary: APC UPS Power Control Daemon for Linux
106 Name: apcupsd
107 Version: %{_version}
108 Release: %{_release}
109 Vendor: APC UPS Daemon Team
110 Distribution: The apcupsd Team
111 Packager: %{_packager}
112 URL: http://www.apcupsd.com
113 Source0: http://www.spcupsd.com/%{name}-%{version}.tar.gz
114 Source1: Release_Notes-%{version}-%{release}.tar.gz
115 Group: System Environment/Daemons
116 License: GPL v2
117 BuildRoot: %{_tmppath}/%{name}-root
118 BuildRequires: gd-devel, ncurses-devel, ghostscript, libstdc++-devel
119 %if %{rh7}
120 BuildRequires: glibc-devel >= 2.2, libjpeg-devel, libpng-devel, zlib-devel, freetype-devel
121 %else
122 BuildRequires: glibc-devel >= 2.3
123 %endif
124 %if %{gapcmon}
125 BuildRequires: glibc-devel, gtk2-devel >= 2.4, glib2-devel, atk-devel
126 BuildRequires: ORBit2, pango-devel, pkgconfig
127 %endif
128 %if %{suse} && %{gapcmon}
129 BuildRequires: bonobo-activation, freetype2-devel, cairo-devel, fontconfig-devel
130 BuildRequires: gconf2-devel, gnome-vfs2-devel, libpng-devel, glitz-devel, xorg-x11-libs
131 BuildRequires: libbonobo-devel, libbonoboui-devel
132 %endif
133 %if %{fedora_core} && %{gapcmon}
134 BuildRequires: libbonobo-devel, libbonoboui-devel, freetype-devel, GConf2-devel
135 %endif
136 %if %{mdk} && %{gapcmon}
137 BuildRequires: libbonobo2_0-devel, libbonoboui2_0-devel, freetype2-devel, libGConf2_4-devel
138 %endif
139 %if %{rhel4} && %{gapcmon}
140 BuildRequires: libbonobo-devel, libbonoboui-devel, freetype-devel, GConf2-devel
141 %endif
142 %if %{rhel5} && %{gapcmon}
143 BuildRequires: libbonobo-devel, libbonoboui-devel, freetype-devel, GConf2-devel
144 %endif
145 %if %{snmp}
146 BuildRequires: net-snmp-devel
147 %endif
149 Provides: apcupsd
150 Obsoletes: apcupsd-std apcupsd-usb
152 Requires: perl, ncurses
153 %if %{rh7}
154 Requires: glibc >= 2.2
155 %else
156 Requires: glibc >= 2.3
157 %endif
158 %if %{snmp}
159 Requires: net-snmp
160 %endif
162 %description
163 Apcupsd can be used for controlling most APC UPSes. During a
164 power failure, apcupsd will inform the users about the power
165 failure and that a shutdown may occur. If power is not restored,
166 a system shutdown will follow when the battery is exausted, a
167 timeout (seconds) expires, or the battery runtime expires based
168 on internal APC calculations determined by power consumption
169 rates. If the power is restored before one of the above shutdown
170 conditions is met, apcupsd will inform users about this fact.
171 Some features depend on what UPS model you have (simple or smart).
172 This package is configured for USB but can be reconfigured for
173 standard serial port UPS models. See the manual.
175 %package multimon
176 Summary: APC UPS Power Control Daemon for Linux
177 Group: Applications/Internet
179 Requires: libstdc++
180 %if %{fedora_core} || %{suse} || %{mdk} || %{rhel4} || %{rhel5}
181 Requires: gd >= 2.0
182 %else
183 Requires: gd < 2.0
184 %endif
185 %if %{rh7}
186 Requires: glibc >= 2.2, libjpeg, libpng, zlib, freetype
187 %else
188 Requires: glibc >= 2.3
189 %endif
191 %description multimon
192 apcupsd Network Monitoring (CGI) Programs which will give you the
193 status of your UPS or UPSes over the network.
195 %if %{gapcmon}
196 %package gapcmon
197 Summary: APC UPS Power Control Daemon for Linux
198 Group: Applications/System
200 Requires: glibc, gtk2 >= 2.4, glib2, atk, libbonobo, libbonoboui, ORBit2, pango
201 %endif
203 %if %{suse} && %{gapcmon}
204 Requires: bonobo-activation, freetype2, cairo, fontconfig, gconf2, gnome-vfs2, libpng, glitz, xorg-x11-libs
205 %endif
206 %if %{fedora_core} && %{gapcmon}
207 Requires: freetype, GConf2
208 %endif
209 %if %{mdk} && %{gapcmon}
210 Requires: freetype2, GConf2
211 %endif
212 %if %{rhel4} && %{gapcmon}
213 Requires: freetype, GConf2
214 %endif
215 %if %{rhel5} && %{gapcmon}
216 Requires: freetype, GConf2
217 %endif
219 %if %{gapcmon}
220 %description gapcmon
221 A Gnome application to monitor the status of your UPS.
222 %endif
224 # SuSE turns off stripping of binaries by default. In order to get
225 # stripped packages we must generate debug package. RedHat and Mandriva
226 # turn debug packages on by default but strip binaries regardless.
227 %if %{suse}
228 %debug_package
229 %endif
231 %prep
233 %setup -b 1
235 %build
237 %configure \
238 --prefix=%{_prefix} \
239 --sbindir=/sbin \
240 --sysconfdir=%{_sysconfdir}/apcupsd \
241 --with-cgi-bin=%{cgidir} \
242 --enable-cgi \
243 --enable-net \
244 --enable-pcnet \
245 --enable-apcsmart \
246 --enable-dumb \
247 --enable-usb \
248 --enable-snmp \
249 %if %{gapcmon}
250 --enable-gapcmon \
251 %endif
252 %if %{snmp}
253 --enable-net-snmp \
254 %endif
255 --with-serial-dev= \
256 --with-upstype=usb \
257 --with-halpolicydir=%{halpolicydir} \
258 --with-upscable=usb
260 make
262 cd examples
263 make hid-ups
264 cd ../
266 %install
267 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
269 mkdir -p $RPM_BUILD_ROOT%{initdir}
270 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/cgi
272 make \
273 DESTDIR=$RPM_BUILD_ROOT \
274 install
276 install -m744 platforms/apccontrol \
277 $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/apccontrol
279 %if ! %{suse} && ! %{mdk}
280 install -m755 platforms/redhat/apcupsd $RPM_BUILD_ROOT%{initdir}
281 %endif
282 %if %{suse}
283 install -m755 platforms/suse/apcupsd $RPM_BUILD_ROOT%{initdir}
284 %endif
285 %if %{mdk}
286 install -m755 platforms/mandrake/apcupsd $RPM_BUILD_ROOT%{initdir}
287 %endif
289 %if ! %{mdk}
290 rm $RPM_BUILD_ROOT%{initdir}/halt
291 rm $RPM_BUILD_ROOT%{initdir}/halt.old
292 %endif
294 install -m744 examples/hid-ups \
295 $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/hid-ups
296 install -m744 examples/make-hiddev \
297 $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/make-hiddev
299 %clean
300 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
301 rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-%{release}.txt
303 %files
304 %defattr(-,root,root)
305 %{_sysconfdir}/apcupsd/make-hiddev
306 %{_sysconfdir}/apcupsd/hid-ups
307 %{halpolicydir}/80-apcupsd-ups-policy.fdi
308 %doc COPYING DISCLAIMER ReleaseNotes ChangeLog ../Release_Notes-%{version}-%{release}.txt doc/manual/manual.html doc/manual/*.png
309 %dir %{_sysconfdir}/apcupsd
310 %{initdir}/apcupsd
311 %config(noreplace) %{_sysconfdir}/apcupsd/apccontrol
312 %config(noreplace) %{_sysconfdir}/apcupsd/changeme
313 %config(noreplace) %{_sysconfdir}/apcupsd/commfailure
314 %config(noreplace) %{_sysconfdir}/apcupsd/commok
315 %config(noreplace) %{_sysconfdir}/apcupsd/onbattery
316 %config(noreplace) %{_sysconfdir}/apcupsd/offbattery
317 %config(noreplace) %{_sysconfdir}/apcupsd/apcupsd.conf
318 /sbin/*
319 %attr(-,root,man) %{_mandir}/*/*
321 %files multimon
322 %defattr(-,root,root)
323 %dir %{_sysconfdir}/apcupsd
324 %dir %{cgidir}
325 %attr(-,%{dataowner},%{datagroup}) %{_sysconfdir}/apcupsd/apcupsd.css
326 %attr(-,%{binowner},%{bingroup}) %{cgidir}/*
327 %attr(-,%{dataowner},%{datagroup}) %config(noreplace) %{_sysconfdir}/apcupsd/hosts.conf
328 %attr(-,%{dataowner},%{datagroup}) %config(noreplace) %{_sysconfdir}/apcupsd/multimon.conf
330 %if %{gapcmon}
331 %files gapcmon
332 %defattr(-,root,root)
333 %{_prefix}/bin/gapcmon
334 %{_prefix}/share/applications/gapcmon.desktop
335 %{_prefix}/share/pixmaps/apcupsd.png
336 %{_prefix}/share/pixmaps/charging.png
337 %{_prefix}/share/pixmaps/gapc_prefs.png
338 %{_prefix}/share/pixmaps/onbatt.png
339 %{_prefix}/share/pixmaps/online.png
340 %{_prefix}/share/pixmaps/unplugged.png
341 %endif
343 %post
345 # get rid of any 3.6.2 stuff
346 rm -f /etc/rc.d/rc[0-6].d/[KS]20apcups
347 rm -f %{initdir}/apcups
349 # add our links
350 if [ "$1" -ge 1 ] ; then
351 /sbin/chkconfig --add apcupsd
354 # are we Red Hat or SuSE?
355 # Mandrake already handles apcupsd
356 if [ -s /etc/redhat-release -o -s /etc/SuSE-release -o -s /etc/whitebox-release ]; then
357 cp -f %{initdir}/halt %{initdir}/halt.old
358 awk '# Stuff left over from a previous apcupsd, remove it
359 /^# See if this is a powerfail situation\./ {
360 do {
361 getline
362 } while (length($0) != 0)
363 getline
365 # We insert the new apcupsd code just before the following line
366 /^# Now halt or reboot\./ {
367 print "# See if this is a powerfail situation. # ***apcupsd***"
368 print "if [ -f %{pwrfaildir}/powerfail ]; then # ***apcupsd***"
369 print " echo # ***apcupsd***"
370 print " echo \"APCUPSD will now power off the UPS\" # ***apcupsd***"
371 print " echo # ***apcupsd***"
372 print " %{pwrfaildir}/apccontrol killpower # ***apcupsd***"
373 print " echo # ***apcupsd***"
374 print " echo \"Please ensure that the UPS has powered off before rebooting\" # ***apcupsd***"
375 print " echo \"Otherwise, the UPS may cut the power during the reboot!!!\" # ***apcupsd***"
376 print " echo # ***apcupsd***"
377 print "fi # ***apcupsd***"
378 print ""
380 # Everything else is duplicated
381 { print } ' %{initdir}/halt.old > %{initdir}/halt
383 chmod 744 %{initdir}/halt
386 # restart the daemon if we are upgrading
387 if [ "$1" -ge "2" ] ; then
388 %{initdir}/apcupsd restart
391 # Undo things a bit
393 %preun
395 if [ "$1" = 0 ] ; then
397 # remove startup links
398 /sbin/chkconfig --del apcupsd
400 # are we Red Hat or SuSE?
401 # Mandrake already handles apcupsd
402 if [ -s /etc/redhat-release -o -s /etc/SuSE-release -o -s /etc/whitebox-release ]; then
404 cp -f %{initdir}/halt %{initdir}/halt.old
405 awk '# Stuff added by apcupsd, remove it
406 /^# See if this is a powerfail situation\./ {
407 do {
408 getline
409 } while (length($0) != 0)
410 getline
412 # Everything else is duplicated
413 { print } ' %{initdir}/halt.old > %{initdir}/halt
415 chmod 744 %{initdir}/halt
419 %changelog
420 * Sun Jan 10 2010 Adam Kropelin <akropel1 at rochester.rr.com>
421 - changes for new snmp driver
422 * Sat Aug 01 2009 D. Scott Barninger <barninger at fairfieldcomputers.com>
423 - fix restart on upgrade using $1 variable. remove previously commented out code
424 * Sat May 16 2009 D. Scott Barninger <barninger at fairfieldcomputers.com>
425 - comment out latex build
426 * Fri May 15 2009 Adam Kropelin <akropel1 at rochester.rr.com>
427 - changes for new user manual location and format
428 * Sat May 31 2008 D. Scott Barninger <barninger at fairfieldcomputers.com>
429 - add check for upgrade and restart daemon
430 * Sun May 11 2008 Adam Kropelin <akropel1 at rochester.rr.com>
431 - remove powerflute
432 * Sun Feb 03 2008 D. Scott Barninger <barninger at fairfieldcomputers.com>
433 - add debug package to strip suse
434 * Sat Nov 17 2007 D. Scott Barninger <barninger at fairfieldcomputers.com>
435 - add hal policy file
436 * Sat Nov 10 2007 D. Scott Barninger <barninger at fairfieldcomputers.com>
437 - SuSE 10.3 replaces tetex with texlive-latex package
438 * Sun May 27 2007 Adam Kropelin <akropel1 at rochester.rr.com>
439 - add support for rhel5
440 * Sun Jan 28 2007 D. Scott Barninger <barninger at fairfieldcomputers.com>
441 - remove /etc/apcupsd/masterconnect and mastertimeout files
442 * Sat Jan 27 2007 D. Scott Barninger <barninger at fairfieldcomputers.com>
443 - add snmp build
444 - fix location of Requires for base package
445 * Sun Jan 21 2007 D. Scott Barninger <barninger at fairfieldcomputers.com>
446 - correct gapcmon dependancies
447 * Sat Jan 20 2007 D. Scott Barninger <barninger at fairfieldcomputers.com>
448 - restructure for 3.14 release
449 - merge std and ups packages
450 - remove --enable-pthreads and --enable-master-slave
451 - add --enable-pcnet
452 - break out multimon into separate package
453 - add gapcmon package
454 * Sat Aug 19 2006 D. Scott Barninger <barninger at fairfieldcomputers.com>
455 - add third party packager tag
456 * Fri May 05 2006 D. Scott Barninger <barninger at fairfieldcomputers.com>
457 - update build requirments to include ghostscript
458 - update fedora_core build requirements to include latex2html
459 * Sun Apr 23 2006 D. Scott Barninger <barninger at fairfieldcomputers.com>
460 - add pdf manual to doc package
461 - remove redundant code for std and usb packages
462 - add powerflute
463 * Sat Apr 22 2006 D. Scott Barninger <barninger at fairfieldcomputers.com>
464 - clean up build defines, add rhel4
465 * Sat Jan 21 2006 D. Scott Barninger <barninger at fairfieldcomputers.com>
466 - release 3.12.2 update docs
467 * Sun Sep 18 2005 D. Scott Barninger <barninger at fairfieldcomputers.com>
468 - Change deprecated Copyright tag to License
469 * Tue Jun 07 2005 Adam Kropelin <akropel1@rochester.rr.com>
470 - Rename mainsback.in to offbattery.in so default power loss/return actions
471 - are symmetrical.
472 * Sat Apr 30 2005 D. Scott Barninger <barninger at fairfieldcomputers.com>
473 - fix typo in rh7 dependencies
474 * Sat Mar 12 2005 D. Scott Barninger <barninger at fairfieldcomputers.com>
475 - clean up halt insertion code, add check for whitebox-release
476 - remove cruft that has been commented out for a long time
477 - add pwrfaildir as variable
478 - correct SuSE initdir
479 - add libjpeg libpng zlib freetype dependencies for RH7
480 * Sun Nov 28 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
481 - correct awk insertion in halt script for SuSE
482 * Fri Nov 05 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
483 - change Mandrake logic in preun and post scriptlets to if;then;fi
484 * Sun Oct 31 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
485 - add Mandrake support
486 * Wed Aug 04 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
487 - changed location of apcupsd.css to /etc/apcupsd from /etc/apcupsd/cgi
488 - corrected typo introduced in SuSE configuration for initdir definition
489 * Sun Apr 25 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
490 - add SuSE configuration
491 * Sat Apr 24 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
492 - tidy up doc includes, add release notes
493 * Mon Mar 08 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
494 - added additional clean of buildroot to beginning of install section
495 - corrected post install routines for nicer chkconfig
496 * Sat Jan 17 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
497 - added build of net driver to configure
498 - moved usb driver build into both packages
499 - set --with-serial-dev= to blank so will find any device and removed rh7 patch
500 * Sat Jan 10 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
501 - added build tags for rh8 rh9 fedora_core and wb3
502 - cleaned up dependancies and Requires by platform
503 * Thu Jan 1 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
504 - removed rh_version from package names
505 - added platform build configuration section to beginning of file
506 * Sat Nov 08 2003 Scott at fairfieldcomputers dot com
507 - expanded usb devices from 0-9 to 0-15
508 * Fri Nov 07 2003 Scott at fairfieldcomputers dot com
509 - corrected device path for usb devices to /dev/usb and added patch for
510 - rh7 builds to make it /dev/usb/hid in /etc/apcupsd/apcupsd.conf
511 * Sat Oct 18 2003 Scott at fairfieldcomputers dot com
512 - added master-slave, apcsmart and dumb to configure options
513 * Sun Sep 14 2003 Scott at fairfieldcomputers dot com
514 - added rm commands during install to remove halt scripts created
515 - in the build root
516 * Mon May 11 2003 Scott at fairfieldcomputers dot com
517 - combined layout for usb/serial builds
518 * Thu Jan 16 2003 Scott at fairfieldcomputers dot com
519 - Update spec to new source layout
520 - Added masterconnect and mastertimout to files section
521 - Changed make install-apcupsd and make install-cgi to make install
522 * Wed Sep 05 2001 kern at sibbald dot com
523 - Applied very nice patch to this spec by Giulio Orsero <giulioo@pobox.com>
524 * Thu Sep 14 2000 kern at sibbald dot com
525 - Many thanks to Fredrik Persson and Neil Darlow for helping me write this spec file.
526 - Basic spec by Kern Sibbald