# TODO:
-# - upssched-cmd installed in /usr/bin, should be /sbin (Patch0, client/Makefile.am)
-# - _datadir files installed in /usr/share (Patch1, data/Makefile.am)
-# - hidups bcond has wrong name and description (should be "usbups"? or removed)
-# - unpackaged files:
-# /usr/html/{{bottom,header,index}.html,nut-banner.png}
-# /etc/udev/rules.d/52_nut-usbups.rules
-# - check hal BR
+# - upsdrvctl (used by ups.init) doesn't recognize status and reload commands
+#
+# Conditional build:
+%bcond_without usb # build without usb drivers
+%bcond_without snmp # build without snmp driver
+%bcond_without cgi # build without cgi support
+%bcond_without neon # build with neon based XML/HTTP driver
#
Summary: Network UPS Tools
Summary(pl.UTF-8): Sieciowe narzędzie do UPS-ów
Name: nut
-Version: 2.2.0
-Release: 0.1
+Version: 2.7.4
+Release: 1
License: GPL
Group: Applications/System
-Source0: http://eu1.networkupstools.org/source/2.2/%{name}-%{version}.tar.gz
-# Source0-md5: a3570515d80804051d4e7631e8a3eb12
+Source0: http://www.networkupstools.org/source/2.7/%{name}-%{version}.tar.gz
+# Source0-md5: 3ba53656933d7471f95140b32a5b8d5c
Source1: %{name}.init
Source2: %{name}.sysconfig
Source3: %{name}-upsmon.init
Source4: %{name}.sysconfig.upsmon
Patch0: %{name}-client.patch
-Patch1: %{name}-datadir.patch
-Patch2: %{name}-config.patch
-Patch3: %{name}-smartdp-load.patch
+Patch1: %{name}-config.patch
+Patch2: %{name}-smartdp-load.patch
+Patch3: %{name}-upssched-cmd-sysconf.patch
+Patch4: %{name}-matrix.patch
+Patch5: systemd-sysconfig.patch
+Patch6: bcmxcp-off-by-one.patch
+Patch7: %{name}-build.patch
URL: http://www.networkupstools.org/
BuildRequires: autoconf
BuildRequires: automake
-BuildRequires: gd-devel >= 2.0.15
-BuildRequires: libpng-devel
-BuildRequires: net-snmp-devel
+BuildRequires: avahi-devel
+BuildRequires: freeipmi-devel
+%{?with_cgi:BuildRequires: gd-devel >= 2.0.15}
+BuildRequires: libltdl-devel
+BuildRequires: libtool
+%{?with_usb:BuildRequires: libusb-compat-devel}
+BuildRequires: libwrap-devel
+%{?with_neon:BuildRequires: neon-devel}
+%{?with_snmp:BuildRequires: net-snmp-devel}
BuildRequires: openssl-devel >= 0.9.7d
-BuildRequires: rpmbuild(macros) >= 1.268
-BuildRequires: xorg-lib-libXpm-devel
+BuildRequires: pkgconfig
+BuildRequires: rpmbuild(macros) >= 1.647
+Requires: systemd-units >= 38
Requires(post,preun): /sbin/chkconfig
Requires: %{name}-common = %{version}-%{release}
Requires: rc-scripts
+Obsoletes: nut-hal
Obsoletes: smartupstools
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%define _sysconfdir /etc/ups
+%define _udevrulesdir /etc/udev/rules.d
%description
These programs are part of a developing project to monitor the
Requires(post,preun): /sbin/chkconfig
Requires: %{name}-common = %{version}-%{release}
Requires: rc-scripts
+Requires: systemd-units >= 38
%description client
This package includes the client utilities that are required to
Summary: Files for NUT clients development
Summary(pl.UTF-8): Pliki do tworzenia klientów NUT-a
Group: Development/Libraries
+Requires: %{name}-common = %{version}-%{release}
Requires: openssl-devel >= 0.9.7c
-# it does NOT require nut
%description devel
Object file and header for developing NUT clients.
%prep
%setup -q
-#patch0 -p1
+%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
%build
cp -f /usr/share/automake/config.sub .
+%{__libtoolize}
%{__aclocal} -I m4
+%{__automake}
%{__autoconf}
%configure \
- --with-hal \
+ --datadir=%{_datadir}/%{name} \
+ --with-htmlpath=%{_datadir}/%{name}/html \
--with-serial \
- --with-snmp \
- --with-usb \
+ --with%{!?with_usb:out}-usb \
+ --with%{!?with_snmp:out}-snmp \
+ --with%{!?with_cgi:out}-cgi \
+ --with-avahi \
+ --with-ipmi \
+ --with-dev \
+ --with%{!?with_neon:out}-neon \
--with-ssl \
- --with-cgi \
- --with-linux-hiddev=%{_includedir}/linux/hiddev.h \
+ --with-openssl \
+ %{?with_usb:--with-udev-dir=/etc/udev} \
--with-statepath=%{_var}/lib/ups \
--with-drvpath=/lib/nut \
--with-cgipath=/home/services/httpd/cgi-bin \
+ --with-systemdsystemunitdir=%{systemdunitdir} \
--with-user=ups \
--with-group=ups
-%{__make} all snmp cgi
+
+%{__make}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{/sbin,/etc/{sysconfig,rc.d/init.d},/var/lib/ups} \
- $RPM_BUILD_ROOT{/lib/nut,%{_libdir},%{_includedir}/nut}
+install -d $RPM_BUILD_ROOT{/etc/{sysconfig,rc.d/init.d},/var/lib/ups,/lib/nut,/sbin}
-%{__make} -j1 install install-snmp install-cgi \
+%{__make} install \
DESTDIR=$RPM_BUILD_ROOT
install %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/ups
install %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/upsmon
install %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/upsmon
-rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/*
-install conf/upsd.users.sample $RPM_BUILD_ROOT%{_sysconfdir}/upsd.users
-install conf/hosts.conf.sample $RPM_BUILD_ROOT%{_sysconfdir}/hosts.conf
-install conf/ups.conf.sample $RPM_BUILD_ROOT%{_sysconfdir}/ups.conf
-install conf/upsd.conf.sample $RPM_BUILD_ROOT%{_sysconfdir}/upsd.conf
-install conf/upsmon.conf.sample $RPM_BUILD_ROOT%{_sysconfdir}/upsmon.conf
-install conf/upssched.conf.sample $RPM_BUILD_ROOT%{_sysconfdir}/upssched.conf
-install conf/upsset.conf.sample $RPM_BUILD_ROOT%{_sysconfdir}/upsset.conf
-install conf/upsstats.html.sample $RPM_BUILD_ROOT%{_sysconfdir}/upsstats.html
-install conf/upsstats-single.html.sample $RPM_BUILD_ROOT%{_sysconfdir}/upsstats-single.html
+ln -s /dev/null $RPM_BUILD_ROOT%{systemdunitdir}/ups.service
+ln -s /dev/null $RPM_BUILD_ROOT%{systemdunitdir}/upsmon.service
-install clients/upsclient.o common/parseconf.o $RPM_BUILD_ROOT%{_libdir}
-install clients/upsclient.h include/parseconf.h $RPM_BUILD_ROOT%{_includedir}/nut
+for i in $RPM_BUILD_ROOT%{_sysconfdir}/*.sample; do
+ mv -f $i ${i%.sample}
+done
+
+%{!?with_usb:rm -f $RPM_BUILD_ROOT%{_udevrulesdir}/62-nut-usbups.rules}
cat > $RPM_BUILD_ROOT/sbin/poweroff-ups << EOF
#!/bin/sh
-/etc/rc.d/init.d/ups powerdown
+echo "Switching the power off"
+/lib/nut/upsdrvctl shutdown
+sleep 60
EOF
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/*.la
+
%clean
rm -rf $RPM_BUILD_ROOT
%post
+/sbin/ldconfig
/sbin/chkconfig --add ups
%service ups restart "NUT ups daemon"
+%systemd_post nut-driver.service nut-server.service
%preun
if [ "$1" = "0" ]; then
%service ups stop
/sbin/chkconfig --del ups
fi
+%systemd_preun nut-driver.service nut-server.service
+
+%postun
+/sbin/ldconfig
+%systemd_reload
+
+%triggerpostun -- nut < 2.6.4-2
+[ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
+[ ${RPM_ENABLE_SYSTEMD_SERVICE:-yes} = no ] && exit 0
+[ "$(echo /etc/rc.d/rc[0-6].d/S[0-9][0-9]ups)" != "/etc/rc.d/rc[0-6].d/S[0-9][0-9]ups" ] || exit 0
+%systemd_service_enable nut-driver.service nut-server.service
%pre common
# move to trigger?
-if [ -n "`/usr/bin/getgid ups`" ] && [ "`/usr/bin/getgid ups`" = 121 ]; then
+if [ -n "`/usr/bin/getgid ups 2> /dev/null`" ] && [ "`/usr/bin/getgid ups 2> /dev/null`" = 121 ]; then
/usr/sbin/groupmod -g 76 ups
chgrp ups %{_sysconfdir}/{upsd.conf,ups.conf,upsd.users}
/usr/sbin/usermod -g 76 ups
%groupadd -g 76 ups
%useradd -u 70 -d /usr/share/empty -s /bin/false -c "UPS Manager User" -g ups ups
+%post common -p /sbin/ldconfig
+
+%postun common
+/sbin/ldconfig
+if [ "$1" = "0" ]; then
+ %userremove ups
+ %groupremove ups
+fi
+
%post client
/sbin/chkconfig --add upsmon
%service upsmon restart "NUT upsmon daemon"
+%systemd_post nut-monitor.service
%preun client
if [ "$1" = "0" ]; then
%service upsmon stop
/sbin/chkconfig --del upsmon
fi
+%systemd_preun nut-monitor.service
-%postun common
-if [ "$1" = "0" ]; then
- %userremove ups
- %groupremove ups
-fi
+%postun client
+%systemd_reload
+
+%triggerpostun client -- nut-client < 2.6.4-2
+[ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
+[ ${RPM_ENABLE_SYSTEMD_SERVICE:-yes} = no ] && exit 0
+/sbin/chkconfig --list upsmon 2>/dev/null | grep -qsv "[0-6]:on" && exit 0
+[ "$(echo /etc/rc.d/rc[0-6].d/S[0-9][0-9]upsmon)" != "/etc/rc.d/rc[0-6].d/S[0-9][0-9]upsmon" ] || exit 0
+%systemd_service_enable nut-monitor.service
%files
%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/nut-scanner
%attr(755,root,root) %{_bindir}/upscmd
%attr(755,root,root) %{_bindir}/upslog
%attr(755,root,root) %{_bindir}/upsrw
%attr(755,root,root) %{_sbindir}/upsd
+%attr(755,root,root) %{_sbindir}/upsdrvctl
%attr(755,root,root) /sbin/poweroff-ups
+%attr(755,root,root) %ghost %{_libdir}/libnutscan.so.1
+%attr(755,root,root) %{_libdir}/libnutscan.so.*.*.*
%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/ups
%attr(754,root,root) /etc/rc.d/init.d/ups
+%attr(640,root,ups) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nut.conf
%attr(640,root,ups) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/upsd.conf
%attr(640,root,ups) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/ups.conf
%attr(640,root,ups) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/upsd.users
+%{systemdunitdir}/nut-driver.service
+%{systemdunitdir}/nut-server.service
+%{systemdunitdir}/ups.service
%{_mandir}/man5/ups.conf.5*
%{_mandir}/man5/upsd.conf.5*
%{_mandir}/man5/upsd.users.5*
+%{_mandir}/man8/nut-recorder.8*
+%{_mandir}/man8/nut-scanner.8*
%{_mandir}/man8/upscmd.8*
%{_mandir}/man8/upscode2.8*
%{_mandir}/man8/upsd.8*
%dir /lib/nut
%attr(755,root,root) /lib/nut/al175
%attr(755,root,root) /lib/nut/apcsmart
+%attr(755,root,root) /lib/nut/apcsmart-old
+%attr(755,root,root) /lib/nut/apcupsd-ups
%attr(755,root,root) /lib/nut/bcmxcp
-%attr(755,root,root) /lib/nut/bcmxcp_usb
+%{?with_usb:%attr(755,root,root) /lib/nut/bcmxcp_usb}
%attr(755,root,root) /lib/nut/belkin
%attr(755,root,root) /lib/nut/belkinunv
%attr(755,root,root) /lib/nut/bestfcom
+%attr(755,root,root) /lib/nut/bestfortress
%attr(755,root,root) /lib/nut/bestuferrups
%attr(755,root,root) /lib/nut/bestups
-%attr(755,root,root) /lib/nut/cpsups
-%attr(755,root,root) /lib/nut/cyberpower
+%attr(755,root,root) /lib/nut/blazer_ser
+%{?with_usb:%attr(755,root,root) /lib/nut/blazer_usb}
+%attr(755,root,root) /lib/nut/clone
+%attr(755,root,root) /lib/nut/clone-outlet
%attr(755,root,root) /lib/nut/dummy-ups
-%attr(755,root,root) /lib/nut/energizerups
%attr(755,root,root) /lib/nut/etapro
%attr(755,root,root) /lib/nut/everups
%attr(755,root,root) /lib/nut/gamatronic
%attr(755,root,root) /lib/nut/genericups
-%attr(755,root,root) /lib/nut/hald-addon-bcmxcp_usb
-%attr(755,root,root) /lib/nut/hald-addon-megatec_usb
-%attr(755,root,root) /lib/nut/hald-addon-tripplite_usb
-%attr(755,root,root) /lib/nut/hald-addon-usbhid-ups
%attr(755,root,root) /lib/nut/isbmex
+%attr(755,root,root) /lib/nut/ivtscd
%attr(755,root,root) /lib/nut/liebert
+%attr(755,root,root) /lib/nut/liebert-esp2
%attr(755,root,root) /lib/nut/masterguard
-%attr(755,root,root) /lib/nut/megatec
-%attr(755,root,root) /lib/nut/megatec_usb
%attr(755,root,root) /lib/nut/metasys
%attr(755,root,root) /lib/nut/mge-shut
%attr(755,root,root) /lib/nut/mge-utalk
-%attr(755,root,root) /lib/nut/newmge-shut
-%attr(755,root,root) /lib/nut/nitram
+%attr(755,root,root) /lib/nut/microdowell
+%{?with_neon:%attr(755,root,root) /lib/nut/netxml-ups}
+%{?with_usb:%attr(755,root,root) /lib/nut/nutdrv_atcl_usb}
+%attr(755,root,root) /lib/nut/nutdrv_qx
+%attr(755,root,root) /lib/nut/nut-ipmipsu
+%attr(755,root,root) /lib/nut/oldmge-shut
%attr(755,root,root) /lib/nut/oneac
%attr(755,root,root) /lib/nut/optiups
%attr(755,root,root) /lib/nut/powercom
%attr(755,root,root) /lib/nut/powerpanel
%attr(755,root,root) /lib/nut/rhino
+%{?with_usb:%attr(755,root,root) /lib/nut/richcomm_usb}
+%attr(755,root,root) /lib/nut/riello_ser
+%{?with_usb:%attr(755,root,root) /lib/nut/riello_usb}
%attr(755,root,root) /lib/nut/safenet
%attr(755,root,root) /lib/nut/skel
-%attr(755,root,root) /lib/nut/snmp-ups
+%{?with_snmp:%attr(755,root,root) /lib/nut/snmp-ups}
%attr(755,root,root) /lib/nut/solis
%attr(755,root,root) /lib/nut/tripplite
%attr(755,root,root) /lib/nut/tripplitesu
-%attr(755,root,root) /lib/nut/tripplite_usb
+%{?with_usb:%attr(755,root,root) /lib/nut/tripplite_usb}
%attr(755,root,root) /lib/nut/upscode2
-%attr(755,root,root) /lib/nut/upsdrvctl
-%attr(755,root,root) /lib/nut/usbhid-ups
+%{?with_usb:%attr(755,root,root) /lib/nut/usbhid-ups}
%attr(755,root,root) /lib/nut/victronups
-#{_datadir}/nut
+%dir %{_datadir}/nut
+%{_datadir}/nut/cmdvartab
+%{_datadir}/nut/driver.list
+%{_mandir}/man5/nut.conf.5*
%{_mandir}/man8/al175.8*
%{_mandir}/man8/apcsmart.8*
+%{_mandir}/man8/apcsmart-old.8*
+%{_mandir}/man8/apcupsd-ups.8*
%{_mandir}/man8/bcmxcp.8*
-%{_mandir}/man8/bcmxcp_usb.8*
+%{?with_usb:%{_mandir}/man8/bcmxcp_usb.8*}
%{_mandir}/man8/belkin.8*
%{_mandir}/man8/belkinunv.8*
%{_mandir}/man8/bestfcom.8*
+%{_mandir}/man8/bestfortress.8*
%{_mandir}/man8/bestuferrups.8*
%{_mandir}/man8/bestups.8*
-%{_mandir}/man8/cpsups.8*
-%{_mandir}/man8/cyberpower.8*
+%{_mandir}/man8/blazer_ser.8*
+%{?with_usb:%{_mandir}/man8/blazer_usb.8*}
+%{_mandir}/man8/clone.8*
%{_mandir}/man8/dummy-ups.8*
-%{_mandir}/man8/energizerups.8*
%{_mandir}/man8/etapro.8*
%{_mandir}/man8/everups.8*
%{_mandir}/man8/gamatronic.8*
%{_mandir}/man8/genericups.8*
%{_mandir}/man8/isbmex.8*
+%{_mandir}/man8/ivtscd.8*
%{_mandir}/man8/liebert.8*
+%{_mandir}/man8/liebert-esp2.8*
%{_mandir}/man8/masterguard.8*
-%{_mandir}/man8/megatec.8*
-%{_mandir}/man8/megatec_usb.8*
%{_mandir}/man8/metasys.8*
%{_mandir}/man8/mge-shut.8*
%{_mandir}/man8/mge-utalk.8*
-%{_mandir}/man8/nitram.8*
+%{_mandir}/man8/microdowell.8*
+%{?with_neon:%{_mandir}/man8/netxml-ups.8*}
+%{?with_usb:%{_mandir}/man8/nutdrv_atcl_usb.8*}
+%{_mandir}/man8/nutdrv_qx.8*
+%{_mandir}/man8/nut-ipmipsu.8*
%{_mandir}/man8/nutupsdrv.8*
%{_mandir}/man8/oneac.8*
%{_mandir}/man8/optiups.8*
%{_mandir}/man8/powercom.8*
%{_mandir}/man8/powerpanel.8*
%{_mandir}/man8/rhino.8*
+%{?with_usb:%{_mandir}/man8/richcomm_usb.8*}
+%{_mandir}/man8/riello_ser.8*
+%{?with_usb:%{_mandir}/man8/riello_usb.8*}
%{_mandir}/man8/safenet.8*
-%{_mandir}/man8/snmp-ups.8*
+%{?with_snmp:%{_mandir}/man8/snmp-ups.8*}
%{_mandir}/man8/solis.8*
%{_mandir}/man8/tripplite.8*
%{_mandir}/man8/tripplitesu.8*
-%{_mandir}/man8/tripplite_usb.8*
-%{_mandir}/man8/usbhid-ups.8*
+%{?with_usb:%{_mandir}/man8/tripplite_usb.8*}
+%{?with_usb:%{_mandir}/man8/usbhid-ups.8*}
%{_mandir}/man8/victronups.8*
+%{?with_usb:%config(noreplace) %verify(not md5 mtime size) %{_udevrulesdir}/62-nut-usbups.rules}
+%config(noreplace) %verify(not md5 mtime size) %{_udevrulesdir}/52-nut-ipmipsu.rules
%files common
%defattr(644,root,root,755)
%doc AUTHORS MAINTAINERS NEWS README UPGRADING ChangeLog docs
%dir %{_sysconfdir}
+%attr(755,root,root) %ghost %{_libdir}/libnutclient.so.0
+%attr(755,root,root) %{_libdir}/libnutclient.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libupsclient.so.4
+%attr(755,root,root) %{_libdir}/libupsclient.so.*.*.*
%files client
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/upsc
%attr(755,root,root) %{_sbindir}/upsmon
%attr(755,root,root) %{_sbindir}/upssched
-#attr(755,root,root) %{_sbindir}/upssched-cmd
%attr(754,root,root) /etc/rc.d/init.d/upsmon
%attr(640,root,ups) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/upsmon.conf
%attr(640,root,ups) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/upssched.conf
+%attr(750,root,ups) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/upssched-cmd
%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/upsmon
+/lib/systemd/system-shutdown/nutshutdown
+%{systemdunitdir}/nut-monitor.service
+%{systemdunitdir}/upsmon.service
%{_mandir}/man5/upsmon.conf.5*
%{_mandir}/man5/upssched.conf.5*
%{_mandir}/man8/upsc.8*
%{_mandir}/man8/upsmon.8*
%{_mandir}/man8/upssched.8*
+%if %{with cgi}
%files cgi
%defattr(644,root,root,755)
+%{_datadir}/%{name}/html
%attr(755,root,root) /home/services/httpd/cgi-bin/*.cgi
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/hosts.conf
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/upsset.conf
%{_mandir}/man8/upsimage.cgi.8*
%{_mandir}/man8/upsset.cgi.8*
%{_mandir}/man8/upsstats.cgi.8*
+%endif
%files devel
%defattr(644,root,root,755)
-%{_libdir}/upsclient.o
-%{_libdir}/parseconf.o
-%{_includedir}/nut
+%attr(755,root,root) %{_libdir}/libnutclient.so
+%attr(755,root,root) %{_libdir}/libupsclient.so
+%attr(755,root,root) %{_libdir}/libnutscan.so
+%{_pkgconfigdir}/libnutclient.pc
+%{_pkgconfigdir}/libnutscan.pc
+%{_pkgconfigdir}/libupsclient.pc
+%{_includedir}/*.h
+%{_mandir}/man3/*.3*