[readonly/geninitrd/devel: 229/334] Finish software suspend2 support (and enable it by default).

draenog draenog at pld-linux.org
Sat Nov 2 19:30:47 CET 2013


commit 2a5bcca96baaddfb13dd3ca4df641b66771cf63d
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sun Aug 1 22:37:16 2004 +0000

    Finish software suspend2 support (and enable it by default).
    
    
    svn-id: @4413

 geninitrd | 76 +++++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 45 insertions(+), 31 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 2ad6983..ddf41f7 100755
--- a/geninitrd
+++ b/geninitrd
@@ -20,13 +20,14 @@ COMPRESS="yes"
 USERAIDSTART="yes"
 USEMDADMSTATIC="no"
 USEINSMODSTATIC="no"
-USESUSPEND="no"
+USESUSPEND="yes"
 uselvm="no"
 usenfs="no"
 # it should be safe to remove scsi_mod from here, but I'm not sure...
 PRESCSIMODS="-scsi_mod unknown -sd_mod"
 PREIDEMODS="-ide-core unknown -ide-detect -ide-disk"
 PREIDEMODSOLD="-ide-probe -ide-probe-mod -ide-disk"
+SUSPENDMODS="-suspend2_core -suspend2_lzf -suspend2_block_io -suspend2_swap"
 target=""
 kernel=""
 force=""
@@ -649,6 +650,40 @@ find_modules_for() {
 	fi
 }
 
+modules_install() {
+	modules="$1"
+
+	for mod in $modules; do
+	        MODULEDIR="`my_dirname "$mod"`"
+        	mkdir -p "$MNTIMAGE/lib/modules/$kernel/$MODULEDIR"
+        	cp $verbose -a "/lib/modules/$kernel/$mod" "$MNTIMAGE/lib/modules/$kernel/$mod"
+        	gunzip "$MNTIMAGE/lib/modules/$kernel/$mod" 2> /dev/null
+	done
+}
+
+modules_add_linuxrc() {
+	modules="$1"
+	linuxrc="$2"
+ 
+	for mod in $modules; do
+        	MODULE2="`my_dirname "$mod"`"
+	        NAME2=`basename "$mod" .gz`
+	        MODULE2=$MODULE2/$NAME2
+	        module="`echo $mod | awk -F/ '{ $0=$NF } /'$modext'.*$/ { gsub(/'$modext'.*/, NIL, $0); } { print $0; }'`"
+	        options="`awk '{ if($1 == "options" && $2 == "'${module}'") { for(i=3;i<=NF;i++) printf("%s ",$i); }}' "$modulefile"`"
+
+	        if [ -n "$verbose" ]; then
+	                /bin/echo -n "Loading module [$module] "
+	                if [ -n "$options" ] ; then
+	                        echo "with options [$options]."
+	                else
+	                        echo "without options."
+	                fi
+	        fi
+	        echo "$insmod /lib/modules/$kernel/$MODULE2 $options" >> "$linuxrc"
+	done
+}
+
 if [ -r /etc/sysconfig/geninitrd ] ; then
 	. /etc/sysconfig/geninitrd
 fi
@@ -896,12 +931,6 @@ for n in $BASICMODULES; do
 	findmodule "$n"
 done
 
-if is_yes "$USESUSPEND"; then
-    for n in suspend2_core suspend2_lzf suepend2_block_io suspend2_swap; do
-	findmodule "$n"
-    done
-fi
-			
 if [ -n "$ifneeded" -a -z "$MODULES" ]; then
 	if [ -n "$verbose" ]; then
 		echo "No modules are needed -- not building initrd image."
@@ -948,12 +977,7 @@ mkdir -p "$MNTIMAGE"/{lib,bin,etc,dev,loopfs,var}
 # We don't need this directory, so let's save space
 rm -rf "$MNTPOINT"/lost+found
 
-for MODULE in $MODULES; do
-	MODULEDIR="`my_dirname "$MODULE"`"
-	mkdir -p "$MNTIMAGE/lib/modules/$kernel/$MODULEDIR"
-	cp $verbose -a "/lib/modules/$kernel/$MODULE" "$MNTIMAGE/lib/modules/$kernel/$MODULE"
-	gunzip "$MNTIMAGE/lib/modules/$kernel/$MODULE" 2> /dev/null
-done
+modules_install "$MODULES"
 
 # mknod'ing the devices instead of copying them works both with and
 # without devfs...
@@ -978,23 +1002,7 @@ set -x
 EOF
 chmod 755 "$s"
 
-for MODULE in $MODULES; do
-	MODULE2="`my_dirname "$MODULE"`"
-	NAME2=`basename "$MODULE" .gz`
-	MODULE2=$MODULE2/$NAME2
-	module="`echo $MODULE | awk -F/ '{ $0=$NF } /'$modext'.*$/ { gsub(/'$modext'.*/, NIL, $0); } { print $0; }'`"
-	options="`awk '{ if($1 == "options" && $2 == "'${module}'") { for(i=3;i<=NF;i++) printf("%s ",$i); }}' "$modulefile"`"
-
-	if [ -n "$verbose" ]; then
-		/bin/echo -n "Loading module [$module] "
-		if [ -n "$options" ] ; then
-			echo "with options [$options]."
-		else
-			echo "without options."
-		fi
-	fi
-	echo "$insmod /lib/modules/$kernel/$MODULE2 $options" >> "$s"
-done
+modules_add_linuxrc "$MODULES" "$s"
 
 # TODO: rewrite for busybox
 #if [ -n "$loopDev" ]; then
@@ -1011,11 +1019,17 @@ done
 #fi
 
 if is_yes "$USESUSPEND"; then
+	MODULES=""
+	for mod in $SUSPENDMODS; do
+	    findmodule "$mod"
+	done
+	modules_install "$MODULES"
     	mkdir -p $MNTIMAGE/sys
     	mkdir -p $MNTIMAGE/proc
 	echo "mount -t proc none /proc" >> "$s"
 	echo "cmdline=\`cat /proc/cmdline\`" >> "$s"
-	echo "if [ \"$cmdline\" != \"${cmdline#* resume2=}\" ]; then" >> "$s"
+	echo "if [ \"\$cmdline\" != \"\${cmdline#* resume2=}\" ]; then" >> "$s"
+	modules_add_linuxrc "$MODULES" "$s"
 	echo "	echo > /proc/software_suspend/activate" >> "$s"
 	echo "  umount /proc" >> "$s"
 	echo "	exit 0" >> "$s"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/398807324938659207036e520c0950a61ef50c11



More information about the pld-cvs-commit mailing list