]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
- handle initrd programs under %{_libdir}/initrd
authorElan Ruusamäe <glen@pld-linux.org>
Thu, 2 Apr 2009 21:19:58 +0000 (21:19 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Thu, 2 Apr 2009 21:19:58 +0000 (21:19 +0000)
svn-id: @10274

geninitrd
mod-dmraid.sh
mod-luks.sh
mod-lvm.sh
mod-md.sh

index c6ebaa64dbb0f4fe540095971c3fc06d5e897f55..23d7a08e8c6b432976c0d4cdcb3d208ae83c81fc 100755 (executable)
--- a/geninitrd
+++ b/geninitrd
@@ -104,6 +104,20 @@ die() {
        exit $rc
 }
 
+# find program from specified paths
+find_tool() {
+       local x
+       for x in "$@"; do
+               if [ -x "$x" ]; then
+                       echo $x
+                       debug "find_tool: found $x"
+                       return 0
+               fi
+       done
+       debug "find_tool: did not found any of: $@"
+       return 1
+}
+
 # append text to /linuxrc
 # takes STDIN as input
 add_linuxrc() {
@@ -217,12 +231,12 @@ busybox_applet() {
        local err=0
 
        if [ -z "$busybox_functions" ]; then
-               local tmp=$(/bin/initrd-busybox 2>&1)
+               local tmp=$($busybox 2>&1)
 
                # BusyBox v1.1.3 says applet not found if it's not called 'busybox'.
                if [[ "$tmp" = *applet\ not\ found* ]]; then
                        local t=$(mktemp -d)
-                       ln -s /bin/initrd-busybox $t/busybox
+                       ln -s $busybox $t/busybox
                        local tmp=$($t/busybox 2>&1)
                        rm -rf $t
                fi
@@ -734,14 +748,16 @@ initrd_gen_v86d() {
 }
 
 initrd_gen_udev() {
+       local udevd udevadm
+
        debug "Setting up udev..."
-       inst_d /sbin /etc/udev
 
-       if [ ! -x /sbin/initrd-udevd ]; then
-               die "/sbin/initrd-udevd not present"
-       fi
+       udevd=$(find_tool $initrd_dir/udevd /sbin/initrd-udevd) || die "Couldn't find udevd suitable for initrd"
+       udevadm=$(find_tool $initrd_dir/initrd-udevadm /sbin/initrd-udevadm) || die "Couldn't find udevadm suitable for initrd"
 
-       inst_exec /sbin/initrd-udevd /sbin/udevd
+       inst_d /sbin /etc/udev
+       inst_exec $udevd /sbin/udevd
+       inst_exec $udevadm /sbin/udevadm
        inst /etc/udev/udev.conf /etc/udev/udev.conf
 
        mount_dev
@@ -749,10 +765,6 @@ initrd_gen_udev() {
        add_linuxrc <<-'EOF'
                : 'Starting udev'
                /sbin/udevd --daemon
-       EOF
-
-       inst_exec /sbin/initrd-udevadm /sbin/udevadm
-       add_linuxrc <<-'EOF'
                /sbin/udevadm trigger
                /sbin/udevadm settle
        EOF
@@ -766,8 +778,6 @@ initrd_gen_stop_udevd() {
        EOF
 }
 
-
-
 initrd_gen_bootsplash() {
        local target="$1"
 
@@ -953,7 +963,11 @@ initrd_gen_nfs() {
 initrd_gen_blkid()
 {
        debug "Adding BLKID support to initrd"
-       inst_exec /sbin/initrd-blkid /bin/blkid
+
+       local blkid
+       blkid=$(find_tool $initrd_dir/blkid /sbin/initrd-blkid) || die "Couldn't find blkid suitable for initrd"
+
+       inst_exec $blkid /bin/blkid
        initrd_gen_devices
        add_linuxrc <<-'EOF'
                # if built with blkid change ROOT=LABEL=something into ROOT=/dev/somethingelse -
@@ -1087,10 +1101,6 @@ if [ -r /etc/sysconfig/geninitrd ]; then
        . /etc/sysconfig/geninitrd
 fi
 
-if [ ! -x /bin/initrd-busybox ]; then
-       die "/bin/initrd-busybox is missing!"
-fi
-
 # backwards compatible
 if [ "$USE_SUSPEND2" ]; then
        USE_TUXONICE=$USE_SUSPEND2
@@ -1352,8 +1362,11 @@ if [ -d /usr/lib64 ]; then
 else
        _lib=lib
 fi
+
+initrd_dir=/usr/$_lib/initrd
 debug "# $RCSID"
-debug "Using libdir: $_lib"
+debug "Using _lib: $_lib"
+debug "Using initrd_dir: $initrd_dir"
 
 cache_modprobe_conf
 
@@ -1419,9 +1432,11 @@ mknod "$DESTDIR/dev/console" c 5 1
 mknod "$DESTDIR/dev/null" c 1 3
 mknod "$DESTDIR/dev/zero" c 1 5
 
-inst_exec /bin/initrd-busybox /bin/initrd-busybox
+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
-ln -s initrd-busybox $DESTDIR/bin/busybox # for older busyboxes who had /bin/busybox as EXEPATH
+# for older busyboxes who had /bin/busybox as EXEPATH
+ln -s initrd-busybox $DESTDIR/bin/busybox
 
 add_linuxrc <<EOF
 #!/bin/sh
index 6db1024f881ab46bba771237f07a4f00ebb56773..50db976adfddddb3c7ef57d5b69a6065891ef88a 100644 (file)
@@ -5,7 +5,8 @@
 # if we should init dmraid at boot
 have_dmraid=no
 
-if [ -x /sbin/dmraid-initrd ]; then
+dmraid=$(find_tool $initrd_dir/dmraid /sbin/dmraid-initrd)
+if [ -x /sbin/dmraid -a -x "$dmraid" ]; then
        USE_DMRAID=yes
 else
        USE_DMRAID=no
@@ -59,12 +60,8 @@ find_modules_dmraid() {
 # generate initrd fragment for dmraid
 # @access      public
 initrd_gen_dmraid() {
-       if [ ! -x /sbin/dmraid-initrd ]; then
-               die "/sbin/dmraid-initrd is missing!"
-       fi
-
        inst_d /sbin
-       inst_exec /sbin/dmraid-initrd /sbin/dmraid
+       inst_exec $dmraid /sbin/dmraid
 
        mount_dev
        mount_sys
index 44dd705c572deb93c71abdaac1b68e13e200397c..1cfda62e637443f35ceab67286dcc230a3e11ddc 100644 (file)
@@ -6,7 +6,8 @@
 # and we should init cryptsetup luks at boot
 have_luks=no
 
-if [ -x /sbin/cryptsetup ]; then
+cryptsetup=$(find_tool $initrd_dir/cryptsetup /sbin/cryptsetup-initrd)
+if [ -x /sbin/cryptsetup -a -x "$cryptsetup" ]; then
        USE_LUKS=yes
 else
        USE_LUKS=no
@@ -78,12 +79,8 @@ find_modules_luks() {
 # generate initrd fragment for cryptsetup luks init
 # @access      public
 initrd_gen_luks() {
-       if [ ! -x /sbin/cryptsetup-initrd ]; then
-               die "/sbin/cryptsetup-initrd is missing!"
-       fi
-
        inst_d /bin
-       inst_exec /sbin/cryptsetup-initrd /bin/cryptsetup
+       inst_exec $cryptsetup /bin/cryptsetup
 
        mount_dev
        mount_sys
index fa8bc7638ea52406cb121963423236beff2529c6..d78b6d05e4db8a6aab7783a62cfd714d437f95e7 100644 (file)
@@ -19,7 +19,8 @@ VGVOLUMES=""
 # Values: 1|2
 LVMTOOLSVERSION=
 
-if [ -x /sbin/lvm ]; then
+lvm=$(find_tool $initrd_dir/lvm /sbin/initrd-lvm)
+if [ -x /sbin/lvm -a -x $lvm ]; then
        USE_LVM=yes
 else
        USE_LVM=no
@@ -72,12 +73,12 @@ find_modules_lvm() {
 
        debug "LVM: $devpath is LVM node"
 
-       if [ ! -f /sbin/initrd-lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ]; then
-               die "root on LVM but /sbin/initrd-lvm, /sbin/lvdisplay and /sbin/pvdisplay not found. Please install lvm(2) and lvm(2)-initrd package and rerun $PROGRAM."
+       if [ ! -x $lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ]; then
+               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 /sbin/initrd-lvm vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
+               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
@@ -118,7 +119,7 @@ find_modules_lvm() {
 initrd_gen_lvm() {
        debug "Adding LVM support to initrd"
        inst_d /tmp /newroot
-       inst_exec /sbin/initrd-lvm /bin/lvm.static
+       inst_exec $lvm /bin/lvm.static
 
        # always make /dev on tmpfs for LVM2
        if [ "$LVMTOOLSVERSION" = "2" ]; then
index c76ab1a5c7c9321ca5bfc1e7de632c43b26c9bdc..e8309a3309ebb82a143bb471cbd712498ffeb7fc 100644 (file)
--- a/mod-md.sh
+++ b/mod-md.sh
@@ -5,8 +5,8 @@
 # if we should init md (softraid) at boot
 have_md=no
 
-# disable if tools not installed
-if [ -x /sbin/mdadm ]; then
+mdassemble=$(find_tool $initrd_dir/mdassemble /sbin/initrd-mdassemble)
+if [ -x /sbin/mdadm -a -x $mdassemble ]; then
        USE_MD=yes
 else
        USE_MD=no
@@ -116,13 +116,10 @@ find_modules_md() {
 initrd_gen_md() {
        debug "Setting up mdadm..."
 
-       if [ ! -x /sbin/mdadm -o ! -x /sbin/initrd-mdassemble ]; then
-               die "/sbin/mdadm or /sbin/initrd-mdassemble is missing!"
-       fi
-
-       inst_exec /sbin/initrd-mdassemble /bin/mdassemble
+       inst_exec $mdassemble /bin/mdassemble
 
        # LVM on RAID case
+       local dev_list_extra ex_dev
        dev_list_extra=$(awk '/^DEVICE / { for (i=2; i<=NF; i++) { printf "%s ", $i; }; } ' /etc/mdadm.conf | xargs)
        if [ "$dev_list_extra" = "partitions" ]; then
                # FIXME: handle this case (see man mdadm.conf)
@@ -133,7 +130,8 @@ initrd_gen_md() {
                        echo "DEVICE $ex_dev" >> "$DESTDIR/etc/mdadm.conf"
                done
        fi
-       do_md0=1
+
+       local cr_rootdev cr_dev_list do_md0=1 nr cr_dev_list_md f cr_md_conf
        for nr in `seq 1 $rootdev_nr`; do
                eval cr_rootdev="\$rootdev${nr}"
                eval cr_dev_list="\$dev_list${nr}"
This page took 0.123712 seconds and 4 git commands to generate.