[readonly/geninitrd: 469/1068] - cosmetics - take modprobe -c as modules source by default (you can now use include statement there

draenog draenog at pld-linux.org
Sat Nov 2 19:51:48 CET 2013


commit 82474db98676ba3957816b3aa8c6a6409c496956
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Thu Oct 25 08:15:56 2007 +0000

    - cosmetics
    - take modprobe -c as modules source by default (you can now use include statement there)
    
    svn-id: @8868

 geninitrd | 78 ++++++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 47 insertions(+), 31 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index ac52f61..909a19e 100755
--- a/geninitrd
+++ b/geninitrd
@@ -210,7 +210,7 @@ BEGIN { here = 0 }
 	fi
 
 	first=
-	for f in $mods ; do
+	for f in $mods; do
 		if [ "$first" = "" ]; then
 			first=$f
 		else
@@ -236,7 +236,7 @@ addmodule() {
 	# only need to add each module once
 	# quote /
 	local tmpFmPath=$(echo $fmPath | awk '{gsub(/\//,"\\/");print}')
-	if echo "$MODULES" | awk '/'"$tmpFmPath"'/ {exit 1}' ; then
+	if echo "$MODULES" | awk '/'"$tmpFmPath"'/ {exit 1}'; then
 		MODULES="$MODULES $fmPath"
 	fi
 }
@@ -295,6 +295,31 @@ inst_d() {
 	done
 }
 
+# output modules.conf / modprobe.conf
+modprobe_conf() {
+	echo "$modprobe_conf_cache"
+}
+
+#
+# defaults to modprobe -c if not told otherwise, this means include statements
+# work from there.
+cache_modprobe_conf() {
+	if [ "$pack_version" -lt "002005" ]; then
+		modulefile=/etc/modules.conf
+		if [ ! -f "$modulefile" -a -f /etc/conf.modules ]; then
+			modulefile=/etc/conf.modules
+		fi
+	fi
+
+	if [ -n "$modulefile" ]; then
+		debug "modprobe: using $modulefile"
+		modprobe_conf_cache=$(cat $modulefile)
+	else
+		debug "modprobe: using modprobe -c"
+		modprobe_conf_cache=$(modprobe -c)
+	fi
+}
+
 find_modules_md() {
 	local found raidlevel
 
@@ -339,7 +364,7 @@ find_modules_md() {
 		die "raidtools are not longer supported. Please migrate to mdadm setup!"
 	fi
 
-	if is_yes "$have_md" ; then
+	if is_yes "$have_md"; then
 		case "$raidlevel" in
 		[01]|10)
 			findmodule "raid$raidlevel"
@@ -373,7 +398,7 @@ find_modules_scsi() {
 	for n in $PRESCSIMODS; do
 		if [ "X$n" = "Xunknown" ]; then
 			if [ -f "$modulefile" ]; then
-				scsimodules="`awk '/scsi_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
+				local scsimodules=$(modprobe_conf | awk '/scsi_hostadapter/ && ! /^[\t ]*#/ { print $3; }')
 				for n in $scsimodules; do
 			# for now allow scsi modules to come from anywhere. There are some
 			# RAID controllers with drivers in block
@@ -404,14 +429,12 @@ find_modules_ide() {
 		local tryauto=1
 		for n in $PREIDEMODS; do
 			if [ "X$n" = "Xunknown" ]; then
-				if [ -f "$modulefile" ]; then
-					debug "Finding IDE modules using ide_hostadapter"
-					idemodules="`awk '/ide_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
-					for na in $idemodules; do
-						tryauto=0;
-						findmodule "$na"
-					done
-				fi
+				debug "Finding IDE modules using ide_hostadapter"
+				local mod idemodules=$(modprobe_conf | awk '/ide_hostadapter/ && ! /^[\t ]*#/ { print $3; }')
+				for mod in $idemodules; do
+					tryauto=0;
+					findmodule "$mod"
+				done
 
 				if [ "$tryauto" -eq 1 ]; then
 					# If tryauto {{{
@@ -638,12 +661,12 @@ find_modules_for_device() {
 		# fallback
 	fi
 
-	if is_yes "$(echo "$devpath" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')" ; then
+	if is_yes "$(echo "$devpath" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')"; then
 		find_modules_scsi
 		return
 	fi
 
-	if is_yes "$(echo "$devpath" | awk '/^\/dev\/(hd|ide)/ { print "yes"; }')" ; then
+	if is_yes "$(echo "$devpath" | awk '/^\/dev\/(hd|ide)/ { print "yes"; }')"; then
 		find_modules_ide "$devpath"
 		return
 	fi
@@ -666,10 +689,10 @@ find_modules_for_device() {
 	if [[ "$devpath" == /dev/ataraid/* ]]; then
 		find_modules_ide
 		findmodule "ataraid"
-		ataraidmodules="`awk '/ataraid_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
+		ataraidmodules=$(modprobe_conf | awk '/ataraid_hostadapter/ && ! /^[\t ]*#/ { print $3; }')
 		if [ -n "$ataraidmodules" ]; then
 			# FIXME: think about modules compiled in kernel
-			die "ataraid_hostadapter alias not defined in $modulefile! Please set it and run $PROGRAM again."
+			die "ataraid_hostadapter alias not defined in modprobe.conf! Please set it and run $PROGRAM again."
 		fi
 		for n in $ataraidmodules; do
 			findmodule "$n"
@@ -685,7 +708,7 @@ find_modules_for_device() {
 			die "losetup is missing"
 		fi
 		key="^# $(echo $devpath | awk -F/ '{print($3);}' | tr '[a-z]' '[A-Z]'):"
-		if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`" ; then
+		if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`"; then
 			die "The root filesystem is on a $devpath, but there is no magic entry in $fstab for this device. Consult the geninitrd man page for more information"
 		fi
 
@@ -797,7 +820,7 @@ modules_add_linuxrc() {
 		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"`"
+		options=$(modprobe_conf | awk -vmodule="$module" '{ if ($1 == "options" && $2 == module) { for(i=3;i<=NF;i++) printf("%s ",$i); }}')
 
 		generic_module=$(echo "${module}" | awk ' { gsub("-", "_", $0) } { print $0; } ')
 		sleep_var="$(eval echo \$MODULE_${generic_module}_USLEEP)"
@@ -1020,7 +1043,7 @@ if [ "$pack_version" -ge "002005" ]; then
 	insmod="insmod"
 fi
 
-if is_yes "$USEINSMODSTATIC" ; then
+if is_yes "$USEINSMODSTATIC"; then
 	insmod="insmod.static"
 	INSMOD="/sbin/insmod.static"
 	if [ "$pack_version" -lt "002005" -a -f /sbin/insmod.static.modutils ]; then
@@ -1088,25 +1111,18 @@ if [ ! -f /proc/mounts ]; then
 	echo >&2 "WARNING: /proc filesystem not mounted, may cause wrong results or failure."
 fi
 
-if [ "$pack_version" -lt "002005" ]; then
-	modulefile=/etc/modules.conf
-	if [ ! -f "$modulefile" -a -f /etc/conf.modules ]; then
-		modulefile=/etc/conf.modules
-	fi
-else
-	modulefile=/etc/modprobe.conf
-fi
+cache_modprobe_conf
 
 for n in $PREMODS; do
 	findmodule "$n"
 done
 
 # allow forcing loading SCSI and/or IDE modules
-if is_yes "$ADDSCSI" ; then
+if is_yes "$ADDSCSI"; then
 	find_modules_scsi
 fi
 
-if is_yes "$ADDIDE" ; then
+if is_yes "$ADDIDE"; then
 	find_modules_ide
 fi
 
@@ -1745,13 +1761,13 @@ case "$INITRDFS" in
 		mkcramfs "$MNTPOINT" "$IMAGE"
 		;;
 	initramfs)
-		(cd $MNTPOINT ; find . | cpio --quiet -H newc -o > "$IMAGE")
+		(cd $MNTPOINT; find . | cpio --quiet -H newc -o > "$IMAGE")
 		;;
 	*)
 		echo "Filesystem $INITRDFS not supported by $PROGRAM";
 esac
 
-if is_yes "$COMPRESS" ; then
+if is_yes "$COMPRESS"; then
 	gzip -9 < "$IMAGE" > "$target"
 else
 	cp -a "$IMAGE" "$target"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090



More information about the pld-cvs-commit mailing list