SHA256
1
0
forked from pool/nut

Accepting request 354882 from home:scarabeus_iv:branches:hardware

- Cleanup a bit with spec-cleaner
- Install init or systemd files not both at once
- Remove patches used only on sle10:
  * nut-powersave.patch
  * nut-udev.patch

OBS-URL: https://build.opensuse.org/request/show/354882
OBS-URL: https://build.opensuse.org/package/show/hardware/nut?expand=0&rev=55
This commit is contained in:
Ismail Dönmez
2016-02-01 09:08:38 +00:00
committed by Git OBS Bridge
parent 05d38eec1f
commit 89a6130492
4 changed files with 185 additions and 303 deletions

View File

@@ -1,44 +0,0 @@
--- conf/upsmon.conf.sample
+++ conf/upsmon.conf.sample
@@ -130,6 +130,8 @@
# Example:
# NOTIFYCMD /usr/local/ups/bin/notifyme
+NOTIFYCMD /usr/lib/powersave/powersave-notify
+
# --------------------------------------------------------------------------
# POLLFREQ <n>
#
@@ -247,11 +249,11 @@
NOTIFYFLAG ONLINE SYSLOG
NOTIFYFLAG COMMOK SYSLOG
NOTIFYFLAG SHUTDOWN SYSLOG
-NOTIFYFLAG ONBATT SYSLOG+WALL
-NOTIFYFLAG LOWBATT SYSLOG+WALL
-NOTIFYFLAG FSD SYSLOG+WALL
-NOTIFYFLAG NOCOMM SYSLOG+WALL
-NOTIFYFLAG COMMBAD SYSLOG+WALL
+NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
+NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
+NOTIFYFLAG FSD SYSLOG+WALL+EXEC
+NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
+NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
# --------------------------------------------------------------------------
# RBWARNTIME - replace battery warning time in seconds
--- README.SUSE
+++ README.SUSE
@@ -127,11 +127,11 @@
you should:
- Verify, that suspend to disk works correctly with your desktop:
- sudo systemctl hibernate
+ powersave -U
(You can lose your unsaved data, if your computer does not support
suspend.)
- Change SHUTDOWNCMD in /etc/ups/upsmon.conf to:
-SHUTDOWNCMD "/usr/bin/systemctl hibernate"
+SHUTDOWNCMD "/usr/bin/powersave -U"
- Verify, that your UPS provides reasonable grace period to complete
suspend in all situations.

View File

@@ -1,16 +0,0 @@
--- scripts/udev/nut-usbups.rules.in
+++ scripts/udev/nut-usbups.rules.in
@@ -1,7 +1,11 @@
# udev rules for the NUT USB drivers
-SUBSYSTEM!="usb_device", GOTO="nut-usbups_rules_end"
ACTION!="add", GOTO="nut-usbups_rules_end"
+SUBSYSTEM=="usb_device", GOTO="nut-usbups_rules_real"
+SUBSYSTEM=="usb", GOTO="nut-usbups_rules_real"
+BUS!="usb", GOTO="nut-usbups_rules_end"
+
+LABEL="nut-usbups_rules_real"
# MGE UPS SYSTEMS - usbhid-ups
SYSFS{idVendor}=="0463", SYSFS{idProduct}=="ffff", MODE="664", GROUP="uucp"

View File

@@ -1,3 +1,12 @@
-------------------------------------------------------------------
Tue Jan 19 09:33:47 UTC 2016 - tchvatal@suse.com
- Cleanup a bit with spec-cleaner
- Install init or systemd files not both at once
- Remove patches used only on sle10:
* nut-powersave.patch
* nut-udev.patch
-------------------------------------------------------------------
Mon May 18 10:11:40 UTC 2015 - mvyskocil@opensuse.org

419
nut.spec
View File

