Today I've smoked my first 'serious' sh script, making another script
(linuxrc). Now I feel what webdevelopers must feel like.

Ok these changes *should* make possible proper initramfs start with both
udev on and off (I'm using udev, but I've also tested without and it
seems to work)

The generated init script can make use of root paramter, both in
form /dev/something /my/dir/super/device or 0203 and init parameter.

I've also done some early setups for splashutils. I've got silent and
verbose splash working on my laptop and I'll write some splash adding to
geninitrd.

One thing that makes me trouble is udev. Now static linked udev doesn't
do totally anything in init/linuxrc. It doesn't make a single device!

As I've sniffed arround, we're renaming udev in our udev.spec to
initrd-udev, but FC ppl rename udevd and start a static udevd in init.
I've been able to make this happen, but that implies having a static
udevtrigger and udevsettle in initramfs, as a little tweaked start_udev
script there. That could be wrong. Any ideas then how to make udev
happen in early boot instaed of whole udev daemon??

[EMAIL PROTECTED]
Index: trunk/geninitrd
===================================================================
--- trunk/geninitrd	(wersja 8089)
+++ trunk/geninitrd	(kopia robocza)
@@ -41,6 +41,8 @@
 rootdev_nr=0
 # default bootsplash is off, if it have to be on, install bootsplash package
 BOOT_SPLASH=no
+# default same as bootsplash, if on install splashutils and some splashutils theme
+FB_SPLASH=no
 
 # is /dev on tmpfs. internal variable
 tmpfs_dev=
@@ -59,7 +61,8 @@
 	echo "       [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]"
 	echo "       [--initrdfs=rom|ext2|cram] [--modules-conf=<modules.conf>]"
 	echo "       [--with-raidstart] [--without-raidstart] [--with-insmod-static]"
-	echo "       [--without-bootsplash] [--lvmtoolsversion=1|2] [--with-udev] [--without-udev]"
+	echo "       [--without-bootsplash] [--without-fbsplash]"
+	echo "       [--lvmtoolsversion=1|2] [--with-udev] [--without-udev]"
 	echo "       [--without-suspend] [--without-suspend2] [--without-dmraid]"
 	echo "       <initrd-image> <kernel-version>"
 	echo "       (ex: `basename $0` /boot/initrd-2.2.5-15.img 2.2.5-15)"
@@ -781,6 +784,10 @@
 	. /etc/sysconfig/bootsplash
 fi
 
+if [ -r /etc/sysconfig/fbsplash ] ; then
+	. /etc/sysconfig/fbsplash
+fi
+
 if [ ! -x /bin/initrd-busybox ] ; then
 	echo "/bin/initrd-busybox is missing !"
 	exit 1
@@ -817,6 +824,9 @@
 	--without-bootsplash)
 		BOOT_SPLASH="no"
 		;;
+	--without-fbsplash)
+		FB_SPLASH="no"
+		;;
 	--without-suspend)
 		USE_SUSPEND="no";
 		;;
@@ -915,8 +925,7 @@
 if [ "x" = "x$INITRDFS" ] ; then
 	if [ "x" = "x$FS" ] ; then
 		# default value
-		# XXX: initramfs blocked for now
-		if [ "1" = " 0" -a "$pack_version" -ge "002005" ] ; then
+		if [ "$pack_version" -ge "002005" ] ; then
 			INITRDFS="initramfs"
 		else
 			INITRDFS="rom"
@@ -1047,6 +1056,9 @@
 	findmodule "-lzf"
 fi
 
+if is_yes "$FB_SPLASH"; then
+	findmodule "-evdev"
+fi
 if [ -n "$ifneeded" -a -z "$MODULES" ]; then
 	debug "No modules are needed -- not building initrd image."
 	exit 0
@@ -1464,8 +1476,34 @@
 if [ "$INITRDFS" = "initramfs" ]; then
 	mkdir -p $MNTIMAGE/newroot
 	cp -HR $org_rootdev $MNTIMAGE/dev
-	echo "mount -t $rootFs $org_rootdev /newroot" >> "$s"
-	echo "switch_root /newroot /sbin/init" >> "$s"
+	echo "mount -t proc none /proc" >> "$s"
+	# the worst part if we don't have udev
+	if [ "$USE_UDEV" != "yes" ]; then
+		# We either have root passed into kernel as /dev/something or as a maj-min number
+		# we parse acordingly
+		cat << 'EOF' >> "$s"
+root="$(busybox awk ' /root=/ { gsub(/.*root=/,NIL,$0); gsub(/ .*/,NIL,$0); print $0; } ' /proc/cmdline )"
+if [[ "$root" == +(/+([A-z0-9])) ]]; then
+	rootnr="$(busybox awk -v root="$root" ' { if ($4 == root) { print $1 $2; } } ' /proc/partitions)"
+else
+	rootnr="${root#??} ${root%??}"
+	root="$(busybox awk " \
+		BEGIN { maj=${root#??}; min=${root%??}; } \
+		{ if ( (\$1 == maj) && (\$2 == min) ) { print \$4; } } " \
+	/proc/partitions )"
+fi
+mknod $root b $rootnr
+EOF
+	fi
+	cat << EOF >> "$s"
+mount -t $rootFs \$root /newroot 
+init="\$(busybox awk ' /init=\// { gsub(/.*init=/,NIL,\$0); gsub(/ .*/,NIL,\$0); print \$0; }  ' /proc/cmdline )"
+if [ -z "\$init" -o ! -n "/newroot\$init" ]; then
+	init=/sbin/init
+fi
+umount /proc
+exec switch_root /newroot \$init
+EOF
 	# we need real file, not symlink
 	rm -f $MNTIMAGE/init
 	cp -a $MNTIMAGE/linuxrc $MNTIMAGE/init
_______________________________________________
pld-devel-en mailing list
pld-devel-en@lists.pld-linux.org
http://lists.pld-linux.org/mailman/listinfo/pld-devel-en

Reply via email to