File apcupsd.spec of Package apcupsd

#
# spec file for package apcupsd (Version 3.14.4)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           apcupsd
BuildRequires:  apache2-devel dos2unix gcc-c++ gconf2-devel gd-devel gnome-vfs2-devel gtk2-devel latex2html mailx ncurses-devel net-snmp-devel tcpd-devel update-desktop-files
%if %suse_version > 1010
BuildRequires:  dummy-release
%else
BuildRequires:  suse-release
%endif
Group:          Hardware/UPS
License:        GPL v2 or later
Summary:        APC UPS Daemon (Powerful Daemon for APC UPSs)
Version:        3.14.4
Release:        44
Url:            http://www.apcupsd.com/
Source:         apcupsd-%{version}.tar.bz2
Source1:        apcupsd.init
Source2:        README.SUSE
Source3:        apcupsd-early-powerdown.init
Patch:          apcupsd-suse.patch
Patch1:         apcupsd-gpp.patch
Patch3:         apcupsd-powersave.patch
Patch5:         apcupsd-largebuf-overflow.patch
Patch6:         apcupsd-install-apctest-man.patch
Patch7:         apcupsd-link-index-html.patch
PreReq:         %fillup_prereq %insserv_prereq /usr/bin/sed /usr/bin/grep
Requires:       /usr/bin/mail
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define apache_serverroot %(/usr/sbin/apxs2 -q datadir 2>/dev/null || /usr/sbin/apxs -q PREFIX)

%description
Controls and monitors the status of an APC UPS under Linux. Allows your
computer or server to run for a specified length of time on UPS power
then executes a controlled shutdown in the case of an extended power
failure. Find APC on the Internet at http://www.apc.com/.

APC also made their PowerChute plus available for download at
http://www.apc.com/tools/download/.



Authors:
--------
    Andre Hedrick
    Adam Kropelin
    Kern Sibbald

%package gui
License:        GPL v2 or later
Group:          Hardware/UPS
Summary:        APC UPS Monitor GUI (for APC UPSs)
Requires:       %{name} = %{version}

%description gui
Controls and monitors the status of an APC UPS under Linux. Allows your
computer or server to run for a specified length of time on UPS power
then executes a controlled shutdown in the case of an extended power
failure. Find APC on the Internet at http://www.apc.com/.

APC also made their PowerChute plus available for download at
http://www.apc.com/tools/download/.



Authors:
--------
    James Scott, Jr.

%prep
%setup -q
rm include/tcpd.h
cp -a %{S:1} platforms/suse/apcupsd.in
cp -a %{S:2} .
cp -a %{S:3} apcupsd-early-powerdown
chmod +x apcupsd-early-powerdown
%patch
%patch1
%patch3
chmod -x kernstodo
%patch5
%patch6 -p1
%patch7 -p1

%build
%{suse_update_config}
# Incomplete:
#cd autoconf
#aclocal
#autoconf
#cp configure ..
#cd ..
%if "%suse_version" == "910"
export CFLAGS="$RPM_OPT_FLAGS -DHID_MAX_USAGES=1024"
%endif
%configure\
	--sbindir=/sbin\
	--sysconfdir=%{_sysconfdir}/apcupsd\
	--enable-usb\
	--enable-nls\
	--with-cgi-bin=%{apache_serverroot}/cgi-bin
make %{?jobs:-j %jobs}
cp -a src/apcupsd src/apcupsd-lite
make clean
%configure\
	--sysconfdir=%{_sysconfdir}/apcupsd\
	--with-libwrap\
	--enable-all\
	--enable-nls\
	--with-cgi-bin=%{apache_serverroot}/cgi-bin
make %{?jobs:-j %jobs}
cd doc/latex
make web
cd ../..

