Package: hibernate
Version: 1.12-1
Followup-For: Bug #336635

I would like the hibernate script to work out-of-the-box on whatever
suspend mechanism is available, preferring Suspend2 but falling back to
sysfs or acpi if necessary. I've attached a patch against hibernate
1.12-1 to do this.

The code to handle the case where more than one method is available is
untested, because I have only the sysfs method available; but I've
tested that after this patch the default hibernate.conf tries suspend2
and acpi but uses sysfs.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14.4
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

hibernate depends on no packages.

Versions of packages hibernate recommends:
ii  console-tools              1:0.2.3dbs-60 Linux console and font utilities
ii  hdparm                     6.3-3         tune hard disk parameters for high
pn  vlock                      <none>        (no description available)

-- no debconf information
diff -ur hibernate-1.12/hibernate.conf hibernate-1.12-tryall/hibernate.conf
--- hibernate-1.12/hibernate.conf       2006-01-06 17:59:39.000000000 -0800
+++ hibernate-1.12-tryall/hibernate.conf        2006-01-06 18:03:27.000000000 
-0800
@@ -44,8 +44,8 @@
 ## To use /sys/power/state to suspend your machine (which may offer
 ## suspend-to-RAM, suspend-to-disk, standby, etc) comment out all the options
 ## above for Software Suspend 2, below for acpi_sleep, and uncomment this line.
-## You may replace mem with any one of the states from "cat /sys/power/state"
-# UseSysfsPowerState mem
+## You may replace disk with any one of the states from "cat /sys/power/state"
+UseSysfsPowerState disk
 # PowerdownMethod shutdown
 
 ### acpi_sleep
@@ -53,7 +53,7 @@
 ## all the options above for Software Suspend 2 and sysfs, and uncomment this
 ## line. The number refers to the ACPI sleep state - 3 is suspend-to-RAM and
 ## 4 is suspend-to-disk.
-# UseACPISleep 4
+UseACPISleep 4
 
 ##############################################################################
 ### Some global settings
Only in hibernate-1.12: hibernate.spec
Only in hibernate-1.12: init.d
Only in hibernate-1.12: install.sh
diff -ur hibernate-1.12/scriptlets.d/acpi_sleep 
hibernate-1.12-tryall/scriptlets.d/acpi_sleep
--- hibernate-1.12/scriptlets.d/acpi_sleep      2005-10-01 22:54:28.000000000 
-0700
+++ hibernate-1.12-tryall/scriptlets.d/acpi_sleep       2006-01-06 
19:35:26.000000000 -0800
@@ -15,8 +15,9 @@
 ACPISleepConfigEnabler() {
     [ "$1" != "useacpisleep" ] && return 1
     [ -n "$USING_ACPI_SLEEP" ] && return 0
+    [ -n "$HIBERNATE_SUSPEND_METHOD" ] && return 0
+    EnsureACPISleepCapable || return 0
     UsingSuspendMethod acpi_sleep
-    AddSuspendHook 10 EnsureACPISleepCapable
     AddSuspendHook 99 DoACPISleep
     USING_ACPI_SLEEP=$2
     return 0
Only in hibernate-1.12/scriptlets.d: modules_gentoo
diff -ur hibernate-1.12/scriptlets.d/suspend2 
hibernate-1.12-tryall/scriptlets.d/suspend2
--- hibernate-1.12/scriptlets.d/suspend2        2005-10-01 22:54:28.000000000 
-0700
+++ hibernate-1.12-tryall/scriptlets.d/suspend2 2006-01-06 19:35:26.000000000 
-0800
@@ -66,9 +66,10 @@
     [ "$1" != "usesuspend2" ] && [ "$1" != "useswsusp2" ] && return 1
     BoolIsOn "$1" "$2" || return 0
     [ -n "$USING_SWSUSP2" ] && return 0
-    UsingSuspendMethod suspend2
     AddConfigHandler Swsusp2ConfigOptions
-    AddSuspendHook 10 EnsureSwsusp2Capable
+    [ -n "$HIBERNATE_SUSPEND_METHOD" ] && return 0
+    EnsureSwsusp2Capable || return 0
+    UsingSuspendMethod suspend2
     AddSuspendHook 97 ChangeToSwsuspVT
     AddSuspendHook 99 DoSwsusp2
     AddResumeHook 97 ChangeFromSwsuspVT
@@ -162,6 +163,7 @@
                vecho 0 "$EXE: Filewriter size is not numeric!"
                exit 1
            fi
+           [ -z "$USING_SWSUSP2" ] && return 0
            AddSuspendHook 06 Swsusp2SetupFilewriter
            AddResumeHook 06 Swsusp2CleanupFilewriter
            ;;
@@ -170,11 +172,13 @@
            SWSUSP_FILEWRITER_NOVERIFY=1
            ;;
        loadsuspendmodules)
