--- hibernate-script-1.93/scriptlets.d/modules_gentoo 2006-07-12 12:15:51.000000000 +0200 +++ /usr/share/hibernate/scriptlets.d/modules_gentoo 2006-10-01 21:51:40.000000000 +0200 @@ -4,15 +4,60 @@ AddConfigHandler GentooModulesOptions AddConfigHelp "GentooModulesAutoload " "Try to load default modules after resuming (from /etc/modules.autoload)" -GentooModulesAutoload() { - [ x"$MODULES_GENTOO_AUTOLOAD" = "x1" ] || return 0 +# Necessary helpers to parse/work with /etc/modules.autoload.d/kernel-2.? +KV_major() { + test -z "$1" && return 1 + + local KV="$@" + echo "${KV%%.*}" +} + +KV_minor() { + test -z "$1" && return 1 + + local KV="$@" + KV="${KV#*.}" + echo "${KV%%.*}" +} + +KV_micro() { + test -z "$1" && return 1 + + local KV="$@" + KV="${KV#*.*.}" + r=`echo "$KV" | sed -n 's/^\([0-9]\+\)[^0-9].*$/\1/p'` + #vecho 1 "in KV_micro KV=$KV r=$r @=" "$@" " ................" + echo $r +} + +get_KV() { + test -z "${_RC_GET_KV_CACHE}" && _RC_GET_KV_CACHE=`uname -r` + + echo "$(KV_to_int "${_RC_GET_KV_CACHE}")" - if [ ! -f /sbin/functions.sh ] ; then - vecho 1 "/sbin/functions.sh not found - not running Gentoo? gentoo-modules disabled." - return 1 + return $? +} + +KV_to_int() { + test -z "$1" && return 1 + + local KV_int=$(( `KV_major "$1"` * 65536 + `KV_minor "$1"` * 256 )) + KV_int=$(( `KV_micro "$1"` + $KV_int )) + + # We make version 2.2.0 the minimum version we will handle as + # a sanity check ... if its less, we fail ... + + if [ $KV_int -ge 131584 ]; then + echo "${KV_int}" + return 0 fi - . /sbin/functions.sh + return 1 +} + +GentooModulesAutoload() { + test "$MODULES_GENTOO_AUTOLOAD" = "1" || return 0 + # taken from gentoo's /etc/init.d/modules if [ -f /etc/modules.autoload ] && [ ! -L /etc/modules.autoload ] ; then modules_autoload_file= /etc/modules.autoload @@ -22,12 +67,10 @@ local KV_MINOR="`KV_minor "${KV}"`" # New support for /etc/modules.autoload/kernel-$KV - if [ "$(get_KV)" -ge "$(KV_to_int '2.5.48')" ] && \ - [ -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ] - then + if [ "$( get_KV )" -ge "$( KV_to_int '2.5.48' )" ] && \ + [ -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ] ; then modules_autoload_file="/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" - elif [ ! -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ] - then + elif [ ! -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ] ; then ewarn "Missing /etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" modules_autoload_file="/etc/modules.autoload.d/kernel-2.4" else @@ -52,7 +95,6 @@ return 0 } - GentooModulesOptions() { case $1 in gentoomodulesautoload)