SVN: geninitrd/trunk/geninitrd

glen glen at pld-linux.org
Tue Nov 6 03:00:32 CET 2007


Author: glen
Date: Tue Nov  6 03:00:31 2007
New Revision: 8999

Modified:
   geninitrd/trunk/geninitrd
Log:
- use $DESTDIR, as it's more common
- always create /var/lib/multipath/bindings file for dm-multipath

Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd	(original)
+++ geninitrd/trunk/geninitrd	Tue Nov  6 03:00:31 2007
@@ -389,8 +389,8 @@
 	local dest=$1
 	set -- $src
 
-	debug "cp $* $MNTIMAGE$dest"
-	cp -HR "$@" "$MNTIMAGE$dest"
+	debug "cp $* $DESTDIR$dest"
+	cp -HR "$@" "$DESTDIR$dest"
 }
 
 inst_d() {
@@ -398,7 +398,7 @@
 		die 'Usage: inst_d <destination> <destination>'
 	fi
 	for dir in "$@"; do
-		install -d "$MNTIMAGE$dir"
+		install -d "$DESTDIR$dir"
 	done
 }
 
@@ -420,7 +420,7 @@
 
 	local lib libs=$(ldd "$@" | awk '/statically|linux-gate\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
 	for lib in $libs; do
-		if [ ! -f "$MNTIMAGE/$_lib/${lib##*/}" ]; then
+		if [ ! -f "$DESTDIR/$_lib/${lib##*/}" ]; then
 			inst_d /$_lib
 			inst_exec $lib /$_lib
 		fi
@@ -896,16 +896,16 @@
 
 	debug "Adding Firmwares ($firmware_files) to initrd for module $module"
 	# firmware not yet installed
-	if [ ! -f "$MNTIMAGE/lib/firmware/firmware.sh" ]; then
+	if [ ! -f "$DESTDIR/lib/firmware/firmware.sh" ]; then
 		inst_d /lib/firmware
-cat << 'EOF' >> "$MNTIMAGE/lib/firmware/firmware.sh"
+cat << 'EOF' >> "$DESTDIR/lib/firmware/firmware.sh"
 #!/bin/sh -e
 echo 1 > /sys$DEVPATH/loading
 cat "/lib/firmware/$FIRMWARE" > /sys$DEVPATH/data
 echo 0 > /sys$DEVPATH/loading
 exit 0
 EOF
-	 	chmod 755 "$MNTIMAGE/lib/firmware/firmware.sh"
+	 	chmod 755 "$DESTDIR/lib/firmware/firmware.sh"
 	fi
 
 	for firmware in $firmware_files; do
@@ -923,8 +923,8 @@
 	for mod in $modules; do
 		MODULEDIR=$(dirname "$mod")
 		inst_d "/lib/modules/$kernel/$MODULEDIR"
-		cp -a "/lib/modules/$kernel/$mod" "$MNTIMAGE/lib/modules/$kernel/$mod"
-		gunzip "$MNTIMAGE/lib/modules/$kernel/$mod" 2> /dev/null
+		cp -a "/lib/modules/$kernel/$mod" "$DESTDIR/lib/modules/$kernel/$mod"
+		gunzip "$DESTDIR/lib/modules/$kernel/$mod" 2> /dev/null
 	done
 }
 
@@ -972,7 +972,7 @@
 		die "/usr/${_lib}/suspend/resume is missing!"
 	fi
 	resume_dev="$(awk '/^resume device =/ { print $4 } ' /etc/suspend.conf)"
-	mknod $MNTIMAGE/dev/snapshot c 10 231
+	mknod $DESTDIR/dev/snapshot c 10 231
 	inst $resume_dev /dev
 	inst /etc/suspend.conf /etc/suspend.conf
 	if [ -x /usr/${_lib}/suspend/resume ]; then
@@ -1027,7 +1027,7 @@
 }
 
 initrd_gen_multipath() {
-	inst_d /sbin /lib/udev
+	inst_d /sbin /lib/udev /var/lib/multipath
 	inst_exec /sbin/kpartx /sbin
 	inst_exec /sbin/multipath /sbin
 	# for udev callouts
@@ -1035,8 +1035,9 @@
 	inst_exec /sbin/mpath* /sbin
 	inst /etc/multipath.conf /etc
 	if [ -f /var/lib/multipath/bindings ]; then
-		inst_d /var/lib/multipath
 		inst /var/lib/multipath/bindings /var/lib/multipath
+	else
+		touch $DESTDIR/var/lib/multipath/bindings
 	fi
 
 	mount_dev
@@ -1125,7 +1126,7 @@
 
 	for res in $FB_SPLASH_RESOLUTIONS; do
 		if [ -f "/etc/splash/$SPLASH_THEME/$res.cfg" ]; then
-			/usr/bin/splash_geninitramfs -c $MNTIMAGE -r $res $SPLASH_THEME && \
+			/usr/bin/splash_geninitramfs -c $DESTDIR -r $res $SPLASH_THEME && \
 			debug "Added $res $SPLASH_THEME theme to initramfs."
 		else
 			echo >&2 "/etc/splash/$SPLASH_THEME/$res.cfg doesn't exist, skipped"
@@ -1170,7 +1171,7 @@
 	# LVM on RAID case
 	dev_list_extra=$(awk '/^DEVICE / { for (i=2; i<=NF; i++) { printf "%s ", $i; }; } ' /etc/mdadm.conf)
 	for ex_dev in $dev_list_extra; do
-		echo "DEVICE $ex_dev" >> "$MNTIMAGE/etc/mdadm.conf"
+		echo "DEVICE $ex_dev" >> "$DESTDIR/etc/mdadm.conf"
 	done
 	do_md0=1
 	for nr in `seq 1 $rootdev_nr`; do
@@ -1180,19 +1181,19 @@
 
 		[ "$cr_rootdev" = "/dev/md0" ] && do_md0=0
 
-		echo "DEVICE $cr_dev_list" >> "$MNTIMAGE/etc/mdadm.conf"
+		echo "DEVICE $cr_dev_list" >> "$DESTDIR/etc/mdadm.conf"
 		cr_dev_list_md="$(echo "$cr_dev_list" | xargs | awk ' { gsub(/ +/,",",$0); print $0; }')"
 		cr_md_conf=$(/sbin/mdadm --detail --brief --config=/etc/mdadm.conf $cr_rootdev | awk ' { gsub(/spares=[0-9]+/, "", $0); print $0; }')
 		if [ -n "$cr_md_conf" ]; then
-			echo "$cr_md_conf" >> "$MNTIMAGE/etc/mdadm.conf"
+			echo "$cr_md_conf" >> "$DESTDIR/etc/mdadm.conf"
 		else
-			echo "ARRAY $cr_rootdev devices=$cr_dev_list_md" >> "$MNTIMAGE/etc/mdadm.conf"
+			echo "ARRAY $cr_rootdev devices=$cr_dev_list_md" >> "$DESTDIR/etc/mdadm.conf"
 		fi
 
 		for f in $cr_dev_list $cr_rootdev $dev_list_extra; do
 			# mkdir in case of devfs name
 			inst_d $(dirname $f)
-			[ -e "$MNTIMAGE/$f" ] && continue
+			[ -e "$DESTDIR/$f" ] && continue
 			# this works fine with and without devfs
 			inst $f $f
 		done
@@ -1202,7 +1203,7 @@
 
 	# needed to determine md-version
 	if [ "$do_md0" -eq 1 ]; then
-		mknod $MNTIMAGE/dev/md0 b 9 0
+		mknod $DESTDIR/dev/md0 b 9 0
 	fi
 }
 
@@ -1210,15 +1211,15 @@
 	# use root=/dev/ram0 init=/linuxrc when starting kernel or you will
 	# have problems like init(XX) being child process of swapper(1).
 	debug "Adding rootfs on NFS support to initrd (dhcp)"
-	mknod "$MNTIMAGE/dev/urandom" c 1 9
-	mkdir "$MNTIMAGE/newroot"
-	mkdir "$MNTIMAGE/proc"
+	mknod "$DESTDIR/dev/urandom" c 1 9
+	mkdir "$DESTDIR/newroot"
+	mkdir "$DESTDIR/proc"
 	echo "ifconfig lo 127.0.0.1 up" | add_linuxrc
 	echo "route add -net 127.0.0.0 netmask 255.0.0.0 lo" | add_linuxrc
 	echo "ifconfig eth0 0.0.0.0 up" | add_linuxrc
 	echo "udhcpc -i eth0 -f -q -s /bin/setdhcp" | add_linuxrc
 
-	cat <<-'EOF' > "$MNTIMAGE/bin/setdhcp"
+	cat <<-'EOF' > "$DESTDIR/bin/setdhcp"
 		#!/bin/sh
 		[ "$1" != "bound" ] && exit
 		[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
@@ -1231,7 +1232,7 @@
 		fi
 	EOF
 
-	cat <<-'EOF' > "$MNTIMAGE/bin/setdhcp"
+	cat <<-'EOF' > "$DESTDIR/bin/setdhcp"
 		for o in $CMDLINE; do
 			case $o in
 			nfsroot=*)
@@ -1249,7 +1250,7 @@
 		fi
 	EOF
 
-	chmod 755 "$MNTIMAGE/bin/setdhcp"
+	chmod 755 "$DESTDIR/bin/setdhcp"
 	add_linuxrc <<-'EOF'
 		cd /newroot
 		pivot_root . initrd
@@ -1270,10 +1271,10 @@
 
 	if ! is_yes "$dev_mounted"; then
 		inst_d /dev/mapper
-		mknod $MNTIMAGE/dev/mapper/control c 10 63
+		mknod $DESTDIR/dev/mapper/control c 10 63
 		for device in $PVDEVICES; do
 			# if LVM on RAID then device might be copied already in gen_md
-			[ -e "$MNTIMAGE/dev/$(basename $device)" ] && continue
+			[ -e "$DESTDIR/dev/$(basename $device)" ] && continue
 			inst $device /dev
 		done
 	fi
@@ -1286,31 +1287,31 @@
 		EOF
 	else
 		echo "cat /etc/lvm.conf > /tmp/lvm.conf" | add_linuxrc
-		echo "global {" > "$MNTIMAGE/etc/lvm.conf"
-		echo "	locking_type = 0" >> "$MNTIMAGE/etc/lvm.conf"
-		echo "	locking_dir = \"/tmp\"" >> "$MNTIMAGE/etc/lvm.conf"
-		echo "}" >> "$MNTIMAGE/etc/lvm.conf"
-		echo "devices {" >> "$MNTIMAGE/etc/lvm.conf"
-		echo "	sysfs_scan=0" >> "$MNTIMAGE/etc/lvm.conf"
+		echo "global {" > "$DESTDIR/etc/lvm.conf"
+		echo "	locking_type = 0" >> "$DESTDIR/etc/lvm.conf"
+		echo "	locking_dir = \"/tmp\"" >> "$DESTDIR/etc/lvm.conf"
+		echo "}" >> "$DESTDIR/etc/lvm.conf"
+		echo "devices {" >> "$DESTDIR/etc/lvm.conf"
+		echo "	sysfs_scan=0" >> "$DESTDIR/etc/lvm.conf"
 		if is_yes "$have_md"; then
-			echo "	md_component_detection = 1" >> "$MNTIMAGE/etc/lvm.conf"
+			echo "	md_component_detection = 1" >> "$DESTDIR/etc/lvm.conf"
 		fi
 		if is_yes "$have_dmraid" || is_yes "$have_multipath"; then
-			echo '	types = [ "device-mapper", 254 ]' >> "$MNTIMAGE/etc/lvm.conf"
+			echo '	types = [ "device-mapper", 254 ]' >> "$DESTDIR/etc/lvm.conf"
 		fi
 		if [ "$lvm_ignore_devices" ]; then
 			# TODO: think of merging with lvm dumpconfig output
-			echo '	filter = [' >> "$MNTIMAGE/etc/lvm.conf"
+			echo '	filter = [' >> "$DESTDIR/etc/lvm.conf"
 			local dev
 			for dev in $lvm_ignore_devices; do
 				debug "LVM2: ignore device $dev"
 				printf '  "r|^%s.*|",\n' $dev
-			done >> "$MNTIMAGE/etc/lvm.conf"
-			echo ']' >> "$MNTIMAGE/etc/lvm.conf"
+			done >> "$DESTDIR/etc/lvm.conf"
+			echo ']' >> "$DESTDIR/etc/lvm.conf"
 		fi
 		# XXX filter= must be on one line!
-		lvm dumpconfig | awk '/filter=/' >> "$MNTIMAGE/etc/lvm.conf"
-		echo "}" >> "$MNTIMAGE/etc/lvm.conf"
+		lvm dumpconfig | awk '/filter=/' >> "$DESTDIR/etc/lvm.conf"
+		echo "}" >> "$DESTDIR/etc/lvm.conf"
 
 		initrd_gen_devices
 
@@ -1691,13 +1692,13 @@
 fi
 debug "Using modules: $MODULES"
 
-MNTIMAGE="`mktemp -d /tmp/initrd.XXXXXX`"
+DESTDIR="`mktemp -d /tmp/initrd.XXXXXX`"
 IMAGE="`mktemp -u /tmp/initrd.img-XXXXXX`"
 MNTPOINT="`mktemp -d /tmp/initrd.mnt-XXXXXX`"
