# by PLD Linux Team
#
# based on mkinitrd from RedHat
+#
+# TODO:
+# - make udev start before insomds
+# - make proper use of USE_UDEV - don't copy fules if USE_UDEV is off no!
+# - sanitize - one mounting of /proc and /sys at the begining and one umount at the end!
+# - chekup and test and ready to go!
+#
RCSID='$Id$'
PATH=/sbin:$PATH
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
+# defualt we don't use udev to make nodes for static modules, as per default
+# PLD loads the modules needed to mount and boot
+PROBESTATICMODULES=no
# is /dev on tmpfs. internal variable
tmpfs_dev=
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)"
. /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
--without-bootsplash)
BOOT_SPLASH="no"
;;
+ --without-fbsplash)
+ FB_SPLASH="no"
+ ;;
--without-suspend)
USE_SUSPEND="no";
;;
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"
fi
fi
+if is_yes "$FB_SPLASH"; then
+ if is_yes "$BOOT_SPLASH"; then
+ echo >&2 "You can't use both bootsplash and fbsplash! Please choose one."
+ exit 1
+ elif [ "$INITRDFS" != "initramfs" ]; then
+ echo >&2 "FB_SPLASH works only if INITRDFS is initramfs!."
+ exit 1
+ fi
+fi
+
if [ ! -f /proc/mounts ]; then
echo >&2 "WARNING: /proc filesystem not mounted, may cause wrong results or failure."
fi
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
mkdir -p $MNTIMAGE/sys
inst /sbin/initrd-udev $MNTIMAGE/sbin/udev
- ln -s udev $MNTIMAGE/sbin/udevstart
inst /etc/udev/udev.conf $MNTIMAGE/etc/udev/udev.conf
- ln -s udev $MNTIMAGE/sbin/hotplug
-
if is_yes "$USE_UDEV"; then
initrd_gen_tmpfs_dev >> "$s"
- cat >> "$s" <<-EOF
-mount -t proc none /proc
-mount -t sysfs none /sys
-: 'Starting udev'
-/sbin/udevstart
-echo -n /sbin/hotplug > /proc/sys/kernel/hotplug
-umount /proc
-umount /sys
-EOF
+ cat >> "$s" <<- 'EOF'
+ mount -t proc none /proc
+ mount -t sysfs none /sys
+ : 'Starting udev'
+ /sbin/udev
+ echo -n /sbin/hotplug > /proc/sys/kernel/hotplug
+ EOF
+ if is_yes "$PROBESTATICMODS"; then
+ inst /sbin/initrd-udevtrigger $MNTIMAGE/sbin/udevtrigger
+ inst /sbin/initrd-udevsettle $MNTIMAGE/sbin/udevsettle
+ cat >> "$s" <<- 'EOF'
+ /sbin/udevtrigger
+ /sbin/udevsettle
+ EOF
+ fi
+ cat >> "$s" <<- 'EOF'
+ umount /proc
+ umount /sys
+ EOF
fi
}
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"
+ # Parsing root parameter
+ # We support passing root as hda3 /dev/hda3 0303 0x0303
+ cat << 'EOF' >> "$s"
+set +x
+mount -t proc none /proc
+root="$(busybox awk -v prefix="root=" ' \
+function separate_root ( txt ) \
+{ \
+ gsub(/.*root=/,NIL,txt); \
+ gsub(/ .*/,NIL,txt); \
+ return txt \
+} \
+BEGIN { \
+ num_pattern = "[0-9][0-9][0-9][0-9]"; \
+ dev_pattern = "[hms][a-z][a-z]([0-9])+"; \
+ partition = "Metallica rocks!"; \
+ min = -1; maj = -1; \
+} \
+$0 ~ prefix "0x" num_pattern { sub(/root=0x/,"root="); } \
+$0 ~ prefix num_pattern { \
+ gsub(/.*root=/,NIL,partition); \
+ gsub(/ .*/,NIL,partition); \
+ partition = separate_root( $0 ); \
+ maj = sprintf("%d",substr(partition,1,2)); \
+ min = sprintf("%d",substr(partition,3)); \
+} \
+$0 ~ prefix "\/dev\/" dev_pattern { sub(/root=\/dev\//,"root="); } \
+$0 ~ prefix dev_pattern { \
+ partition = separate_root( $0 ); \
+} \
+$4 ~ partition { maj = $1; min = $2; } \
+$1 ~ maj && $2 ~ min { partition = $4; } \
+END { print sprintf("/dev/%s %d %d", partition, maj, min); }
+' /proc/cmdline /proc/partitions)"
+device=${root% * *}
+maj=${root#* }
+maj=${maj% *}
+min=${root#* * }
+set -x
+if [ ! -b $device ]; then
+ mknod $device b $maj $min
+fi
+EOF
+ cat << EOF >> "$s"
+mount -t $rootFs \$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
+ 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
fi
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
+fi
+
rm -rf "$MNTIMAGE" "$MNTPOINT" "$IMAGE"
# vim:ts=4:sw=4:noet:fdm=marker