SVN: geninitrd/trunk/geninitrd

glen glen at pld-linux.org
Tue Mar 20 15:12:25 CET 2007


Author: glen
Date: Tue Mar 20 15:12:24 2007
New Revision: 8390

Modified:
   geninitrd/trunk/geninitrd
Log:
- add busybox_applet() which checks if busybox has required applet present

Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd	(original)
+++ geninitrd/trunk/geninitrd	Tue Mar 20 15:12:24 2007
@@ -88,6 +88,38 @@
 	[ -n "$verbose" ] && echo "$*"
 }
 
+# Checks if busybox has support for APPLET(s)
+# Exits from geninitrd if the support is not present.
+#
+# NB! XXX do not output to STDOUT, it will appear in initrd images in some cases!
+busybox_applet() {
+	local err=0
+
+	if [ -z "$busybox_functions" ]; then
+		busybox_functions=$(/bin/initrd-busybox 2>&1 | \
+			sed -ne '/Currently defined functions:/,$p' | \
+		   	xargs | sed -e 's,.*Currently defined functions: ,,'
+		)
+	fi
+	for applet in $*; do
+		local have
+		# try cache
+		eval have='$'busybox_have_$applet
+		if [ -z "$have" ]; then
+			have=$(echo "$busybox_functions" | egrep -c "( |^)$applet(,|$)")
+			if [ "$have" = 0 ]; then
+				echo >&2 "This setup requires busybox-initrd compiled with applet '$applet' support"
+				err=1
+			fi
+			eval busybox_have_$applet=$have
+		fi
+	done
+	if [ $err = 1 ]; then
+		echo >&2 "aborted"
+		exit 1
+	fi
+}
+
 find_depmod () {
 	typeset mods module f level depfile first
 
@@ -661,7 +693,7 @@
 fi
 
 if [ ! -x /bin/initrd-busybox ] ; then
-	echo "/bin/initrd-busybox is missing !"
+	echo "/bin/initrd-busybox is missing!"
 	exit 1
 fi
 
@@ -1050,6 +1082,8 @@
 
 initrd_gen_tmpfs_dev() {
 	tmpfs_dev=yes
+
+	busybox_applet mount mknod mkdir
 	cat <<-EOF
 : 'Creating /dev'
 mount -o mode=0755 -t tmpfs none /dev
@@ -1068,6 +1102,11 @@
 	mkdir -p $MNTIMAGE/etc/udev
 	mkdir -p $MNTIMAGE/sys
 
+	if [ ! -x /sbin/initrd-udevd ]; then
+		echo >&2 "/sbin/initrd-udevd not present; aborted"
+		exit 1
+	fi
+
 	inst /sbin/initrd-udevd $MNTIMAGE/sbin/udevd
 	inst /etc/udev/udev.conf $MNTIMAGE/etc/udev/udev.conf
 
@@ -1087,7 +1126,9 @@
 				/sbin/udevsettle
 				EOF
 		fi
-		cat >> "$s" <<- 'EOF'
+
+		busybox_applet killall
+		cat >> "$s" <<-'EOF'
 			killall udevd
 			umount /proc
 			umount /dev


More information about the pld-cvs-commit mailing list