@@ -1,7 +1,7 @@
#
# spec file for package nut
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,51 +16,36 @@
#
Name: nut
BuildRequires: apache2-devel
BuildRequires: avahi-devel
BuildRequires: dbus-1-glib-devel
BuildRequires: gcc-c++
BuildRequires: gd-devel
BuildRequires: libcppunit-devel
BuildRequires: libneon-devel
BuildRequires: libopenssl-devel
BuildRequires: libtool
BuildRequires: libusb-devel
BuildRequires: net-snmp-devel
BuildRequires: openssl-devel
BuildRequires: pkg-config
BuildRequires: tcpd-devel
# To fix end-of-line encoding:
BuildRequires: dos2unix
%if 0%{?suse_version} < 1310
# for directory ownership:
BuildRequires: pm-utils
%else
BuildRequires: udev
%endif
%if 0%{?suse_version} > 1230
%ifarch %{ix86} x86_64 ia64 alpha
BuildRequires: freeipmi-devel
%endif
%endif
%if 0%{?suse_version} > 1110
BuildRequires: powerman-devel
# For doc build:
BuildRequires: asciidoc
BuildRequires: dblatex
%endif
%define apache_serverroot %(%{_sbindir}/apxs2 -q datadir 2>/dev/null || %{_sbindir}/apxs -q PREFIX)
%define CGIPATH %{apache_serverroot}/cgi-bin
%define HTMLPATH %{apache_serverroot}/htdocs
%define MODELPATH %{_libexecdir}/ups/driver
%define STATEPATH %{_localstatedir}/lib/ups
%define CONFPATH %{_sysconfdir}/ups
%define USER upsd
%define GROUP daemon
%define LBRACE (
%define RBRACE )
%define QUOTE "
%define BACKSLASH \\
# Collect all devices listed in ups-nut-device.fdi:
%define USBHIDDRIVERS %(zcat %{SOURCE0} | tr a-z A-Z | grep -a -A1 USBHID-UPS | sed -n 's/.*ATTR{IDVENDOR}==%{QUOTE}%{BACKSLASH}%{LBRACE}[^%{QUOTE}]*%{BACKSLASH}%{RBRACE}%{QUOTE}, ATTR{IDPRODUCT}==%{QUOTE}%{BACKSLASH}%{LBRACE}[^%{QUOTE}]*%{BACKSLASH}%{RBRACE}%{QUOTE}, MODE=.*/modalias%{LBRACE}usb:v%{BACKSLASH}1p%{BACKSLASH}2d*dc*dsc*dp*ic*isc*ip*%{RBRACE}/p' | tr '%{BACKSLASH}n' ' ')
%define USBNONHIDDRIVERS %(zcat %{SOURCE0} | tr a-z A-Z | grep -a -A1 _USB | sed -n 's/.*ATTR{IDVENDOR}==%{QUOTE}%{BACKSLASH}%{LBRACE}[^%{QUOTE}]*%{BACKSLASH}%{RBRACE}%{QUOTE}, ATTR{IDPRODUCT}==%{QUOTE}%{BACKSLASH}%{LBRACE}[^%{QUOTE}]*%{BACKSLASH}%{RBRACE}%{QUOTE}, MODE=.*/modalias%{LBRACE}usb:v%{BACKSLASH}1p%{BACKSLASH}2d*dc*dsc*dp*ic*isc*ip*%{RBRACE}/p' | tr '%{BACKSLASH}n' ' ')
%if 0%{?suse_version} > 1210
BuildRequires: systemd-devel
%endif
%if 0%{?suse_version} > 1220
BuildRequires: gpg-offline
%define systemdsystemdutildir %(pkg-config --variable=systemdutildir systemd)
%define with_systemd 1
%systemd_requires
%else
%define _libexecdir %{_prefix}/lib
%define _udevrulesdir %{_sysconfdir}/udev/rules.d/
%define with_systemd 0
%endif
Name: nut
Version: 2.7.3
Release: 0
Summary: Network UPS Tools Core (Uninterruptible Power Supply Monitoring)
License: GPL-2.0+
Group: Hardware/UPS
Version: 2.7.3
Release: 0
Url: http://www.networkupstools.org/
Source: http://www.networkupstools.org/source/2.7/%{name}-%{version}.tar.gz
Source1: upsd.init
@@ -74,57 +59,52 @@ Source9: %{name}.keyring
Source10: nut-driver
Source11: nut-server
Source12: nut-monitor
Patch: nut-preconfig.patch
Patch0: nut-preconfig.patch
Patch3: nut-notifyflag.patch
Patch4: nut-powersave.patch
Patch6: nut-udev.patch
# PATCH-FIX-UPSTREAM nut-systemd-dirs.patch sbrabec@suse.cz -- Fix systemd targets.
Patch7: nut-systemd-dirs.patch
# PATCH-FIX-UPSTREAM: nut-server vs nut-drivers relation
# https://github.com/networkupstools/nut/commit/c98fab9f5dec993aa9f5e0a3e79de53ae9ecd32b
Patch8: 0001-Restore-systemd-relationship-with-nut-driver-service.patch
Provides: smartups = %version
Obsoletes: smartups < %version
Conflicts: apcupsd
BuildRoot: %{_tmppath}/%{name}-%{version}-build
PreReq: pwdutils /bin/chown %insserv_prereq pwdutils /bin/chown /bin/chmod %{_bindir}/fgrep %{_bindir}/grep %{_bindir}/sed %{_bindir}/head %{_bindir}/md5sum
Requires: %{_bindir}/fgrep
Requires: %{_bindir}/grep
Requires: %{_bindir}/pgrep
Requires: %{_bindir}/pkill
Requires: %{_bindir}/readlink
BuildRequires: apache2-devel
BuildRequires: avahi-devel
BuildRequires: dbus-1-glib-devel
BuildRequires: gcc-c++
BuildRequires: gd-devel
BuildRequires: libcppunit-devel
BuildRequires: libneon-devel
BuildRequires: libopenssl-devel
BuildRequires: libtool
BuildRequires: libusb-devel
BuildRequires: net-snmp-devel
BuildRequires: pkg-config
BuildRequires: tcpd-devel
Requires: logrotate
Requires: usbutils
Requires(post): udev
# Package provides driver for USB HID UPSes, but people can live with hal addon:
Enhances: %{USBHIDDRIVERS}
# Package provides the only avalailable driver for other USB UPSes:
Supplements: %{USBNONHIDDRIVERS}
Conflicts: apcupsd
Provides: smartups = %{version}
Obsoletes: smartups < %{version}
# for update from openSUSE <= 11.3, SLE <= 11
Provides: nut-classic = %{version}
Obsoletes: nut-classic < %{version}
Obsoletes: nut-hal < %{version}
%define apache_serverroot %(%{_sbindir}/apxs2 -q datadir 2>/dev/null || %{_sbindir}/apxs -q PREFIX)
%define CGIPATH %{apache_serverroot}/cgi-bin
%define HTMLPATH %{apache_serverroot}/htdocs
%define MODELPATH %{_prefix}/lib/ups/driver
%define STATEPATH %{_localstatedir}/lib/ups
%define CONFPATH %{_sysconfdir}/ups
%define USER upsd
%define GROUP daemon
%define LBRACE (
%define RBRACE )
%define QUOTE "
%define BACKSLASH \\
# Collect all devices listed in ups-nut-device.fdi:
%define USBHIDDRIVERS %(zcat %{S:0} | tr a-z A-Z | fgrep -a -A1 USBHID-UPS | sed -n 's/.*ATTR{IDVENDOR}==%{QUOTE}%{BACKSLASH}%{LBRACE}[^%{QUOTE}]*%{BACKSLASH}%{RBRACE}%{QUOTE}, ATTR{IDPRODUCT}==%{QUOTE}%{BACKSLASH}%{LBRACE}[^%{QUOTE}]*%{BACKSLASH}%{RBRACE}%{QUOTE}, MODE=.*/modalias%{LBRACE}usb:v%{BACKSLASH}1p%{BACKSLASH}2d*dc*dsc*dp*ic*isc*ip*%{RBRACE}/p' | tr '%{BACKSLASH}n' ' ')
%define USBNONHIDDRIVERS %(zcat %{S:0} | tr a-z A-Z | fgrep -a -A1 _USB | sed -n 's/.*ATTR{IDVENDOR}==%{QUOTE}%{BACKSLASH}%{LBRACE}[^%{QUOTE}]*%{BACKSLASH}%{RBRACE}%{QUOTE}, ATTR{IDPRODUCT}==%{QUOTE}%{BACKSLASH}%{LBRACE}[^%{QUOTE}]*%{BACKSLASH}%{RBRACE}%{QUOTE}, MODE=.*/modalias%{LBRACE}usb:v%{BACKSLASH}1p%{BACKSLASH}2d*dc*dsc*dp*ic*isc*ip*%{RBRACE}/p' | tr '%{BACKSLASH}n' ' ')
# Package provides driver for USB HID UPSes, but people can live with hal addon:
Enhances: %USBHIDDRIVERS
# Package provides the only avalailable driver for other USB UPSes:
Supplements: %USBNONHIDDRIVERS
%if %suse_version > 1210
%define systemdsystemunitdir %(pkg-config --variable=systemdsystemunitdir systemd)
%define systemdsystemdutildir %(pkg-config --variable=systemdutildir systemd)
%systemd_requires
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} > 1230
BuildRequires: powerman-devel
BuildRequires: systemd-devel
BuildRequires: udev
%ifarch %ix86 x86_64 ia64
BuildRequires: freeipmi-devel
%endif
%if %suse_version < 1310
%else
BuildRequires: pm-utils
Requires: powersave
Requires(pre): %insserv_prereq
%endif
%description
@@ -133,16 +113,11 @@ Core package of Network UPS Tools.
Network UPS Tools is a collection of programs which provide a common
interface for monitoring and administering UPS hardware.
Detailed information about supported hardware can be found in
/usr/share/doc/packages/nut.
%package drivers-net
Summary: Network UPS Tools - Extra Networking Drivers (for Network Monitoring)
Group: Hardware/UPS
Requires: %{name} = %{version}
Enhances: %{name}
# for update from openSUSE <= 10.3, SLE <= 10
Provides: nut:%{MODELPATH}/snmp-ups
%description drivers-net
Networking drivers for the Network UPS Tools. You will need them
@@ -151,9 +126,6 @@ together with nut to provide UPS networking support.
Network UPS Tools is a collection of programs which provide a common
interface for monitoring and administering UPS hardware.
Detailed information about supported hardware can be found in
/usr/share/doc/packages/nut.
%package -n libupsclient1
Summary: Network UPS Tools Library (Uninterruptible Power Supply Monitoring)
Group: System/Libraries
@@ -164,17 +136,12 @@ Shared library for the Network UPS Tools.
Network UPS Tools is a collection of programs which provide a common
interface for monitoring and administering UPS hardware.
Detailed information about supported hardware can be found in
/usr/share/doc/packages/nut.
%package cgi
Summary: Network UPS Tools Web Server Support (UPS Status Pages)
Group: Hardware/UPS
Requires: %{name} = %{version}
Enhances: %{name}
Supplements: packageand(%{name}:apache2)
# for update from openSUSE <= 10.3, SLE <= 10
Provides: nut:/srv/www/cgi-bin/upsstats.cgi
%description cgi
Web server support package for the Network UPS Tools.
@@ -184,9 +151,6 @@ Predefined URL is http://localhost/nut/index.html
Network UPS Tools is a collection of programs which provide a common
interface for monitoring and administering UPS hardware.
Detailed information about supported hardware can be found in
/usr/share/doc/packages/nut.
%package devel
Summary: Network UPS Tools (Uninterruptible Power Supply Monitoring)
Group: Development/Libraries/C and C++
@@ -197,58 +161,55 @@ Requires: openssl-devel
Network UPS Tools is a collection of programs which provide a common
interface for monitoring and administering UPS hardware.
Detailed information about supported hardware can be found in
/usr/share/doc/packages/nut.
%prep
%if 0%{?gpg_verify:1}
%gpg_verify %{S:8}
%endif
%setup -q
cp -a %{S:1} %{S:2} %{S:3} %{S:5} %{S:6} %{S:7} %{S:10} %{S:11} %{S:12} .
cp -a %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE5} %{SOURCE6} %{SOURCE7} %{SOURCE10} %{SOURCE11} %{SOURCE12} .
mv upsd-early-powerdown.init upsd-early-powerdown
%patch
%patch0
%patch3
%if %suse_version < 1110
%patch4
%endif
%if %suse_version < 1030
%patch6 -R
%endif
sed -i "s/@UPSD_USER@/%{USER}/g" upsd.init
%if %suse_version < 1030
sed -i 's:/usr/lib/pm-utils/functions:/etc/pm/functions:' nut.sleep
%endif
%patch7 -p1
%patch8 -p1
sed -i s:/usr/local/ups/bin:/bin: conf/upssched.conf.sample.in
sed -i "s/@UPSD_USER@/%{USER}/g" upsd.init
sed -i s:%{_prefix}/local/ups/bin:/bin: conf/upssched.conf.sample.in
%build
autoreconf -f -i
%configure --disable-static --with-pic --libexecdir=%_prefix/lib\
--sysconfdir=%{CONFPATH}\
--datadir=%{_datadir}/nut\
--with-all\
--with-dev\
autoreconf -fvi
# documentation fails to build -> disable
%configure \
--disable-static \
--with-pic \
--sysconfdir=%{CONFPATH} \
--datadir=%{_datadir}/nut \
--with-all \
--without-doc \
--with-ssl \
--with-openssl \
--without-nss \
--with-wrap \
%if 0%{?suse_version} <= 1230
--without-ipmi\
--without-ipmi \
%endif
%ifnarch %{ix86} x86_64 ia64 alpha
--without-ipmi\
%ifnarch %ix86 x86_64 ia64
--without-ipmi \
%endif
%if %suse_version <= 1110
--without-powerman\
%if 0%{?suse_version} <= 1110
--without-powerman \
%endif
--with-htmlpath=%{HTMLPATH}\
--with-cgipath=%{CGIPATH}\
--with-statepath=%{STATEPATH}\
--with-drvpath=%{MODELPATH}\
--with-user=%{USER}\
--with-htmlpath=%{HTMLPATH} \
--with-cgipath=%{CGIPATH} \
--with-statepath=%{STATEPATH} \
--with-drvpath=%{MODELPATH} \
--with-user=%{USER} \
--with-group=%{GROUP} \
--with-udev-dir=/etc/udev \
--enable-option-checking=fatal
%if 0%{with_systemd}
--with-udev-dir=%{_libexecdir}/udev \
%else
--with-udev-dir=%{_sysconfdir}/udev \
%endif
--enable-option-checking=fatal
make %{_smp_mflags}
make %{?_smp_mflags}
PORT=$(sed -n 's/#define PORT //p' config.log)
if test "$PORT" = 3493 ; then
PORT=nut
@@ -256,68 +217,62 @@ fi
sed s/@PORT@/$PORT/ <nut.firewall.in >nut.firewall
%install
make DESTDIR=$RPM_BUILD_ROOT install
mkdir -p $RPM_BUILD_ROOT%{STATEPATH}
# SuSE rc
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
install -m 755 upsd.init $RPM_BUILD_ROOT%{_sysconfdir}/init.d/upsd
ln -sf ../..%{_sysconfdir}/init.d/upsd $RPM_BUILD_ROOT%{_sbindir}/rcupsd
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
install -m 644 scripts/logrotate/nutlogd $RPM_BUILD_ROOT/etc/logrotate.d/
mkdir -p $RPM_BUILD_ROOT%{STATEPATH}
%if %suse_version < 1110
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/dbus-1/system.d
install -m 644 packaging/opensuse/upsd.dbus-1 $RPM_BUILD_ROOT%{_sysconfdir}/dbus-1/system.d/upsd.conf
%endif
rename .sample "" $RPM_BUILD_ROOT%{_sysconfdir}/ups/*.sample
%if %suse_version >= 1030
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services
cp nut.firewall $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/nut
%endif
%if 0%{?suse_version} < 1310
%if %suse_version >= 1030
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/pm-utils/sleep.d
install nut.sleep $RPM_BUILD_ROOT%{_prefix}/lib/pm-utils/sleep.d/99nut
make DESTDIR=%{buildroot} install %{?_smp_mflags}
find %{buildroot} -type f -name "*.la" -delete -print
mkdir -p %{buildroot}%{STATEPATH}
# initscript
mkdir -p %{buildroot}%{_sbindir}
%if 0%{with_systemd}
ln -s service %{buildroot}%{_sbindir}/rcnut-driver
ln -s service %{buildroot}%{_sbindir}/rcnut-server
ln -s service %{buildroot}%{_sbindir}/rcnut-monitor
%else
install -d $RPM_BUILD_ROOT%{_sysconfdir}/pm/sleep.d
install nut.sleep $RPM_BUILD_ROOT%{_sysconfdir}/pm/sleep.d/99nut
mkdir -p %{buildroot}%{_sysconfdir}/init.d
install -m 755 upsd.init %{buildroot}%{_sysconfdir}/init.d/upsd
ln -sf ../..%{_sysconfdir}/init.d/upsd %{buildroot}%{_sbindir}/rcupsd
install nut-driver nut-server nut-monitor %{buildroot}%{_initddir}/
%endif
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
install -m 644 scripts/logrotate/nutlogd %{buildroot}%{_sysconfdir}/logrotate.d/nut
mkdir -p %{buildroot}%{STATEPATH}
rename .sample "" %{buildroot}%{_sysconfdir}/ups/*.sample
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services
cp nut.firewall %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/nut
%if 0%{with_systemd}
install -d %{buildroot}%{_libexecdir}/systemd/system-sleep
install nut.system-sleep %{buildroot}%{_libexecdir}/systemd/system-sleep/%{name}.sh
%else
install -d $RPM_BUILD_ROOT/usr/lib/systemd/system-sleep
install nut.system-sleep $RPM_BUILD_ROOT/usr/lib/systemd/system-sleep/%{name}.sh
mkdir -p %{buildroot}%{_libexecdir}/pm-utils/sleep.d
install nut.sleep %{buildroot}%{_libexecdir}/pm-utils/sleep.d/99nut
%endif
mkdir $RPM_BUILD_ROOT/bin
mv $RPM_BUILD_ROOT%{_bindir}/upssched-cmd $RPM_BUILD_ROOT/bin/upssched-cmd
# Rename web pages to not conflict with apache2-example-pages or user home page:
mkdir $RPM_BUILD_ROOT%{HTMLPATH}/nut $RPM_BUILD_ROOT%{CGIPATH}/nut
mv $RPM_BUILD_ROOT%{HTMLPATH}/*.{html,png} $RPM_BUILD_ROOT%{HTMLPATH}/nut/
mv $RPM_BUILD_ROOT%{CGIPATH}/*.cgi $RPM_BUILD_ROOT%{CGIPATH}/nut
%{__rm} -f %{buildroot}%{_libdir}/*.la
mkdir -p $RPM_BUILD_ROOT/etc/bash_completion.d
install -m0644 scripts/misc/nut.bash_completion $RPM_BUILD_ROOT/etc/bash_completion.d/
# It would be nice to use -m0644, but it will fail on brp-55-boot-scripts
install nut-driver nut-server nut-monitor $RPM_BUILD_ROOT/etc/init.d/
mkdir %{buildroot}%{HTMLPATH}/nut %{buildroot}%{CGIPATH}/nut
mv %{buildroot}%{HTMLPATH}/*.{html,png} %{buildroot}%{HTMLPATH}/nut/
mv %{buildroot}%{CGIPATH}/*.cgi %{buildroot}%{CGIPATH}/nut
mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d
install -m0644 scripts/misc/nut.bash_completion %{buildroot}%{_sysconfdir}/bash_completion.d/nut
%pre
usr/sbin/useradd -r -g %{GROUP} -s /bin/false \
-c "UPS daemon" -d /sbin %{USER} 2>/dev/null || :
%if %suse_version > 1210
useradd -r -g %{GROUP} -s /bin/false -c "UPS daemon" -d /sbin %{USER} 2>/dev/null || :
%if 0%{with_systemd}
%service_add_pre nut-driver.service nut-server.service nut-monitor.service
%endif
%post
# Be sure that all files are owned by a dedicated user.
bin/chown -R %{USER}:%{GROUP} %{STATEPATH}
%{fillup_and_insserv -f -n upsd}
chown -R %{USER}:%{GROUP} %{STATEPATH}
# Generate initial passwords.
if usr/bin/fgrep -q "password = @UPSD_INITIAL_MASTER_PASSWORD@" %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.users; then
UPSD_INITIAL_MASTER_PASSWORD=$(usr/bin/head -c 20 /dev/urandom | usr/bin/md5sum | usr/bin/head -c 10)
usr/bin/sed -i s/@UPSD_INITIAL_MASTER_PASSWORD@/$UPSD_INITIAL_MASTER_PASSWORD/ %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.users
if grep -q "password = @UPSD_INITIAL_MASTER_PASSWORD@" %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.users; then
UPSD_INITIAL_MASTER_PASSWORD=$(head -c 20 /dev/urandom | md5sum | head -c 10)
sed -i s/@UPSD_INITIAL_MASTER_PASSWORD@/$UPSD_INITIAL_MASTER_PASSWORD/ %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.users
fi
if usr/bin/fgrep -q "password = @UPSD_INITIAL_SLAVE_PASSWORD@" %{CONFPATH}/upsd.users ; then
UPSD_INITIAL_SLAVE_PASSWORD=$(usr/bin/head -c 20 /dev/urandom | usr/bin/md5sum | usr/bin/head -c 10)
usr/bin/sed -i s/@UPSD_INITIAL_SLAVE_PASSWORD@/$UPSD_INITIAL_SLAVE_PASSWORD/ %{CONFPATH}/upsd.users
if grep -q "password = @UPSD_INITIAL_SLAVE_PASSWORD@" %{CONFPATH}/upsd.users ; then
UPSD_INITIAL_SLAVE_PASSWORD=$(head -c 20 /dev/urandom | md5sum | head -c 10)
sed -i s/@UPSD_INITIAL_SLAVE_PASSWORD@/$UPSD_INITIAL_SLAVE_PASSWORD/ %{CONFPATH}/upsd.users
fi
# Be sure that all files are owned by a dedicated user.
bin/chown %{USER}:root %{CONFPATH}/upsd.conf %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.users
@@ -325,65 +280,58 @@ bin/chmod 600 %{CONFPATH}/upsd.conf %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.use
# Install or remove HALT_POWERDOWN_INSERT
# It was last installed in 1310, but it is obsolete since dropping sysvinit support.
%if 0%{?suse_version} < 1310
if usr/bin/grep -q '^HALT_POWERDOWN_INSERT="\(%{_sysconfdir}/init\.d/upsd try-powerdown\|\)"' etc/sysconfig/shutdown ; then
usr/bin/sed -i 's:^\(HALT_POWERDOWN_INSERT="\).*"[[:space:]]*:\1%{_sysconfdir}/init.d/upsd try-powerdown":' etc/sysconfig/shutdown
if grep -q '^HALT_POWERDOWN_INSERT="\(%{_sysconfdir}/init\.d/upsd try-powerdown\|\)"' etc/sysconfig/shutdown ; then
sed -i 's:^\(HALT_POWERDOWN_INSERT="\).*"[[:space:]]*:\1%{_sysconfdir}/init.d/upsd try-powerdown":' etc/sysconfig/shutdown
else
# User configured Suspend-to-disc. Keep it unchanged and be silent.
if ! usr/bin/grep -q '^HALT_POWERDOWN_INSERT="/usr/bin/powersave -U' etc/sysconfig/shutdown ; then
if ! grep -q '^HALT_POWERDOWN_INSERT="%{_bindir}/powersave -U' etc/sysconfig/shutdown ; then
echo >&2 "nut: WARNING: Unknown value of HALT_POWERDOWN_INSERT in %{_sysconfdir}/sysconfig/shutdown."
echo >&2 " Keeping unchanged. Should be:"
echo >&2 "HALT_POWERDOWN_INSERT=\"%{_sysconfdir}/init.d/upsd try-powerdown\""
echo >&2 "or"
echo >&2 "HALT_POWERDOWN_INSERT=\"/usr/bin/powersave -U\""
echo >&2 "HALT_POWERDOWN_INSERT=\"%{_bindir}/powersave -U\""
fi
fi
%else
# Unconditional removal of HALT_POWERDOWN_INSERT in new SUSE versions. (last installed in 1310)
if usr/bin/grep -q '^HALT_POWERDOWN_INSERT="\(%{_sysconfdir}/init\.d/upsd try-powerdown\|/usr/bin/powersave -U\)"' etc/sysconfig/shutdown ; then
usr/bin/sed -i 's:^\(HALT_POWERDOWN_INSERT="\)\(%{_sysconfdir}/init\.d/upsd try-powerdown\|/usr/bin/powersave -U\)":\1":' etc/sysconfig/shutdown
fi
%endif
# Migrate Suspend to Disc to the new convention (bnc#449861 and later bnc#871406):
# It was never on by default, but documentation up to 11.0 recommends
# "shutdown -z +0" for suspend to disc. It was discontinued before 11.0.
# Documentation since 11.0 up to 13.1 recommends /usr/bin/powersave -U.
# Documentation since 11.0 up to 13.1 recommends /powersave -U.
# pm-utils (and powersave) were obsoleted after 13.1 in favor of systemd.
%if 0%{?suse_version} >= 1310
if fgrep "shutdown -z +0" /etc/ups/upsmon.conf ; then
sed -i 's:/sbin/shutdown -z +0:/usr/bin/systemctl hibernate:;s:shutdown -z +0:/usr/bin/systemctl hibernate:' /etc/ups/upsmon.conf
%if 0%{with_systemd}
if grep "shutdown -z +0" %{_sysconfdir}/ups/upsmon.conf ; then
sed -i 's:/sbin/shutdown -z +0:%{_bindir}/systemctl hibernate:;s:shutdown -z +0:%{_bindir}/systemctl hibernate:' %{_sysconfdir}/ups/upsmon.conf
fi
if fgrep "powersave -U" /etc/ups/upsmon.conf ; then
sed -i 's:/usr/bin/powersave -U:/usr/bin/systemctl hibernate:;s:powersave -U:/usr/bin/systemctl hibernate:' /etc/ups/upsmon.conf
if grep "powersave -U" %{_sysconfdir}/ups/upsmon.conf ; then
sed -i 's:%{_bindir}/powersave -U:%{_bindir}/systemctl hibernate:;s:powersave -U:%{_bindir}/systemctl hibernate:' %{_sysconfdir}/ups/upsmon.conf
fi
%else
if fgrep "shutdown -z +0" /etc/ups/upsmon.conf ; then
sed -i 's:/sbin/shutdown -z +0:/usr/bin/powersave -U:;s:shutdown -z +0:/usr/bin/powersave -U:' /etc/ups/upsmon.conf
if grep "shutdown -z +0" %{_sysconfdir}/ups/upsmon.conf ; then
sed -i 's:/sbin/shutdown -z +0:%{_bindir}/powersave -U:;s:shutdown -z +0:%{_bindir}/powersave -U:' %{_sysconfdir}/ups/upsmon.conf
fi
%endif
# Silently remove %{_sysconfdir}/sysconfig/smartups. File is now obsolete and
# values are copied to not replaced config files.
# %{_sysconfdir}/sysconfig/smartups was last present in SuSE Linux 10.0
rm -f %{_sysconfdir}/sysconfig/smartups
# And finally trigger udev to set permissions according to newly installed rules files.
/sbin/udevadm trigger --subsystem-match=usb --property-match=DEVTYPE=usb_device
%if %suse_version > 1210
%if 0%{with_systemd}
%service_add_post nut-driver.service nut-server.service nut-monitor.service
%else
%{fillup_and_insserv -f -n upsd}
%endif
%preun
%{stop_on_removal upsd}
%if %suse_version > 1210
%if 0%{with_systemd}
%service_del_preun nut-driver.service nut-server.service nut-monitor.service
%else
%{stop_on_removal upsd}
%endif
%postun
%{restart_on_update upsd}
# Remove HALT_POWERDOWN_INSERT
# It was last installed in 1310, but it is obsolete since dropping sysvinit support.
%if 0%{?suse_version} < 1310
if test $1 -eq 0 -a ! -f %{_sysconfdir}/init.d/upsd ; then
if usr/bin/grep -q '^HALT_POWERDOWN_INSERT="\(%{_sysconfdir}/init\.d/upsd try-powerdown\|/usr/bin/powersave -U\)"' etc/sysconfig/shutdown ; then
usr/bin/sed -i 's:^\(HALT_POWERDOWN_INSERT="\)\(%{_sysconfdir}/init\.d/upsd try-powerdown\|/usr/bin/powersave -U\)":\1":' etc/sysconfig/shutdown
if grep -q '^HALT_POWERDOWN_INSERT="\(%{_sysconfdir}/init\.d/upsd try-powerdown\|%{_bindir}/powersave -U\)"' etc/sysconfig/shutdown ; then
sed -i 's:^\(HALT_POWERDOWN_INSERT="\)\(%{_sysconfdir}/init\.d/upsd try-powerdown\|%{_bindir}/powersave -U\)":\1":' etc/sysconfig/shutdown
else
echo >&2 "nut: WARNING: Unknown value of HALT_POWERDOWN_INSERT in %{_sysconfdir}/sysconfig/shutdown."
echo >&2 " Keeping unchanged. Should be:"
@@ -394,51 +342,32 @@ if test $1 -eq 0 -a ! -f %{_sysconfdir}/init.d/upsd ; then
fi
fi
%endif
%insserv_cleanup
%if %suse_version > 1210
%if 0%{with_systemd}
%service_del_postun nut-driver.service nut-server.service nut-monitor.service
%else
%{restart_on_update upsd}
%insserv_cleanup
%endif
%post -n libupsclient1 -p /sbin/ldconfig
%postun -n libupsclient1 -p /sbin/ldconfig
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog MAINTAINERS NEWS README README.SUSE UPGRADING upsd-early-powerdown docs/*.txt docs/cables
/bin/*
/etc/bash_completion.d/*
/etc/logrotate.d/*
%{_sysconfdir}/bash_completion.d/*
%config %{_sysconfdir}/logrotate.d/*
%{_bindir}/*
%{_datadir}/nut
%doc %{_mandir}/man5/*.*
%doc %{_mandir}/man8/*.*
%exclude %doc %{_mandir}/man8/netxml-ups*.*
%exclude %doc %{_mandir}/man8/snmp-ups*.*
%dir %{_prefix}/lib/ups
%if 0%{?suse_version} < 1310
%if %suse_version >= 1030
%{_prefix}/lib/pm-utils/sleep.d/99nut
%else
%{_sysconfdir}/pm/sleep.d/99nut
%endif
%else
/usr/lib/systemd/system-sleep/%{name}.sh
%endif
%{_mandir}/man5/*.*
%{_mandir}/man8/*.*
%exclude %{_mandir}/man8/netxml-ups*.*
%exclude %{_mandir}/man8/snmp-ups*.*
%dir %{_libexecdir}/ups
%{_sbindir}/*
%if %suse_version < 1110
%{_sysconfdir}/dbus-1/system.d/upsd.conf
%endif
%if %suse_version >= 1030
%config(noreplace) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/nut
%endif
%{_sysconfdir}/init.d/*
%dir %{_sysconfdir}/udev
%dir %{_sysconfdir}/udev/rules.d
%config(noreplace) %{_sysconfdir}/udev/rules.d/*.rules
%{_udevrulesdir}/*.rules
%config(noreplace) %{CONFPATH}/hosts.conf
%config(noreplace) %attr(600,%{USER},root) %{CONFPATH}/upsd.conf
%config(noreplace) %attr(600,%{USER},root) %{CONFPATH}/upsd.users
@@ -453,17 +382,21 @@ rm -rf $RPM_BUILD_ROOT
%exclude %{MODELPATH}/snmp-ups
%exclude %{MODELPATH}/netxml-ups
%attr(700,%{USER},%{GROUP}) %{STATEPATH}
%if %suse_version > 1210
%{systemdsystemunitdir}/*.service
%if 0%{with_systemd}
%{_unitdir}/*.service
%{systemdsystemdutildir}/system-shutdown/*
%{_libexecdir}/systemd/system-sleep/%{name}.sh
%else
%{_libexecdir}/pm-utils/sleep.d/99nut
%{_sysconfdir}/init.d/*
%endif
%files drivers-net
%defattr(-,root,root)
%{MODELPATH}/snmp-ups
%{MODELPATH}/netxml-ups
%doc %{_mandir}/man8/netxml-ups*.*
%doc %{_mandir}/man8/snmp-ups*.*
%{_mandir}/man8/netxml-ups*.*
%{_mandir}/man8/snmp-ups*.*
%files -n libupsclient1
%defattr(-,root,root)
@@ -481,6 +414,6 @@ rm -rf $RPM_BUILD_ROOT
%{_includedir}/*.h
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc
%doc %{_mandir}/man3/*.*
%{_mandir}/man3/*.*
%changelog