%install
%makeinstall
mkdir -p $RPM_BUILD_ROOT/sbin
install src/apcupsd-lite $RPM_BUILD_ROOT/sbin
ln -sf ../../etc/init.d/apcupsd $RPM_BUILD_ROOT/usr/sbin/rcapcupsd
%suse_update_desktop_file gapcmon
chmod 644 $RPM_BUILD_ROOT/usr/share/pixmaps/*.png
mv doc/latex/apcupsd users_guide
cd users_guide
rm -f imagename_translations images.aux images.idx images.log images.out images.pl images.tex internals.pl labels.pl WARNINGS
cd ..
# fix docu permissions
rm examples/safe.apccontrol.in
find examples users_guide -type f | xargs chmod 644
# fix end-of-line encoding
dos2unix -o examples/status/SmartUPS-vs-650.status examples/snoopdecode.c examples/rpt/Smart-UPS-1500.rpt \
	examples/rpt/Back-UPS-ES-550.rpt examples/rpt/Back-UPS-CS-650.rpt examples/rpt/Back-UPS-BR-800.rpt

%post
%{fillup_and_insserv apcupsd}
# HALT_POWERDOWN_INSERT is supported since SuSE Linux 10.1, SLES 10.
# Install HALT_POWERDOWN_INSERT
if usr/bin/grep -q '^HALT_POWERDOWN_INSERT="\(/etc/apcupsd/apccontrol killpower\|/etc/init\.d/apcupsd try-powerdown\|\)"' etc/sysconfig/shutdown ; then
  usr/bin/sed -i 's:^\(HALT_POWERDOWN_INSERT="\).*"[[:space:]]*:\1/etc/init.d/apcupsd try-powerdown":' etc/sysconfig/shutdown
else
  echo >&2 "apcupsd: WARNING: Unknown value of HALT_POWERDOWN_INSERT in /etc/sysconfig/shutdown."
  echo >&2 "         Keeping unchanged. Should be:"
  echo >&2 "HALT_POWERDOWN_INSERT=\"/etc/init.d/apcupsd try-powerdown\""
fi
# NOTE: Up to SuSE Linux 10.0, SLES 9 installation modified /etc/init.d/halt.local.
# Now it is obsolete and should be removed.
if [ -f etc/init.d/halt.local ]
then
    if usr/bin/grep -q "XXX APCUPSD - DO NOT EDIT XXX" etc/init.d/halt.local ; then
# NOTE: SuSE Linux 8.2, SLES 8 and older have had a bug: Last "fi"
# command was not commented by $MAGICWORD and was not replaced during
# update. This script tries to detect such orphan "fi".
	usr/bin/sed -i ':1;/XXX APCUPSD - DO NOT EDIT XXX/,+1s/^fi$/& # XXX APCUPSD - DO NOT EDIT XXX/;t1;/XXX APCUPSD - DO NOT EDIT XXX/d' etc/init.d/halt.local
    fi
fi

%preun
%{stop_on_removal apcupsd}

%postun
# Remove HALT_POWERDOWN_INSERT
if test $1 -eq 0 -a ! -f /etc/init.d/apcupsd ; then
  if usr/bin/grep -q '^HALT_POWERDOWN_INSERT="\(/etc/init\.d/apcupsd try-powerdown\)"' etc/sysconfig/shutdown ; then
    usr/bin/sed -i 's:^\(HALT_POWERDOWN_INSERT="\)\(/etc/init\.d/apcupsd try-powerdown\)":\1":' etc/sysconfig/shutdown
  else
    echo >&2 "apcupsd: WARNING: Unknown value of HALT_POWERDOWN_INSERT in /etc/sysconfig/shutdown."
    echo >&2 "         Keeping unchanged. Should be:"
    echo >&2 "HALT_POWERDOWN_INSERT=\"\""
  fi
  if test -f etc/init.d/apcupsd-early-powerdown ; then
    echo >&2 "apcupsd: WARNING: You may want to remove your /etc/init.d/apcupsd-early-powerdown."
  fi
fi
%{restart_on_update apcupsd}
%{insserv_cleanup}

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc apcupsd-early-powerdown COPYING ChangeLog* DISCLAIMER Developers INSTALL README.SUSE ReleaseNotes kernstodo users_guide/ examples/
/sbin/apcupsd-lite
%{_datadir}/hal/fdi/policy/20thirdparty/*.fdi
%{_sbindir}/apcupsd
%{_sbindir}/apcaccess
%{_sbindir}/apctest
%{_sbindir}/rcapcupsd
%{_sbindir}/smtp
/etc/init.d/apcupsd
%dir %{_sysconfdir}/apcupsd/
%{_sysconfdir}/apcupsd/apccontrol
%config(noreplace)%{_sysconfdir}/apcupsd/apcupsd.conf
%{_sysconfdir}/apcupsd/changeme
%{_sysconfdir}/apcupsd/commfailure
%{_sysconfdir}/apcupsd/commok
%config(noreplace) %{_sysconfdir}/apcupsd/hosts.conf
%config(noreplace) %{_sysconfdir}/apcupsd/multimon.conf
%{_sysconfdir}/apcupsd/onbattery
%{_sysconfdir}/apcupsd/offbattery
%{_sysconfdir}/apcupsd/apcupsd.css
%{apache_serverroot}/cgi-bin/multimon.cgi
%{apache_serverroot}/cgi-bin/upsfstats.cgi
%{apache_serverroot}/cgi-bin/upsstats.cgi
%{apache_serverroot}/cgi-bin/upsimage.cgi
%doc %{_mandir}/man8/apcupsd.8*
%doc %{_mandir}/man8/apctest.8*

%files gui
%defattr(-,root,root)
%{_bindir}/gapcmon
%{_datadir}/applications/gapcmon.desktop
%{_datadir}/pixmaps/*.png

%changelog
* Fri Sep 19 2008 ro@suse.de
- buildreq dummy-release instead of openSUSE-release
* Mon Jul 14 2008 sbrabec@suse.cz
- Updated to version 3.14.3:
  * Build system rewrite.
  * Built-in version of libgd for multimon cgi has been removed
  * Removal of NLS support.
  * Powerflute has been disabled.
  * gapcmon: Corrected the use of NOMPOWER and the calc of current
  usage amount.
  * Add a heuristic to fix up incorrect NOMINV or NOMOUTV.
  * Fix hal policy file syntax.
  * A HAL policy file is automatically installed on Linux systems
  to disable the hald-addon-hid-ups module which conflicts with
  apcupsd's control of USB UPSes.
  * Add support for Nominal Power.
  * Add units to NOMINV, NOMOUTV, and NOMBATTV stats.
  * Eliminate warnings emitted from gcc-4.2.1.
  * Fix killpower and eeprom settings bug on USB models introduced
  when INPUT reports were prioritized over FEATURE reports.
  * Fix bugs that could cause NIS-net driver to get stuck waiting
  for comms to be restored instead of shutting down.
- Fixed UPS shutdown on systems with /usr on a different file
  system (bnc#407269).
* Wed Feb 20 2008 jdelvare@suse.de
- Remove duplicate index.html file in documentation, create a
  symbolic link instead to save some disk space.
- Fix rpmlint warnings about bad end-of-line encoding of some
  documentation files.
* Mon Feb 18 2008 jdelvare@suse.de
- Package apctest.8 properly.
- Convert the user's guide to HTML before packaging it. Not that
  many users know what to do with latex source files (361885).
- Do not package the uninteresting or redundant documentation.
  This makes the package 4 times smaller (installed size divided
  by 15, from 33.1 MB to 2.2 MB on i386) (361885).
* Mon Jan 21 2008 sbrabec@suse.cz
- Updated to version 3.14.3:
  * HAL policy file is automatically installed on Linux systems to
  disable the hald-addon-hid-ups module which conflicts with
  apcupsd's control of USB UPSes. The file is automatically
  removed when apcupsd is uninstalled.
  * Add support for Nominal Power (aka Configured Active Power)
  reading.
  * Add units to NOMINV, NOMOUTV, and NOMBATTV stats.
  * Eliminate some gcc warnings.
  * Fix killpower and eeprom settings bug on USB modules introduced
  when INPUT reports were prioritized over FEATURE reports.
  * Fix bugs that could cause NIS-net driver to get stuck waiting
  for comms to be restored instead of shutting down.
- Fixed possible buffer overflow.
- Removed support for SuSE Linux <= 10.0.
* Mon Jan 14 2008 sbrabec@suse.cz
- Updated to version 3.14.2:
  * USB fix for BackUPS LCD series. This fix carries a risk of
  breaking other models, but test results are positive so far.
  * Fix linux-usb device detection bug when multiple hiddev nodes
  are present. Fixes Fedora#245864:
  * Fix SNMP port selection when using SNMP driver.
  * Add workaround for broken BackUPS Pro model that returns
  certain reports encoded in ASCII.
  * apcsmart: Wait 20 seconds before declaring COMMLOST.
  * Documentation updates: Fix up udev info for modern Linux
  distros.
  * Don't leak unnecessary descriptors to child when execing
  apccontrol.
  * Fix bug with multi-threaded net_open() calls.
  * Correct multimon.conf humidity monitoring. (Novell#199834)
  * Fix race between attach_ups() and detach_ups().
  * Remove dependency on libc++ (again).
* Thu Aug 23 2007 sbrabec@suse.cz
- Fixed multimon.conf comments for humidity measurement (#199834).
* Tue Jul 24 2007 ro@suse.de
- fix build
* Wed Jul 04 2007 sbrabec@suse.cz
- Updated to version 3.14.1:
  * PCNET driver supports remote shutdown request from UPS web
  interface
  * Fix potential NIS client lockup when server disappears.
  * Fix crash when displaying EEPROM values more than once.
  * Increase self-test timeout to 40 seconds to accomodate the
  RS 800.
  * Rewrite device opening logic to be more reliable.
  * Do not attempt to cancel shutdowns.
* Thu May 24 2007 ro@suse.de
- fix some rpmlint errors
* Wed Apr 11 2007 sbrabec@suse.cz
- Updated to version 3.14.0:
  * New stable release.
  * Bug fixes.
* Thu Nov 16 2006 mrueckert@suse.de
- added apcupsd-3.13.9_missing_netsnmp_include.patch:
  include for net-snmp-config.h was missing.
* Tue Nov 07 2006 ro@suse.de
- fix permissions for icon files
* Fri Oct 20 2006 sbrabec@suse.cz
- Updated to version 3.13.9:
  * Runtime configurable paths for apccontrol.
  * Ambient temperature is reported for USB UPSes with a AP9612
  SmartSlot card.
  * pcnet driver detects COMMLOST and SelfTest events.
  * pcnet driver supports killpower (turning off UPS output power).
  * Bug fixes.
* Wed Sep 20 2006 sbrabec@suse.cz
- Build correctly in older products.
* Wed Sep 20 2006 sbrabec@suse.cz
- Create /sbin/apcupsd-lite, working with unmounted /usr (#186606).
- Call killpower only if power is failing (#186606#6) (#187454).
- Minor fixes of previous update.
* Mon Sep 18 2006 sbrabec@suse.cz
- Updated to version 3.13.8:
  * GUI monitoring application, gapcmon.
  * Bug fixes.
* Tue Sep 12 2006 aj@suse.de
- Adjust BuildRequires.
* Mon Apr 03 2006 sbrabec@suse.cz
- Do not remove /etc/nologin, if changes are disabled (#161709).
* Sat Mar 25 2006 ro@suse.de
- remove second preun script
* Fri Mar 24 2006 sbrabec@suse.cz
- Removed fast incorrect shutdown script (#132478).
- Added README.SUSE.
- Integrated with powersave.
- Do not strip binaries.
- Simplified neededforbuild.
- Removed obsolete halt-setup.sh and clean halt.local.
- Scriptlet fixes.
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Tue Jan 24 2006 ro@suse.de
- disable parallel build, seems to cause trouble
* Thu Jan 12 2006 sbrabec@suse.cz
- Updated to version 3.12.1.
* Fri Sep 30 2005 sbrabec@suse.cz
- Updated to version 3.10.18 (#116685).
* Tue Jul 12 2005 sbrabec@suse.cz
- Updated to version 3.10.17a.
- Moved binaries (linked against libraries in /usr) to /usr/sbin.
* Wed May 04 2005 sbrabec@suse.cz
- Removed START_APCUPSD from halt.local (#81281).
* Thu Jan 06 2005 sbrabec@suse.cz
- Updated to version 3.10.16.
* Tue Nov 30 2004 sbrabec@suse.cz
- Fixed OS misdetection (missing USB support, #48607).
  Patch from Andrea Arcangeli.
* Mon Aug 23 2004 sbrabec@suse.cz
- Updated to version 3.10.15.
* Mon Apr 19 2004 ro@suse.de
- Force-define HID_MAX_USAGES
- build using apache2
* Fri Mar 19 2004 sbrabec@suse.cz
- Removed *.orig files from documentation.
* Thu Feb 05 2004 sbrabec@suse.cz
- Updated to version 3.10.11.
* Mon Nov 10 2003 ro@suse.de
- use net-snmp instead of ucdsnmp
* Wed Sep 17 2003 kukuk@suse.de
- Remove setuid bit from apcupsd (else SuSEconfig will do it)
* Mon Sep 01 2003 sbrabec@suse.cz
- Removed tcpd.h (use systemwide instead).
* Mon Sep 01 2003 sbrabec@suse.cz
- Added "Should-Start: hotplug_usb" to init script.
- Fix and update hack of orphan fi in halt.local.
- Fixed pre and postinstall scripts.
- Really turned on and fixed SNMP support.
* Fri Aug 29 2003 kukuk@suse.de
- Add "Should-Start: serial" to init script [Bug #28353]
* Fri Aug 15 2003 sbrabec@suse.cz
- Updated to development version 3.10.6-05Aug03.
- Turned on all optional features.
* Mon Mar 10 2003 sbrabec@suse.cz
- Buffer overflow fixes.
- Name clash and error handling fixes.
* Wed Feb 12 2003 sbrabec@suse.cz
- Updated to version 3.8.6.
* Thu Aug 15 2002 mcihar@suse.cz
- added $remote_fs to Required-Start (should fix #17294)
* Fri Aug 02 2002 ro@suse.de
- adapted to /srv/www
- added prereqs
* Sat Jul 27 2002 adrian@suse.de
- fix build
* Mon Jan 07 2002 cihlar@suse.cz
- updated to version 3.8.5:
  * Battery Runtime Calibration in the apctest
  program
  * Resolved a crash caused by a lost TCP/IP
  connection
* Mon Dec 17 2001 cihlar@suse.cz
- updated to version 3.8.4-2:
  * bug fix release
* Mon Dec 10 2001 cihlar@suse.cz
- removed START_APCUPSD
* Thu Nov 29 2001 cihlar@suse.cz
- update to version 3.8.3:
  * updated manual
  * several bug fixes
  * added support for new hardware
- fixed permissions of halt-setup.sh
- fixed halt-setup.sh
- moved halt-setup.sh from %%postun to %%preun
* Tue Nov 27 2001 cihlar@suse.cz
- fixed variable names in init script [#12451]
* Thu Jul 26 2001 cihlar@suse.cz
- fixed call of suse_update_config
* Wed Jul 25 2001 cihlar@suse.cz
- update to 3.8.2
- added part with autoconf
- compile with --with-libwrap and --enable-pthreads
* Thu Apr 12 2001 cihlar@suse.cz
- fixed init script by new skeleton
* Mon Jan 15 2001 cihlar@suse.cz
- added apctest
* Wed Jan 10 2001 cihlar@suse.cz
- update to 3.8.1
- change to new init script mechanism
- fixed initialization of halt.local
- added BuildRoot
- clean up spec file
- bzipped sources
- added fillup of rc.config
* Mon Jun 19 2000 kasal@suse.de
- Updated to 3.7.2.  The package is still BETA, see "Todo" below.
* Sun Oct 10 1999 bk@suse.de
- new package, requested e.g by Andre Hedrick <andre@suse.com>
  Todo:
  - polish /sbin/init.d/apcupsd and add links to the rcX.d directories
  - add the proper START_APCUPSD= fillup for /etc/rc.config
  - add the changes for halt.sh in the suse subdir
openSUSE Build Service is sponsored by