SHA256
1
0
forked from pool/nut

Accepting request 228899 from home:sbrabec:branches:hardware

- Replace powersave support by systemd (bnc#871406).

- explicitly require udev to fix buildenvironment issues 

- Replace pm-utils support by systemd (FATE#316824).

OBS-URL: https://build.opensuse.org/request/show/228899
OBS-URL: https://build.opensuse.org/package/show/hardware/nut?expand=0&rev=45
This commit is contained in:
2014-04-03 14:56:12 +00:00
committed by Git OBS Bridge
parent e1b63bbeb5
commit 8bc42be341
5 changed files with 96 additions and 10 deletions

View File

@@ -127,12 +127,12 @@ If you want to configure nut to do suspend to disk instead of shutdown
you should:
- Verify, that suspend to disk works correctly with your desktop:
powersave -U
sudo systemctl hibernate
(You can lose your unsaved data, if your computer does not support
suspend.)
- Change SHUTDOWNCMD in /etc/ups/upsmon.conf to:
SHUTDOWNCMD "/usr/bin/powersave -U"
- Verify, that your UPS provides reasonable grant period to complete
SHUTDOWNCMD "/usr/bin/systemctl hibernate"
- Verify, that your UPS provides reasonable grace period to complete
suspend in all situations.

View File

@@ -26,3 +26,19 @@
# --------------------------------------------------------------------------
# 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,3 +1,18 @@
-------------------------------------------------------------------
Thu Apr 3 16:19:56 CEST 2014 - sbrabec@suse.cz
- Replace powersave support by systemd (bnc#871406).
-------------------------------------------------------------------
Thu Mar 27 11:20:30 CET 2014 - ro@suse.de
- explicitly require udev to fix buildenvironment issues
-------------------------------------------------------------------
Fri Feb 14 20:15:04 CET 2014 - sbrabec@suse.cz
- Replace pm-utils support by systemd (FATE#316824).
-------------------------------------------------------------------
Tue Nov 26 20:48:34 CET 2013 - sbrabec@suse.cz

View File

@@ -31,10 +31,14 @@ BuildRequires: net-snmp-devel
BuildRequires: openssl-devel
BuildRequires: pkg-config
BuildRequires: tcpd-devel
# for directory ownership:
BuildRequires: pm-utils
# 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
@@ -63,6 +67,7 @@ Source1: upsd.init
Source2: README.SUSE
Source3: upsd-early-powerdown.init
Source5: nut.firewall.in
Source6: nut.system-sleep
Source7: nut.sleep
Source8: http://www.networkupstools.org/source/2.7/%{name}-%{version}.tar.gz.sig
Source9: %{name}.keyring
@@ -87,7 +92,6 @@ Requires: %{_bindir}/grep
Requires: %{_bindir}/pgrep
Requires: %{_bindir}/pkill
Requires: %{_bindir}/readlink
Requires: powersave
Requires: usbutils
Requires(post): udev
# for update from openSUSE <= 11.3, SLE <= 11
@@ -118,6 +122,9 @@ Supplements: %USBNONHIDDRIVERS
%define systemdsystemdutildir %(pkg-config --variable=systemdutildir systemd)
%systemd_requires
%endif
%if %suse_version < 1310
Requires: powersave
%endif
%description
Core package of Network UPS Tools.
@@ -197,7 +204,7 @@ Detailed information about supported hardware can be found in
%gpg_verify %{S:8}
%endif
%setup -q
cp -a %{S:1} %{S:2} %{S:3} %{S:5} %{S:7} %{S:10} %{S:11} %{S:12} .
cp -a %{S:1} %{S:2} %{S:3} %{S:5} %{S:6} %{S:7} %{S:10} %{S:11} %{S:12} .
mv upsd-early-powerdown.init upsd-early-powerdown
%patch
%patch1 -p1
@@ -269,13 +276,18 @@ rename .sample "" $RPM_BUILD_ROOT%{_sysconfdir}/ups/*.sample
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
%else
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/pm/sleep.d
install -d $RPM_BUILD_ROOT%{_sysconfdir}/pm/sleep.d
install nut.sleep $RPM_BUILD_ROOT%{_sysconfdir}/pm/sleep.d/99nut
%endif
%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
%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:
@@ -311,7 +323,9 @@ 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
bin/chmod 600 %{CONFPATH}/upsd.conf %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.users
# Install HALT_POWERDOWN_INSERT
# 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
else
@@ -324,12 +338,29 @@ else
echo >&2 "HALT_POWERDOWN_INSERT=\"/usr/bin/powersave -U\""
fi
fi
# Migrate Suspend to Disc to the new convention (bnc#449861):
%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.
# 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
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
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
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
@@ -349,6 +380,8 @@ rm -f %{_sysconfdir}/sysconfig/smartups
%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
@@ -361,6 +394,7 @@ if test $1 -eq 0 -a ! -f %{_sysconfdir}/init.d/upsd ; then
echo >&2 "nut: WARNING: You may want to remove your %{_sysconfdir}/init.d/upsd-early-powerdown."
fi
fi
%endif
%insserv_cleanup
%if %suse_version > 1210
%service_del_postun nut-driver.service nut-server.service nut-monitor.service
@@ -386,11 +420,15 @@ rm -rf $RPM_BUILD_ROOT
%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
%{_sbindir}/*
%if %suse_version < 1110
%{_sysconfdir}/dbus-1/system.d/upsd.conf

17
nut.system-sleep Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Always stop nut before sleep, but do not initiate powerdown for hybrid-sleep.
if [ "$1" = pre ] && ( [ "$2" = hibernate ] || [ "$2" = hybrid-sleep ] ) ; then
/sbin/service upsd.service stop
fi
if [ "$1" = pre ] && [ "$2" = hibernate ] ; then
# FIXME: All hibernate quirks are called in parallel. To be on a safest side, we should initiate powerdown grace period when they terminate.
sleep 5
if test -n "$POWERDOWNFLAG" -a -f "$POWERDOWNFLAG" ; then
export UPSD_POWERDOWN_CONDITION=1
/etc/init.d/upsd try-powerdown
fi
fi
if [ "$1" = post ] && ( [ "$2" = hibernate ] || [ "$2" = hybrid-sleep ] ) ; then
/sbin/service upsd.service start
fi