+           [ -z "$USING_SWSUSP2" ] && return 0
            AddSuspendHook 05 Swsusp2LoadModules
            shift
            SWSUSP_LOAD_MODULES=$@
            ;;
        unloadsuspendmodulesafterresume)
+           [ -z "$USING_SWSUSP2" ] && return 0
            BoolIsOn "$1" "$2" || return 0
            AddResumeHook 05 Swsusp2UnloadModules
            ;;
@@ -196,6 +200,7 @@
            SWSUSP_ENCRYPTOR=$2
            ;;
        procsetting)
+           [ -z "$USING_SWSUSP2" ] && return 0
            if [ -z "$OPT_DRY_RUN" ] ; then
                if [ -z "$SWSUSP_EXTRA_PROC_SETTINGS" ] ; then
                    SWSUSP_EXTRA_PROC_SETTINGS=`mktemp 
/tmp/tmp.hibernate.XXXXXX`
@@ -215,6 +220,7 @@
        *)
            return 1
     esac
+    [ -z "$USING_SWSUSP2" ] && return 0
     if [ -z "$SWSUSP2_HOOKED" ] ; then
        AddSuspendHook 98 Swsusp2ConfigSet
        SWSUSP2_HOOKED=1
diff -ur hibernate-1.12/scriptlets.d/sysfs_power_state 
hibernate-1.12-tryall/scriptlets.d/sysfs_power_state
--- hibernate-1.12/scriptlets.d/sysfs_power_state       2005-10-01 
22:54:28.000000000 -0700
+++ hibernate-1.12-tryall/scriptlets.d/sysfs_power_state        2006-01-06 
19:35:26.000000000 -0800
@@ -18,9 +18,10 @@
 SysfsPowerStateConfigEnabler() {
     [ "$1" != "usesysfspowerstate" ] && return 1
     [ -n "$USING_SYSFS_POWER_STATE" ] && return 0
-    UsingSuspendMethod sysfs_power_state
     AddConfigHandler SysfsPowerStateConfigOptions
-    AddSuspendHook 10 EnsureSysfsPowerStateCapable
+    [ -n "$HIBERNATE_SUSPEND_METHOD" ] && return 0
+    EnsureSysfsPowerStateCapable $2 || return 0
+    UsingSuspendMethod sysfs_power_state
     AddSuspendHook 99 DoSysfsPowerStateSuspend
     USING_SYSFS_POWER_STATE=$2
     return 0
@@ -69,8 +70,8 @@
        vecho 0 "Your kernel does not have power management built in."
        return 2
     fi
-    if ! grep -q $USING_SYSFS_POWER_STATE $SYSFS_POWER_STATE_FILE ; then
-       vecho 0 "Your kernel or machine does support the power state 
\"$USING_SYSFS_POWER_STATE\"."
+    if ! grep -q $1 $SYSFS_POWER_STATE_FILE ; then
+       vecho 0 "Your kernel or machine does support the power state \"$1\"."
        return 2
     fi
 

Reply via email to