SVN: geninitrd/trunk: geninitrd mod-blkid.sh mod-dmraid.sh mod-luks.sh mod-lvm.sh mod-md.sh mod-mult...
glen
glen at pld-linux.org
Fri Apr 3 00:18:29 CEST 2009
Author: glen
Date: Fri Apr 3 00:18:29 2009
New Revision: 10280
Modified:
geninitrd/trunk/geninitrd
geninitrd/trunk/mod-blkid.sh
geninitrd/trunk/mod-dmraid.sh
geninitrd/trunk/mod-luks.sh
geninitrd/trunk/mod-lvm.sh
geninitrd/trunk/mod-md.sh
geninitrd/trunk/mod-multipath.sh
geninitrd/trunk/mod-udev.sh
Log:
- setup modules _after_ parsing command-line args
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Fri Apr 3 00:18:29 2009
@@ -15,6 +15,8 @@
. /lib/geninitrd/functions
. /etc/sysconfig/system
+# list of geninitrd modules which need setup routine after commandline args parsing
+GENINITRD_MODS=""
COMPRESS=yes
USE_SUSPEND=yes
USE_TUXONICE=no
@@ -114,6 +116,31 @@
return 1
}
+# loads geninitrd modules
+geninitrd_load_mods() {
+ local mod
+ for mod in "$@"; do
+ if [ ! -f /lib/geninitrd/mod-$mod.sh ]; then
+ die "$mod geninitrd module can't be loaded"
+ fi
+ . /lib/geninitrd/mod-$mod.sh
+
+ if type setup_mod_$mod > /dev/null; then
+ # add to list which need init
+ GENINITRD_MODS="$GENINITRD_MODS $mod"
+ fi
+ done
+}
+
+# setup geninitrd modules
+geninitrd_setup_mods() {
+ local mod
+
+ for mod in $GENINITRD_MODS; do
+ eval setup_mod_$mod
+ done
+}
+
# append text to /linuxrc
# takes STDIN as input
add_linuxrc() {
@@ -1022,27 +1049,12 @@
die "You need to be root to generate initrd"
fi
-# IDE addon
-. /lib/geninitrd/mod-ide.sh
-# cryptsetup luks addon
-. /lib/geninitrd/mod-luks.sh
-# dm-multipath addon
-. /lib/geninitrd/mod-multipath.sh
-# dmraid addon
-. /lib/geninitrd/mod-dmraid.sh
-# LVM addon
-. /lib/geninitrd/mod-lvm.sh
-# md addon
-. /lib/geninitrd/mod-md.sh
-# blkid addon
-. /lib/geninitrd/mod-blkid.sh
-# udev addon
-. /lib/geninitrd/mod-udev.sh
-
if [ -r /etc/sysconfig/geninitrd ]; then
. /etc/sysconfig/geninitrd
fi
+geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev
+
# backwards compatible
if [ "$USE_SUSPEND2" ]; then
USE_TUXONICE=$USE_SUSPEND2
@@ -1160,11 +1172,11 @@
shift
;;
--fs=*)
- warn "Warning: --fs option is obsoleted. Use --initrdfs instead"
+ warn "--fs option is obsoleted. Use --initrdfs instead"
INITRDFS=${1#--fs=}
;;
--fs)
- warn "Warning: --fs option is obsoleted. Use --initrdfs instead"
+ warn "--fs option is obsoleted. Use --initrdfs instead"
INITRDFS=$2
shift
;;
@@ -1201,13 +1213,29 @@
exit 1
fi
-if [ ! -f /boot/vmlinuz-"$kernel" ]; then
- warn "/boot/vmlinuz-$kernel doesn't exist, is your /boot mounted?"
+if [ -d /usr/lib64 ]; then
+ _lib=lib64
+else
+ _lib=lib
fi
+initrd_dir=/usr/$_lib/initrd
kernel_version=$(echo "$kernel" | awk -F. '{print sprintf("%03d%03d",$1,$2)}')
kernel_version_long=$(echo "$kernel" | awk -F. '{print sprintf("%03d%03d%03d",$1,$2,$3)}')
+debug "# $RCSID"
+debug "Using _lib: $_lib"
+debug "Using initrd_dir: $initrd_dir"
+
+busybox=$(find_tool $initrd_dir/initrd-busybox /bin/initrd-busybox) || die "Couldn't find busybox suitable for initrd"
+
+# we setup mods after parsing command line args
+geninitrd_setup_mods
+
+if [ ! -f /boot/vmlinuz-"$kernel" ]; then
+ warn "/boot/vmlinuz-$kernel doesn't exist, is your /boot mounted?"
+fi
+
if [ -z "$INITRDFS" ]; then
if [ -z "$FS" ]; then
# default value
@@ -1294,17 +1322,6 @@
warn "/proc filesystem not mounted, may cause wrong results or failure."
fi
-if [ -d /usr/lib64 ]; then
- _lib=lib64
-else
- _lib=lib
-fi
-
-initrd_dir=/usr/$_lib/initrd
-debug "# $RCSID"
-debug "Using _lib: $_lib"
-debug "Using initrd_dir: $initrd_dir"
-
cache_modprobe_conf
for n in $PREMODS; do
@@ -1369,7 +1386,6 @@
mknod "$DESTDIR/dev/null" c 1 3
mknod "$DESTDIR/dev/zero" c 1 5
-busybox=$(find_tool $initrd_dir/initrd-busybox /bin/initrd-busybox) || die "Couldn't find busybox suitable for initrd"
inst_exec $busybox /bin/initrd-busybox
ln -s initrd-busybox $DESTDIR/bin/sh
# for older busyboxes who had /bin/busybox as EXEPATH
Modified: geninitrd/trunk/mod-blkid.sh
==============================================================================
--- geninitrd/trunk/mod-blkid.sh (original)
+++ geninitrd/trunk/mod-blkid.sh Fri Apr 3 00:18:29 2009
@@ -5,12 +5,16 @@
# true if we should parse UUID= or LABEL= for root parameter
have_blkid=no
-blkid=$(find_tool $initrd_dir/blkid /sbin/initrd-blkid)
-if [ -x "$blkid" ]; then
- USE_BLKID=yes
-else
- USE_BLKID=no
-fi
+# setup geninitrd module
+# @access public
+setup_mod_blkid() {
+ blkid=$(find_tool $initrd_dir/blkid /sbin/initrd-blkid)
+ if [ -x "$blkid" ]; then
+ USE_BLKID=yes
+ else
+ USE_BLKID=no
+ fi
+}
# generate initrd fragment
# @access public
Modified: geninitrd/trunk/mod-dmraid.sh
==============================================================================
--- geninitrd/trunk/mod-dmraid.sh (original)
+++ geninitrd/trunk/mod-dmraid.sh Fri Apr 3 00:18:29 2009
@@ -5,16 +5,20 @@
# if we should init dmraid at boot
have_dmraid=no
-dmraid=$(find_tool $initrd_dir/dmraid /sbin/dmraid-initrd)
-if [ -x /sbin/dmraid -a -x "$dmraid" ]; then
- USE_DMRAID=yes
-else
- USE_DMRAID=no
-fi
-
-if [ "$kernel_version" -lt "002006" ]; then
- USE_DMRAID=no
-fi
+# setup geninitrd module
+# @access public
+setup_mod_dmraid() {
+ dmraid=$(find_tool $initrd_dir/dmraid /sbin/dmraid-initrd)
+ if [ -x /sbin/dmraid -a -x "$dmraid" ]; then
+ USE_DMRAID=yes
+ else
+ USE_DMRAID=no
+ fi
+
+ if [ "$kernel_version" -lt "002006" ]; then
+ USE_DMRAID=no
+ fi
+}
# return true if dmraid is set on $devpath
# @param string $devpath device node to be examined
Modified: geninitrd/trunk/mod-luks.sh
==============================================================================
--- geninitrd/trunk/mod-luks.sh (original)
+++ geninitrd/trunk/mod-luks.sh Fri Apr 3 00:18:29 2009
@@ -6,16 +6,20 @@
# and we should init cryptsetup luks at boot
have_luks=no
-cryptsetup=$(find_tool $initrd_dir/cryptsetup /sbin/cryptsetup-initrd)
-if [ -x /sbin/cryptsetup -a -x "$cryptsetup" ]; then
- USE_LUKS=yes
-else
- USE_LUKS=no
-fi
-
# device to use for name for cryptsetup luks
LUKSDEV=""
+# setup geninitrd module
+# @access public
+setup_mod_luks() {
+ cryptsetup=$(find_tool $initrd_dir/cryptsetup /sbin/cryptsetup-initrd)
+ if [ -x /sbin/cryptsetup -a -x "$cryptsetup" ]; then
+ USE_LUKS=yes
+ else
+ USE_LUKS=no
+ fi
+}
+
# return true if node is cryptsetup luks encrypted
# @param string $node device node to be examined
# @access public
Modified: geninitrd/trunk/mod-lvm.sh
==============================================================================
--- geninitrd/trunk/mod-lvm.sh (original)
+++ geninitrd/trunk/mod-lvm.sh Fri Apr 3 00:18:29 2009
@@ -19,17 +19,28 @@
# Values: 1|2
LVMTOOLSVERSION=
-lvm=$(find_tool $initrd_dir/lvm /sbin/initrd-lvm)
-if [ -x /sbin/lvm -a -x "$lvm" ]; then
- USE_LVM=yes
-else
- USE_LVM=no
-fi
-
# LVM devices that should not be included in vgscan on initrd.
# @internal
lvm_ignore_devices=''
+# setup geninitrd module
+# @access public
+setup_mod_lvm() {
+ lvm=$(find_tool $initrd_dir/lvm /sbin/initrd-lvm)
+ if [ -x /sbin/lvm -a -x "$lvm" ]; then
+ USE_LVM=yes
+ else
+ USE_LVM=no
+ fi
+
+ if [ -z "$LVMTOOLSVERSION" ]; then
+ LVMTOOLSVERSION=$(LC_ALL=C $lvm vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
+ if [ -z "$LVMTOOLSVERSION" ]; then
+ die "Can't determine LVM tools version. Please set LVMTOOLSVERSION and rerun $PROGRAM."
+ fi
+ fi
+}
+
# return true if node is lvm node
# @param string $node device node to be examined
# @access public
@@ -77,13 +88,6 @@
die "root on LVM but /sbin/lvdisplay or /sbin/pvdisplay not found. Please install lvm(2) and lvm(2)-initrd package and rerun $PROGRAM."
fi
- if [ -z "$LVMTOOLSVERSION" ]; then
- LVMTOOLSVERSION=$(LC_ALL=C $lvm vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
- if [ -z "$LVMTOOLSVERSION" ]; then
- die "Can't determine LVM tools version. Please set LVMTOOLSVERSION and rerun $PROGRAM."
- fi
- fi
-
local vg=$(find_lvm_vg "$devpath")
debug "LVM VG for $devpath: $vg"
VGVOLUMES=$(echo $VGVOLUMES $vg | tr ' ' '\n' | sort -u)
Modified: geninitrd/trunk/mod-md.sh
==============================================================================
--- geninitrd/trunk/mod-md.sh (original)
+++ geninitrd/trunk/mod-md.sh Fri Apr 3 00:18:29 2009
@@ -5,16 +5,20 @@
# if we should init md (softraid) at boot
have_md=no
-mdassemble=$(find_tool $initrd_dir/mdassemble /sbin/initrd-mdassemble)
-if [ -x /sbin/mdadm -a -x "$mdassemble" ]; then
- USE_MD=yes
-else
- USE_MD=no
-fi
-
# XXX wtf is this for?
USERAIDSTART=yes
+# setup geninitrd module
+# @access public
+setup_mod_md() {
+ mdassemble=$(find_tool $initrd_dir/mdassemble /sbin/initrd-mdassemble)
+ if [ -x /sbin/mdadm -a -x "$mdassemble" ]; then
+ USE_MD=yes
+ else
+ USE_MD=no
+ fi
+}
+
# return true if mdadm is set on $devpath
# @param string $devpath device node to be examined
# @access public
Modified: geninitrd/trunk/mod-multipath.sh
==============================================================================
--- geninitrd/trunk/mod-multipath.sh (original)
+++ geninitrd/trunk/mod-multipath.sh Fri Apr 3 00:18:29 2009
@@ -5,15 +5,19 @@
# if we should init dm-multipath at boot
have_multipath=no
-if [ -x /sbin/multipath ]; then
- USE_MULTIPATH=yes
-else
- USE_MULTIPATH=no
-fi
-
# dm-multipath wwid which is used for rootfs
MPATH_WWID=
+# setup geninitrd module
+# @access public
+setup_mod_multipath() {
+ if [ -x /sbin/multipath ]; then
+ USE_MULTIPATH=yes
+ else
+ USE_MULTIPATH=no
+ fi
+}
+
# return true if node is multipath controlled
# @param string $node device node to be examined
# @access public
Modified: geninitrd/trunk/mod-udev.sh
==============================================================================
--- geninitrd/trunk/mod-udev.sh (original)
+++ geninitrd/trunk/mod-udev.sh Fri Apr 3 00:18:29 2009
@@ -7,15 +7,19 @@
# - make udev start before insmods
# - make proper use of USE_UDEV - don't copy rules if USE_UDEV is off no!
-udevd=$(find_tool $initrd_dir/udevd /sbin/initrd-udevd)
-udevadm=$(find_tool $initrd_dir/initrd-udevadm /sbin/initrd-udevadm)
-
-if [ "$kernel_version" -ge "002006" -a -x "$udevd" -a -a -x "$udevadm" -f /etc/udev/udev.conf ]; then
- USE_UDEV=yes
- . /etc/udev/udev.conf
-else
- USE_UDEV=no
-fi
+# setup geninitrd module
+# @access public
+setup_mod_udev() {
+ udevd=$(find_tool $initrd_dir/udevd /sbin/initrd-udevd)
+ udevadm=$(find_tool $initrd_dir/initrd-udevadm /sbin/initrd-udevadm)
+
+ if [ "$kernel_version" -ge "002006" -a -x "$udevd" -a -x "$udevadm" -a -f /etc/udev/udev.conf ]; then
+ USE_UDEV=yes
+ . /etc/udev/udev.conf
+ else
+ USE_UDEV=no
+ fi
+}
# generate initrd fragment
# @access public
More information about the pld-cvs-commit
mailing list