[pm-utils] Added support for grub2 in 01grub hook (grub2 patch) Fixed hooks exit code logging (hook-exit-code-l

Jaroslav Škarvada jskarvad at fedoraproject.org
Mon Aug 22 13:26:34 UTC 2011


commit a73cbc13eb26c9dae39d65e721db59662c77277a
Author: Jaroslav Škarvada <jskarvad at redhat.com>
Date:   Mon Aug 22 15:26:13 2011 +0200

    Added support for grub2 in 01grub hook (grub2 patch)
    Fixed hooks exit code logging (hook-exit-code-log patch)

 pm-utils-1.4.1-grub2.patch              |   45 +++++++++++++++++++++++++++++++
 pm-utils-1.4.1-hook-exit-code-log.patch |   19 +++++++++++++
 pm-utils.spec                           |   12 +++++++-
 3 files changed, 75 insertions(+), 1 deletions(-)
---
diff --git a/pm-utils-1.4.1-grub2.patch b/pm-utils-1.4.1-grub2.patch
new file mode 100644
index 0000000..4d3311e
--- /dev/null
+++ b/pm-utils-1.4.1-grub2.patch
@@ -0,0 +1,45 @@
+diff -up pm-utils-1.4.1/pm/sleep.d/01grub.orig pm-utils-1.4.1/pm/sleep.d/01grub
+--- pm-utils-1.4.1/pm/sleep.d/01grub.orig	2010-07-04 16:42:51.000000000 +0200
++++ pm-utils-1.4.1/pm/sleep.d/01grub	2011-08-22 14:11:39.460613138 +0200
+@@ -4,7 +4,8 @@
+ 
+ default_resume_kernel()
+ {
+-        [ "$1" = "suspend" ] && return $NA
++	local g2reboot
++	[ "$1" = "suspend" ] && return $NA
+ 	case $(uname -m) in
+ 		i?86|x86_64|athlon)
+ 	    		;;
+@@ -13,14 +14,26 @@ default_resume_kernel()
+ 	    		;;
+ 	esac
+ 
+-	[ -x /sbin/grubby -a -x /sbin/grub ] || return $NA
++	[ -x /sbin/grubby -a \( -x /sbin/grub -o -r /etc/grub2.cfg \) ] || \
++		return $NA
+ 	[ -e "/boot/vmlinuz-$(uname -r)" ] || return 1
+-	out=$(/sbin/grubby --info /boot/vmlinuz-$(uname -r) |grep index)
++	out=$(/sbin/grubby --info /boot/vmlinuz-$(uname -r) |grep index | \
++		head -n 1)
+ 	[ -n "${out}" ] || return 1
+ 	current=${out#index=}
+-	echo "savedefault --default=${current} --once" | \
+-		/sbin/grub --device-map=/boot/grub/device.map \
+-		--batch --no-floppy --no-curses >/dev/null
++	if [ -r /etc/grub2.cfg ]; then
++		# to enable this functionality in grub2
++		# GRUB_DEFAULT=saved is needed in /etc/default/grub
++		# if you want to be able to by-pass the selection in the
++		# boot menu, also use GRUB_SAVEDEFAULT=true
++		g2reboot=`which grub2-reboot 2>/dev/null` || \
++			g2reboot=`which grub-reboot 2>/dev/null` || return $NA
++		$g2reboot ${current} > /dev/null
++	else
++		echo "savedefault --default=${current} --once" | \
++			/sbin/grub --device-map=/boot/grub/device.map \
++			--batch --no-floppy --no-curses >/dev/null
++	fi
+ 
+ 	return 0
+ }
diff --git a/pm-utils-1.4.1-hook-exit-code-log.patch b/pm-utils-1.4.1-hook-exit-code-log.patch
new file mode 100644
index 0000000..7eccd83
--- /dev/null
+++ b/pm-utils-1.4.1-hook-exit-code-log.patch
@@ -0,0 +1,19 @@
+diff -up pm-utils-1.4.1/pm/pm-functions.in.orig pm-utils-1.4.1/pm/pm-functions.in
+--- pm-utils-1.4.1/pm/pm-functions.in.orig	2011-08-22 14:52:58.976213050 +0200
++++ pm-utils-1.4.1/pm/pm-functions.in	2011-08-22 14:57:26.000000000 +0200
+@@ -195,11 +195,13 @@ hook_ok()
+ _run_hook() {
+ 	# $1 = hook to run
+ 	# rest of args passed to hook unchanged.
++	local hook_status
+ 	log "Running hook $*:"
+ 	hook_ok "$1" && "$@"
++	hook_status=$?
+ 	log ""
+-	log -n "$*: " 
+-	hook_exit_status $? && LAST_HOOK="${1##*/}" || inhibit
++	log -n "$*: "
++	hook_exit_status $hook_status && LAST_HOOK="${1##*/}" || inhibit
+ }
+ 
+ if profiling; then
diff --git a/pm-utils.spec b/pm-utils.spec
index 6cdc5fb..ab31964 100644
--- a/pm-utils.spec
+++ b/pm-utils.spec
@@ -3,7 +3,7 @@ Name: pm-utils
 Summary: Power management utilities and scripts for Fedora
 License: GPLv2
 Version: 1.4.1
-Release: 11%{?dist}
+Release: 12%{?dist}
 Group: System Environment/Base
 URL: http://pm-utils.freedesktop.org
 %ifnarch s390 s390x
@@ -22,6 +22,10 @@ Source23: pm-utils-bugreport-info.sh
 Patch0: pm-utils-1.4.1-init-logfile-append.patch
 # Fix typo in 55NetworkManager (#722759)
 Patch1: pm-utils-1.4.1-networkmanager-typo-fix.patch
+# Add support for grub2 in 01grub hook
+Patch2: pm-utils-1.4.1-grub2.patch
+# Fix hooks exit code logging
+Patch3: pm-utils-1.4.1-hook-exit-code-log.patch
 
 %description
 The pm-utils package contains utilities and scripts useful for tasks related
@@ -43,6 +47,8 @@ when building programs that use %{name}.
 tar -xzf %{SOURCE1}
 %patch0 -p1 -b .init-logfile-append
 %patch1 -p1 -b .network-manager-typo-fix.patch
+%patch2 -p1 -b .grub2
+%patch3 -p1 -b .hook-exit-code-log
 
 %build
 %configure
@@ -101,6 +107,10 @@ rm -rf %{_localstatedir}/run/pm-utils/{pm-suspend,pm-powersave}/storage/*
 %{_libdir}/pkgconfig/pm-utils.pc
 
 %changelog
+* Mon Aug 22 2011 Jaroslav Škarvada <jskarvad at redhat.com> - 1.4.1-12
+- Added support for grub2 in 01grub hook (grub2 patch)
+- Fixed hooks exit code logging (hook-exit-code-log patch)
+
 * Wed Aug 17 2011 Jaroslav Škarvada <jskarvad at redhat.com> - 1.4.1-11
 - Rebuilt due to bug in rpm-4.9.1
 


More information about the scm-commits mailing list