[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Support for addition of modules to initrd using register-module



Hi,

Attached patches against base-installer and d-i-utils make it possible to schedule kernel modules for addition to the initrd (aka initramfs) using register_module. d-i-utils.patch adds a --initrd (or -i) option to register-module, which creates the $MODULE.initrd file in /var/lib/register-module. The base-installer patch adds the logic which looks for such files and make the neccessary changes to yaird or initramfs-tools configuration between their installation and kernel installation. It is needed on sparc, where some devices are not detected by udev, and have to be manually added to initrd for the machine to boot.

Best regards,

Jurij Smakov                                        jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/                   KeyID: C99E03CC
Index: debian/postinst
===================================================================
--- debian/postinst	(revision 36392)
+++ debian/postinst	(working copy)
@@ -510,6 +510,21 @@
 	echo $RET
 }
 
+update_yaird () {
+        ycfg='/target/etc/yaird/Default.cfg'
+        if [ -f "$ycfg" ]; then
+                sed -e "/END GOALS/s/^/\t\tMODULE $1\n/" < $ycfg > $ycfg.new && \
+		    mv $ycfg.new $ycfg
+        fi
+}
+
+update_initramfs_tools () {
+        icfg='/target/etc/mkinitramfs/modules'
+        if [ -f "$icfg" ]; then
+                echo "$1" >> $icfg
+        fi
+}
+
 install_kernel () {
 	if [ "$KERNEL" = none ]; then
 		info "Not installing any kernel"
@@ -683,6 +698,15 @@
 				echo "RESUME=$resume" >> $ramdiskconf
 			fi
 		fi
+		# Add scheduled modules
+		for modfile in /var/lib/register-module/*.initrd; do
+			[ ! -e $modfile ] && break
+			module=$(basename $modfile)
+			update_yaird "$module"
+			update_initramfs_tools "$module"
+			rm $modfile
+		done
+		  
 	else
 		info "Not installing $package."
 	fi
Index: register-module
===================================================================
--- register-module	(revision 36392)
+++ register-module	(working copy)
@@ -3,6 +3,7 @@
 TYPE=options
 PARAMS_ONLY=0
 ADD_PARAMS=1
+ADD_TO_INITRD=0
 
 if [ "$1" = "-t" ]; then
 	TYPE=$2
@@ -16,6 +17,10 @@
 	ADD_PARAMS=1
 	shift 1
 fi
+if [ "$1" = "--initrd" ] || [ "$1" = "-i" ]; then
+	ADD_TO_INITRD=1
+	shift 1
+fi
 
 MODULE=$1
 shift
@@ -23,11 +28,15 @@
 
 QUEUEFILE=$QUEUE/$MODULE.load
 PARAMFILE=$QUEUE/$MODULE.params
+INITRDFILE=$QUEUE/$MODULE.initrd
 
 mkdir -p $QUEUE
 if [ "$PARAMS_ONLY" = 0 ]; then
 	touch $QUEUEFILE
 fi
+if [ "$ADD_TO_INITRD" = 1 ]; then
+	touch $INITRDFILE
+fi
 if [ "$ADD_PARAMS" = 1 ]; then
 	PARAMS="$PARAMS $(grep "^$TYPE:" $PARAMFILE 2>/dev/null | sed "s/^$TYPE://")"
 fi

Reply to: