SVN: geninitrd/trunk/geninitrd
glen
glen at pld-linux.org
Fri Nov 2 18:16:10 CET 2007
Author: glen
Date: Fri Nov 2 18:16:10 2007
New Revision: 8969
Modified:
geninitrd/trunk/geninitrd
Log:
- splash generations moved to function
- create only /init on initramfs due need to keep pid=1
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Fri Nov 2 18:16:10 2007
@@ -543,6 +543,7 @@
local n
for n in $PRESCSIMODS; do
if [ "X$n" = "Xunknown" ]; then
+ debug "Finding SCSI modules using scsi_hostadapter"
local mod scsimodules=$(modprobe_conf | awk '/scsi_hostadapter/ && ! /^[\t ]*#/ { print $3; }')
for mod in $scsimodules; do
# for now allow scsi modules to come from anywhere. There are some
@@ -1306,6 +1307,10 @@
# We don't need this directory, so let's save space
rm -rf "$MNTPOINT"/lost+found
+> "$RCFILE"
+chmod a+rx "$RCFILE"
+ln -s linuxrc $MNTIMAGE/init
+
inst_d /{lib,bin,etc,dev,loopfs,var}
modules_install "$MODULES"
@@ -1317,8 +1322,6 @@
mknod "$MNTIMAGE/dev/zero" c 1 5
inst_d /dev/pts /dev/shm
-ln -s /linuxrc $MNTIMAGE/init
-
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
@@ -1488,6 +1491,56 @@
EOF
}
+initrd_gen_bootsplash() {
+ local target="$1"
+
+ if [ ! -x /bin/splash.bin ]; then
+ echo >&2 "Failed to execute /bin/splash.bin. Is bootsplash package installed?"
+ elif [ -z "$THEME" ]; then
+ echo >&2 "Please configure your /etc/sysconfig/bootsplash first."
+ echo >&2 "Generating bootsplashes skipped."
+ else
+ if [ -n "$BOOT_SPLASH_RESOLUTIONS" ]; then
+ for res in $BOOT_SPLASH_RESOLUTIONS; do
+ if [ -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" ]; then
+ /bin/splash.bin -s -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" >> "$target" && \
+ debug "Added $res $THEME theme to initrd."
+ else
+ echo >&2 "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg doesn't exist, skipped"
+ fi
+ done
+ else
+ echo >&2 "No BOOT_SPLASH_RESOLUTIONS specified in /etc/sysconfig/bootsplash."
+ echo >&2 "Not adding bootsplash to initrd."
+ fi
+ fi
+}
+
+initrd_gen_fbsplash() {
+ local target="$1"
+
+ if [ ! -x /usr/bin/splash_geninitramfs ]; then
+ echo >&2 "Failed to execute /usr/bin/splash_geninitramfs. Is splashutils package installed?"
+ elif [ -z "$SPLASH_THEME" ]; then
+ echo >&2 "Please configure your /etc/sysconfig/fbsplash first."
+ echo >&2 "Generating fbsplashes skipped."
+ else
+ if [ -n "$FB_SPLASH_RESOLUTIONS" ]; then
+ for res in $FB_SPLASH_RESOLUTIONS; do
+ if [ -f "/etc/splash/$SPLASH_THEME/$res.cfg" ]; then
+ /usr/bin/splash_geninitramfs -a $target -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"
+ fi
+ done
+ else
+ echo >&2 "No FB_SPLASH_RESOLUTIONS specified in /etc/sysconfig/fbsplash."
+ echo >&2 "Not adding fbsplash to initramfs."
+ fi
+ fi
+}
+
# Generates /dev nodes based on /proc/partitions information.
# Needs /proc mounted.
# Can be called multiple times.
@@ -1809,40 +1862,44 @@
fi
EOF
- busybox_applet switch_root
add_linuxrc <<-EOF
- if [ "\$device" = '/dev/no_partition_found' ]; then
- device="$rootdev"
+ rootdev=$rootdev
+ rootfs=$rootFs
+ EOF
+
+ add_linuxrc <<-'EOF'
+ if [ "$device" = '/dev/no_partition_found' ]; then
+ device=$rootdev
fi
- mount -t $rootFs -r \$device /newroot
- init="\$(busybox awk ' /init=\// { gsub(/.*init=/,NIL,\$0); gsub(/ .*/,NIL,\$0); print \$0; } ' /proc/cmdline )"
- if [ -z "\$init" -o ! -x "/newroot\$init" ]; then
+ mount -t $rootfs -r $device /newroot
+ init="$(echo "$CMDLINE" | busybox awk '/init=\// { gsub(/.*init=/,NIL,$0); gsub(/ .*/,NIL,$0); print }')"
+ if [ -z "$init" -o ! -x "/newroot$init" ]; then
init=/sbin/init
fi
EOF
- umount_all
- add_linuxrc <<-EOF
- exec switch_root /newroot \$init
- echo "Error ! initramfs should not reach this place."
+ umount_all
+ busybox_applet switch_root
+ add_linuxrc <<-'EOF'
+ exec switch_root /newroot $init
+
+ echo "Error! initramfs should not reach this place."
echo "It probably means you've got old version of busybox, with broken"
echo "initramfs support. Trying to boot anyway, but won't promise anything."
- exec chroot /newroot \$init
+ exec chroot /newroot $init
- echo "Failed to chroot !"
+ echo "Failed to chroot!"
EOF
- # we need real file, not symlink
- rm -f $MNTIMAGE/init
- cp -a $MNTIMAGE/linuxrc $MNTIMAGE/init
+ # 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
else
# other than initramfs
umount_all
fi
-chmod +x "$RCFILE"
-
(cd "$MNTIMAGE"; tar cf - .) | (cd "$MNTPOINT"; tar xf -)
case "$INITRDFS" in
@@ -1889,49 +1946,11 @@
fi
if is_yes "$BOOT_SPLASH"; then
- if [ ! -x /bin/splash.bin ]; then
- echo >&2 "Failed to execute /bin/splash.bin. Is bootsplash package installed?"
- elif [ -z "$THEME" ]; then
- echo >&2 "Please configure your /etc/sysconfig/bootsplash first."
- echo >&2 "Generating bootsplashes skipped."
- else
- if [ -n "$BOOT_SPLASH_RESOLUTIONS" ]; then
- for res in $BOOT_SPLASH_RESOLUTIONS; do
- if [ -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" ]; then
- /bin/splash.bin -s -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" >> "$target" && \
- debug "Added $res $THEME theme to initrd."
- else
- echo >&2 "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg doesn't exist, skipped"
- fi
- done
- else
- echo >&2 "No BOOT_SPLASH_RESOLUTIONS specified in /etc/sysconfig/bootsplash."
- echo >&2 "Not adding bootsplash to initrd."
- fi
- fi
+ initrd_gen_bootsplash "$target"
fi
if is_yes "$FB_SPLASH"; then
- if [ ! -x /usr/bin/splash_geninitramfs ]; then
- echo >&2 "Failed to execute /usr/bin/splash_geninitramfs. Is splashutils package installed?"
- elif [ -z "$SPLASH_THEME" ]; then
- echo >&2 "Please configure your /etc/sysconfig/fbsplash first."
- echo >&2 "Generating fbsplashes skipped."
- else
- if [ -n "$FB_SPLASH_RESOLUTIONS" ]; then
- for res in $FB_SPLASH_RESOLUTIONS; do
- if [ -f "/etc/splash/$SPLASH_THEME/$res.cfg" ]; then
- /usr/bin/splash_geninitramfs -a $target -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"
- fi
- done
- else
- echo >&2 "No FB_SPLASH_RESOLUTIONS specified in /etc/sysconfig/fbsplash."
- echo >&2 "Not adding fbsplash to initramfs."
- fi
- fi
+ initrd_gen_fbsplash "$target"
fi
rm -rf "$MNTIMAGE" "$MNTPOINT" "$IMAGE"
More information about the pld-cvs-commit
mailing list