From 231a418c56c0dba975704a6c735f626b1363e3b9 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Apr 15 2008 12:27:47 +0000 Subject: - remove double %dir %{_libdir}/pm-utils - update pm-utils-99hd-apm-restore to work with current pm-utils release Red Hat Bugzilla: #442294 - move config file for hd apm restore away from config.d, which is only used for pm-utils internal config anymore - own /var/run/pm-utils/ and create storage/locks subdirs (may be needed for selinux) - make sure an empty logfile is created after install (touch -a ...) - sort %files - make Source0: an URL - remove Conflicts: bluez utils, all supported Fedora releases ship already a newer version - remove unused BR: hal-devel, dbus-devel, pkgconfig, docbook-utils --- diff --git a/pm-utils-1.1.0-log_order.patch b/pm-utils-1.1.0-log_order.patch new file mode 100644 index 0000000..b9c7f3e --- /dev/null +++ b/pm-utils-1.1.0-log_order.patch @@ -0,0 +1,41 @@ +diff -up pm-utils-1.1.0/src/pm-action.in.log_order pm-utils-1.1.0/src/pm-action.in +diff -up pm-utils-1.1.0/src/pm-action.in.log_order pm-utils-1.1.0/src/pm-action.in +--- pm-utils-1.1.0/src/pm-action.in.log_order 2008-03-31 12:02:35.000000000 +0200 ++++ pm-utils-1.1.0/src/pm-action.in 2008-04-14 22:10:05.000000000 +0200 +@@ -72,15 +72,24 @@ load_hook_parameters + # Make sure we are not inhibited before we start. + rm -f "${INHIBIT}" + +-# run the sleep hooks +-log "$(date): Running hooks for $ACTION." +-run_hooks sleep "$ACTION" +-log "$(date): ${METHOD}ing" +-# Sleep only if we know how and if a hook did not inhibit us. +-command_exists "do_$METHOD" && [ ! -e "$INHIBIT" ] && { sync; "do_$METHOD"; } +-log "$(date): Awake." +-log "$(date): Running hooks for $REVERSE" +-# run the sleep hooks in reverse with the wakeup action +-run_hooks sleep "$REVERSE" reverse +-log "$(date): Finished." +- ++if command_exists "do_$METHOD" ; then ++ # run the sleep hooks ++ log "$(date): Running hooks for $ACTION." ++ run_hooks sleep "$ACTION" ++ # Sleep only if we know how and if a hook did not inhibit us. ++ if [ ! -e "$INHIBIT" ]; then ++ log "$(date): performing ${METHOD}" ++ sync ++ "do_$METHOD" ++ log "$(date): Awake." ++ else ++ log "$(date): Inhibit found, will not perform ${METHOD}" ++ fi ++ log "$(date): Running hooks for $REVERSE" ++ # run the sleep hooks in reverse with the wakeup action ++ run_hooks sleep "$REVERSE" reverse ++ log "$(date): Finished." ++else ++ log "$(date): Missing module to perform $METHOD - abort." ++ exit 1 ++fi diff --git a/pm-utils-99hd-apm-restore b/pm-utils-99hd-apm-restore index 1ebc2b6..be4a49f 100755 --- a/pm-utils-99hd-apm-restore +++ b/pm-utils-99hd-apm-restore @@ -14,44 +14,55 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin -HD_APM_STATEFILE=/var/run/pm-hd-apm -HD_APM_DEVICES=sda +source "${PM_FUNCTIONS}" +source /etc/pm-utils-hd-apm-restore.conf -source /usr/lib/pm-utils/functions +HD_APM_DEVICES="" +for udi in $(hal-find-by-capability --capability storage) +do + drive_type=$(hal-get-property --udi "${udi}" --key storage.drive_type) + if [ "${drive_type}" == "disk" ] + then + HD_APM_DEVICES+="$(hal-get-property --udi "${udi}" --key block.device | sed 's,^/dev/,,') " + + fi +done case "$1" in hibernate|suspend) - rm -f ${HD_APM_STATEFILE} - touch ${HD_APM_STATEFILE} for DEVICE in ${HD_APM_DEVICES} do - HD_APM_FEATURE=$(hdparm -I /dev/sda | grep "Advanced Power Management feature set") + HD_APM_FEATURE=$(hdparm -I "/dev/${DEVICE}" | grep "Advanced Power Management feature set") if [[ "${HD_APM_FEATURE}" != "" ]] then - if (echo "${HD_APM_FEATURE}" | grep "*") + if (echo "${HD_APM_FEATURE}" | grep -q "*" ) then - HD_APM_LEVEL=$(hdparm -I /dev/${DEVICE} | grep "Advanced power management level" | cut -d" " -f 5) + HD_APM_LEVEL=$(hdparm -I "/dev/${DEVICE}" | grep "Advanced power management level" | cut -d" " -f 5) else HD_APM_LEVEL=255 fi if [[ "${HD_APM_LEVEL}" != "unknown" ]] then - echo "HD_APM_LEVEL_${DEVICE}=${HD_APM_LEVEL}" >> ${HD_APM_STATEFILE} + echo "saving level ${HD_APM_LEVEL} for device ${DEVICE}" + savestate "${DEVICE}" "${HD_APM_LEVEL}" + else + echo "Advanced Power Management value of device ${DEVICE} unknown" fi + else + echo "Advanced Power Management not supported by device ${DEVICE}." fi done ;; thaw|resume) - source ${HD_APM_STATEFILE} for DEVICE in ${HD_APM_DEVICES} do - eval HD_APM_LEVEL=\${HD_APM_LEVEL_${DEVICE}} + HD_APM_LEVEL=$(restorestate "${DEVICE}") if [[ "${HD_APM_LEVEL}" != "" ]] then - hdparm -B ${HD_APM_LEVEL} /dev/${DEVICE} + echo "restoring level ${HD_APM_LEVEL} for device ${DEVICE}" + hdparm -B "${HD_APM_LEVEL}" "/dev/${DEVICE}" fi done - rm -f ${HD_APM_STATEFILE} ;; *) ;; diff --git a/pm-utils-hd-apm-restore.conf b/pm-utils-hd-apm-restore.conf index 953946d..4b68f33 100644 --- a/pm-utils-hd-apm-restore.conf +++ b/pm-utils-hd-apm-restore.conf @@ -6,4 +6,7 @@ # Use this to overwrite a value for a device in case hdparm reports # "unknown value" for the apm level. This is ignored when hdparm # returns an other value. -#HD_APM_LEVEL_sda=192 +#savestate sda 192 +#savestate sdb 192 +#savestate sdc 192 +#savestate sdd 192 diff --git a/pm-utils.spec b/pm-utils.spec index b3609a2..7a3b8ad 100644 --- a/pm-utils.spec +++ b/pm-utils.spec @@ -2,7 +2,7 @@ Name: pm-utils Summary: Power management utilities and scripts for Fedora License: GPLv2 Version: 1.1.0 -Release: 4%{?dist} +Release: 5%{?dist} Group: System Environment/Base URL: http://pm-utils.freedesktop.org Requires: usermode kbd pciutils >= 2.2.1 @@ -14,8 +14,7 @@ Requires: hal %ifarch %{ix86} x86_64 Requires: vbetool %endif -Conflicts: bluez-utils < 2.25-6 -Source0: pm-utils-%{version}.tar.gz +Source0: http://pm-utils.freedesktop.org/releases/pm-utils-%{version}.tar.gz Source1: pm-suspend.pam Source2: pm-hibernate.pam Source3: pm-powersave.pam @@ -31,10 +30,9 @@ Source21: pm-utils-99hd-apm-restore Source22: pm-utils-hd-apm-restore.conf Source23: pm-utils-bugreport-info.sh +Patch0: pm-utils-1.1.0-log_order.patch + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: hal-devel pkgconfig -BuildRequires: dbus-devel >= 0.90 -BuildRequires: docbook-utils %description @@ -54,6 +52,8 @@ when building programs that use %{name}. %prep %setup -q +%patch0 -p1 -b .log_order + %build %configure @@ -84,9 +84,10 @@ done popd install -D -m 0600 /dev/null $RPM_BUILD_ROOT%{_localstatedir}/log/pm-suspend.log +mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/pm-utils/{locks,storage} install -D -m 0755 %{SOURCE21} $RPM_BUILD_ROOT%{_libdir}/pm-utils/sleep.d/99hd-apm-restore.hook -install -D -m 0644 %{SOURCE22} $RPM_BUILD_ROOT%{_sysconfdir}/pm/config.d/hd-apm-restore.conf +install -D -m 0644 %{SOURCE22} $RPM_BUILD_ROOT%{_sysconfdir}/pm-utils-hd-apm-restore.conf install -D -m 0755 %{SOURCE23} $RPM_BUILD_ROOT%{_bindir}/pm-utils-bugreport-info.sh @@ -105,6 +106,7 @@ fi if [ -f %{_sysconfdir}/pm/config.rpmsave ]; then mv %{_sysconfdir}/pm/config.rpmsave %{_sysconfdir}/pm/config.d/02oldconfig.conf fi +touch -a %{_localstatedir}/log/pm-suspend.log if [ -f %{_localstatedir}/log/pm-suspend.log ] ; then chmod 0600 %{_localstatedir}/log/pm-suspend.log [ -x /sbin/restorecon ] && restorecon %{_localstatedir}/log/pm-suspend.log > /dev/null 2>&1 @@ -114,7 +116,7 @@ fi %files %defattr(-,root,root,-) %doc README COPYING AUTHORS ChangeLog -%config(noreplace) %{_sysconfdir}/pm/config.d/hd-apm-restore.conf +%config(noreplace) %{_sysconfdir}/pm-utils-hd-apm-restore.conf %{_sysconfdir}/pm/ %{_sysconfdir}/security/console.apps/pm-hibernate %{_sysconfdir}/security/console.apps/pm-powersave @@ -128,8 +130,10 @@ fi %{_libdir}/pm-utils/bin/ %{_libdir}/pm-utils/defaults %{_libdir}/pm-utils/functions +%{_libdir}/pm-utils/pm-functions %{_libdir}/pm-utils/power.d/ %{_libdir}/pm-utils/sleep.d/ +%{_libdir}/pm-utils/module.d %{_bindir}/on_ac_power %{_bindir}/pm-hibernate %{_bindir}/pm-is-supported @@ -143,10 +147,7 @@ fi %{_sbindir}/pm-suspend-hybrid %{_mandir}/man1/on_ac_power.1* %{_mandir}/man1/pm-pmu.1* -%dir %{_libdir}/pm-utils -%{_libdir}/pm-utils/pm-functions -%dir %{_libdir}/pm-utils/module.d -%{_libdir}/pm-utils/module.d/* +%{_localstatedir}/run/pm-utils/ %ghost %verify(not md5 size mtime) %{_localstatedir}/log/pm-suspend.log @@ -155,6 +156,21 @@ fi %{_libdir}/pkgconfig/pm-utils.pc %changelog +* Mon Apr 14 2008 Till Maas - 1.1.0-5 +- remove double %%dir %%{_libdir}/pm-utils +- update pm-utils-99hd-apm-restore to work with current pm-utils release + Red Hat Bugzilla: #442294 +- move config file for hd apm restore away from config.d, which is only used + for pm-utils internal config anymore +- own /var/run/pm-utils/ and create storage/locks subdirs (may be + needed for selinux) +- make sure an empty logfile is created after install (touch -a ...) +- sort %%files +- make Source0: an URL +- remove Conflicts: bluez utils, all supported Fedora releases ship + already a newer version +- remove unused BR: hal-devel, dbus-devel, pkgconfig, docbook-utils + * Mon Apr 8 2008 Richard Hughes - 1.1.0-4 - Fix build on 64 bit machines - harder.