SVN: geninitrd/trunk/geninitrd
glen
glen at pld-linux.org
Mon Nov 5 22:05:52 CET 2007
Author: glen
Date: Mon Nov 5 22:05:52 2007
New Revision: 8993
Modified:
geninitrd/trunk/geninitrd
Log:
- move functions start of the script
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Mon Nov 5 22:05:52 2007
@@ -79,19 +79,6 @@
# dm-multipath id which is used for rootfs
MULTIPATH_ID=
-if [ -f /etc/udev/udev.conf -a -x /sbin/initrd-udevd ]; then
- USE_UDEV=yes
- . /etc/udev/udev.conf
-fi
-
-if [ -x /sbin/dmraid-initrd ]; then
- USE_DMRAID=yes
-fi
-
-if [ -x /sbin/multipath ]; then
- USE_MULTIPATH=yes
-fi
-
usage() {
uname_r=$(uname -r)
echo "usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
@@ -980,803 +967,816 @@
done
}
-if [ -r /etc/sysconfig/geninitrd ]; then
- . /etc/sysconfig/geninitrd
-fi
-
-if [ -r /etc/sysconfig/bootsplash ]; then
- . /etc/sysconfig/bootsplash
-fi
-
-if [ -r /etc/sysconfig/fbsplash ]; then
- . /etc/sysconfig/fbsplash
-fi
-
-if [ ! -x /bin/initrd-busybox ]; then
- die "/bin/initrd-busybox is missing!"
-fi
-
-# backwards compatible
-if [ "$USE_SUSPEND2" ]; then
- USE_TUXONICE=$USE_SUSPEND2
- echo >&2 "USE_SUSPEND2 is deprecated, use USE_TUXONICE now instead."
-fi
+initrd_gen_suspend() {
+ if [ ! -x /usr/${_lib}/suspend/resume -a ! -x /usr/sbin/resume ]; then
+ 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
+ inst $resume_dev /dev
+ inst /etc/suspend.conf /etc/suspend.conf
+ if [ -x /usr/${_lib}/suspend/resume ]; then
+ inst /usr/${_lib}/suspend/resume /bin/resume
+ else
+ inst /usr/sbin/resume /bin/resume
+ fi
+ echo "resume" | add_linuxrc
+}
-while [ $# -gt 0 ]; do
- case $1 in
- --fstab=*)
- fstab=${1#--fstab=}
- ;;
- --fstab)
- fstab=$2
- shift
- ;;
- --modules-conf=*)
- modulefile=${1#--modules-conf=}
- ;;
- --modules-conf)
- modulefile=$2
- shift
- ;;
- --use-raidstart|--with-raidstart)
- USERAIDSTART=yes
- ;;
- --without-raidstart)
- USERAIDSTART=no
- ;;
- --use-insmod-static|--with-insmod-static)
- USEINSMODSTATIC=yes
- ;;
- --without-insmod-static)
- USEINSMODSTATIC=no
- ;;
- --with-bootsplash)
- BOOT_SPLASH=yes
- ;;
- --without-bootsplash)
- BOOT_SPLASH=no
- ;;
- --with-fbsplash)
- FB_SPLASH=yes
- ;;
- --without-fbsplash)
- FB_SPLASH=no
- ;;
- --with-suspend)
- USE_SUSPEND=yes
- ;;
- --without-suspend)
- USE_SUSPEND=no
- ;;
- --with-suspend2 | --with-tuxonice)
- USE_TUXONICE=yes
- ;;
- --without-suspend2 | --without-tuxonice)
- USE_TUXONICE=no
- ;;
- --lvmtoolsversion=|--lvmversion=)
- LVMTOOLSVERSION="`echo $1 | awk -F= '{print $2;}'`"
- ;;
- --lvmtoolsversion|--lvmversion)
- LVMTOOLSVERSION=$2
- shift
- ;;
- --without-udev)
- USE_UDEV=no
- ;;
- --with-udev)
- USE_UDEV=yes
- ;;
- --without-dmraid)
- USE_DMRAID=no
- ;;
- --without-multipath)
- USE_MULTPATH=no
- ;;
- --with=*)
- BASICMODULES="$BASICMODULES ${1#--with=}"
- ;;
- --with)
- BASICMODULES="$BASICMODULES $2"
- shift
- ;;
- --version)
- echo "$PROGRAM: version $VERSION"
- exit 0
- ;;
- -v)
- verbose=-v
- ;;
- --nocompress)
- COMPRESS=no
- ;;
- --ifneeded)
- ifneeded=1
- ;;
- -f)
- force=1
- ;;
- --preload=*)
- PREMODS="$PREMODS ${1#--preload=}"
- ;;
- --preload)
- PREMODS="$PREMODS $2"
- shift
- ;;
- --fs=*)
- echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs instead"
- INITRDFS=${1#--fs=}
- ;;
- --fs)
- echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs instead"
- INITRDFS=$2
- shift
- ;;
- --initrdfs=*)
- INITRDFS=${1#--initrdfs=}
- ;;
- --initrdfs)
- INITRDFS=$2
- shift
- ;;
- --image-version)
- img_vers=yes
- ;;
- --ide-only-root)
- ide_only_root="yes"
- ;;
- *)
- if [ -z "$target" ]; then
- target="$1"
- elif [ -z "$kernel" ]; then
- kernel="$1"
- else
- usage
+initrd_gen_tuxonice() {
+ mount_sys
+ add_linuxrc <<-'EOF'
+ if [ "$(echo "$CMDLINE" | awk ' /resume2=/ { print "yes"; } ' /proc/cmdline)" = "yes" ]; then
+ [ -e /proc/suspend2/do_resume ] && echo > /proc/suspend2/do_resume
+ [ -e /sys/power/suspend2/do_resume ] && echo > /sys/power/suspend2/do_resume
+ [ -e /sys/power/tuxonice/do_resume ] && echo > /sys/power/tuxonice/do_resume
fi
- ;;
- esac
+ EOF
+}
- shift
-done
+initrd_gen_udev() {
+ debug "Setting up udev..."
+ inst_d /sbin /etc/udev
-if [ -z "$target" -o -z "$kernel" ]; then
- usage
-fi
+ if [ ! -x /sbin/initrd-udevd ]; then
+ die "/sbin/initrd-udevd not present"
+ fi
-pack_version="`echo "$kernel"|awk -F. '{print sprintf("%03d%03d",$1,$2)}'`"
-pack_version_long="`echo "$kernel"|awk -F. '{print sprintf("%03d%03d%03d",$1,$2,$3)}'`"
+ inst /sbin/initrd-udevd /sbin/udevd
+ inst /etc/udev/udev.conf /etc/udev/udev.conf
-if [ -z "$INITRDFS" ]; then
- if [ -z = "$FS" ]; then
- # default value
- if [ "$pack_version" -ge "002005" ]; then
- INITRDFS="initramfs"
- else
- INITRDFS="rom"
- fi
- else
- echo >&2 "Warning: FS configuration options is obsoleted. Use INITRDFS instead"
- INITRDFS="$FS"
+ mount_dev
+ mount_sys
+ add_linuxrc <<-'EOF'
+ : 'Starting udev'
+ /sbin/udevd --daemon
+ EOF
+ if is_yes "$PROBESTATICMODS"; then
+ inst /sbin/initrd-udevtrigger /sbin/udevtrigger
+ inst /sbin/initrd-udevsettle /sbin/udevsettle
+ add_linuxrc <<-'EOF'
+ /sbin/udevtrigger
+ /sbin/udevsettle
+ EOF
fi
-fi
-if [ "$pack_version" -lt "002006" ]; then
- USE_UDEV=no
- USE_DMRAID=no
-fi
+ busybox_applet killall
+ add_linuxrc <<-'EOF'
+ killall udevd
+ EOF
+}
-if [ "$pack_version" -ge "002005" ]; then
- modext=".ko"
- insmod="insmod"
-fi
+initrd_gen_multipath() {
+ inst_d /sbin /lib/udev
+ inst_exec /sbin/kpartx /sbin
+ inst_exec /sbin/multipath /sbin
+ # for udev callouts
+ inst_exec /sbin/scsi_id /lib/udev
+ 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
+ fi
-if is_yes "$USEINSMODSTATIC"; then
- insmod="insmod.static"
- INSMOD="/sbin/insmod.static"
- if [ "$pack_version" -lt "002005" -a -f /sbin/insmod.static.modutils ]; then
- INSMOD="/sbin/insmod.static.modutils"
- fi
- if [ ! -f "$INSMOD" ]; then
- die "insmod.static requested but /sbin/insmod.static not found!"
- fi
-fi
-
-case "$INITRDFS" in
- ext2)
- if [ ! -x /sbin/mke2fs ]; then
- die "/sbin/mke2fs is missing"
- fi
- ;;
- rom|romfs)
- if [ ! -x /sbin/genromfs ]; then
- die "/sbin/genromfs is missing"
- fi
- ;;
- cram|cramfs)
- if [ ! -x /sbin/mkcramfs ]; then
- die "/sbin/mkcramfs is missing"
- fi
- ;;
- initramfs)
- if [ ! -x /bin/cpio ]; then
- die "/bin/cpio is missing"
- fi
- if [ ! -x /usr/bin/find ]; then
- die "/usr/bin/find is missing"
- fi
- ;;
- *)
- die "Filesystem $INITRDFS on initrd is not supported"
- ;;
-esac
-
-if [ -n "$img_vers" ]; then
- target="$target-$kernel"
-fi
-
-if [ -z "$force" -a -f "$target" ]; then
- die "$target already exists."
-fi
+ mount_dev
+ initrd_gen_devices
-if [ ! -d "/lib/modules/$kernel" ]; then
- die "/lib/modules/$kernel is not a directory."
-fi
+ mount_sys
+ echo "export multipath_id=$MULTIPATH_ID" | add_linuxrc
+ add_linuxrc <<-'EOF'
+ debugshell
+ /sbin/multipath -v 0 $multipath_id
-if is_yes "$USE_SUSPEND" && is_yes "$USE_TUXONICE"; then
- die "Tuxonice shouldn't be used in parallel with mainline suspend!."
-fi
+ for a in /dev/mapper/*; do
+ [ $a = /dev/mapper/control ] && continue
+ /sbin/kpartx -a $a
+ done
+ debugshell
+ EOF
+}
-if is_yes "$FB_SPLASH"; then
- if is_yes "$BOOT_SPLASH"; then
- die "You can't use both bootsplash and fbsplash! Please choose one."
- elif [ "$INITRDFS" != "initramfs" ]; then
- die "FB_SPLASH works only if INITRDFS is initramfs!."
+initrd_gen_dmraid() {
+ if [ ! -x /sbin/dmraid-initrd ]; then
+ die "/sbin/dmraid-initrd is missing!"
fi
-fi
-if [ ! -f /proc/mounts ]; then
- echo >&2 "WARNING: /proc filesystem not mounted, may cause wrong results or failure."
-fi
+ inst_d /sbin
+ inst /sbin/dmraid-initrd /sbin/dmraid
-if [ -d /usr/lib64 ]; then
- _lib=lib64
-else
- _lib=lib
-fi
-debug "_lib: $_lib"
+ mount_dev
+ mount_sys
+ initrd_gen_devices
+ add_linuxrc <<-EOF
+ # 2 secs was enough for my system to initialize. but really this is udev issue?
+ usleep 2000000
+ : 'Activating Device-Mapper RAID(s)'
+ /sbin/dmraid -ay -i
-cache_modprobe_conf
+ debugshell
+ EOF
+}
-for n in $PREMODS; do
- findmodule "$n"
-done
+initrd_gen_bootsplash() {
+ local target="$1"
-# allow forcing loading SCSI and/or IDE modules
-if is_yes "$ADDSCSI"; then
- find_modules_scsi
-fi
+ debug "generating bootsplash"
+ 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
+}
-if is_yes "$ADDIDE"; then
- find_modules_ide
-fi
+initrd_gen_fbsplash() {
+ debug "generating fbsplash"
-find_root "$fstab" || exit
-debug "Using $rootdev as device for rootfs"
+ if [ ! -x /usr/bin/splash_geninitramfs ]; then
+ echo >&2 "Failed to execute /usr/bin/splash_geninitramfs. Is splashutils package installed?"
+ return
+ fi
-find_modules_for_device "$rootdev"
-[ -n "$rootdev_add" ] && find_modules_for_device "$rootdev_add"
+ if [ -z "$SPLASH_THEME" ]; then
+ echo >&2 "Please configure your /etc/sysconfig/fbsplash first."
+ echo >&2 "Generating fbsplashes skipped."
+ return
+ fi
-findmodule "-$rootFs"
+ if [ -z "$FB_SPLASH_RESOLUTIONS" ]; then
+ echo >&2 "No FB_SPLASH_RESOLUTIONS specified in /etc/sysconfig/fbsplash."
+ echo >&2 "Not adding fbsplash to initramfs."
+ return
+ fi
-for n in $BASICMODULES; do
- findmodule "$n"
-done
+ 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 && \
+ debug "Added $res $SPLASH_THEME theme to initramfs."
+ else
+ echo >&2 "/etc/splash/$SPLASH_THEME/$res.cfg doesn't exist, skipped"
+ fi
+ done
+}
-if is_yes "$USE_TUXONICE"; then
- findmodule "-lzf"
-fi
+# Generates /dev nodes based on /proc/partitions information.
+# Needs /proc mounted.
+# Can be called multiple times.
+initrd_gen_devices() {
+ if is_yes "$proc_partitions"; then
+ return
+ fi
+ proc_partitions=yes
-if is_yes "$FB_SPLASH"; then
- findmodule "-evdev"
-fi
+ mount_dev
+ add_linuxrc <<-'EOF'
+ : 'Making device nodes'
+ cat /proc/partitions | (
+ # ignore first two lines, header, empty line and process rest
+ read b; read b
-if [ -n "$ifneeded" -a -z "$MODULES" ]; then
- debug "No modules are needed -- not building initrd image."
- exit 0
-fi
-debug "Using modules: $MODULES"
+ while read major minor blocks dev rest; do
+ node=/dev/$dev
+ mkdir -p ${node%/*}
+ mknod $node b $major $minor
+ done
+ )
+ EOF
+}
-MNTIMAGE="`mktemp -d /tmp/initrd.XXXXXX`"
-IMAGE="`mktemp -u /tmp/initrd.img-XXXXXX`"
-MNTPOINT="`mktemp -d /tmp/initrd.mnt-XXXXXX`"
-RCFILE="$MNTIMAGE/linuxrc"
+initrd_gen_md() {
+ debug "Setting up mdadm..."
<<diff output has been trimmed to 500 lines, 1025 line(s) remained.>>
More information about the pld-cvs-commit
mailing list