-RCFILE="$MNTIMAGE/linuxrc"
+RCFILE="$DESTDIR/linuxrc"
 
-if [ -f "$MNTIMAGE" ]; then
-	die "$MNTIMAGE already exists. Remove it and try again"
+if [ -f "$DESTDIR" ]; then
+	die "$DESTDIR already exists. Remove it and try again"
 fi
 
 if [ -f "$IMAGE" ]; then
@@ -1710,7 +1711,7 @@
 
 > "$RCFILE"
 chmod a+rx "$RCFILE"
-ln -s linuxrc $MNTIMAGE/init
+ln -s linuxrc $DESTDIR/init
 
 # create dirs that we really need
 inst_d /{lib,bin,etc,dev{,/pts,/shm},loopfs,var,proc,sys}
@@ -1719,13 +1720,13 @@
 
 # mknod'ing the devices instead of copying them works both with and
 # without devfs...
-mknod "$MNTIMAGE/dev/console" c 5 1
-mknod "$MNTIMAGE/dev/null" c 1 3
-mknod "$MNTIMAGE/dev/zero" c 1 5
+mknod "$DESTDIR/dev/console" c 5 1
+mknod "$DESTDIR/dev/null" c 1 3
+mknod "$DESTDIR/dev/zero" c 1 5
 
 inst /bin/initrd-busybox /bin/initrd-busybox
-ln -s initrd-busybox $MNTIMAGE/bin/sh
-ln -s initrd-busybox $MNTIMAGE/bin/busybox # for older busyboxes who had /bin/busybox as EXEPATH
+ln -s initrd-busybox $DESTDIR/bin/sh
+ln -s initrd-busybox $DESTDIR/bin/busybox # for older busyboxes who had /bin/busybox as EXEPATH
 
 if is_yes "$USEINSMODSTATIC"; then
 	inst "$INSMOD" /bin/insmod.static
@@ -1774,8 +1775,8 @@
 #		mkdir /initrd
 #	fi
 #
-#	cp -a "$loopDev" "$MNTIMAGE/dev"
-#	cp -a "$rootdev" "$MNTIMAGE/dev"
+#	cp -a "$loopDev" "$DESTDIR/dev"
+#	cp -a "$rootdev" "$DESTDIR/dev"
 #	echo "echo Mounting device containing loopback root filesystem" >> "$RCFILE"
 #	echo "mount -t $loopFs $loopDev /loopfs" >> "$RCFILE"
 #	echo "echo Setting up loopback device $rootdev" >> $RCFILE
@@ -1819,11 +1820,11 @@
 fi
 
 # additional devs always needed
-[ ! -e "$MNTIMAGE/$rootdev_add" ] && inst $rootdev_add /dev
+[ ! -e "$DESTDIR/$rootdev_add" ] && inst $rootdev_add /dev
 
 if [ "$INITRDFS" = "initramfs" ]; then
 	inst_d /newroot
-	[ ! -e "$MNTIMAGE/$rootdev" ] && inst $rootdev /dev
+	[ ! -e "$DESTDIR/$rootdev" ] && inst $rootdev /dev
 	# Parsing root parameter
 	# We support passing root as hda3 /dev/hda3 0303 0x0303 and 303
 	add_linuxrc <<-'EOF'
@@ -1893,7 +1894,7 @@
 	EOF
 	# we need /init being real file, not symlink, otherwise the initramfs will
 	# not be ran by pid 1 which is required for switch_root
-	mv $MNTIMAGE/linuxrc $MNTIMAGE/init
+	mv $DESTDIR/linuxrc $DESTDIR/init
 else
 	# other than initramfs
 	umount_all
@@ -1904,7 +1905,7 @@
 fi
 
 
-(cd "$MNTIMAGE"; tar cf - .) | (cd "$MNTPOINT"; tar xf -)
+(cd "$DESTDIR"; tar cf - .) | (cd "$MNTPOINT"; tar xf -)
 
 case "$INITRDFS" in
 	ext2)
@@ -1953,6 +1954,6 @@
 	initrd_gen_bootsplash "$target"
 fi
 
-rm -rf "$MNTIMAGE" "$MNTPOINT" "$IMAGE"
+rm -rf "$DESTDIR" "$MNTPOINT" "$IMAGE"
 
 # vim:ts=4:sw=4:noet:fdm=marker


More information about the pld-cvs-commit mailing list