[PATCH 48/50] Shift some functionality around, make modules maskable.
authorVictor Lowther <victor.lowther@gmail.com>
Fri, 13 Feb 2009 12:43:26 +0000 (04:43 -0800)
committerDave Jones <davej@redhat.com>
Mon, 16 Feb 2009 18:56:42 +0000 (13:56 -0500)
Most of our functionality is now in scripts that we source rather than in the
main dracut script.

dracut
dracut-functions
modules/90crypt
modules/90lvm
modules/95udev-rules
modules/99base

diff --git a/dracut b/dracut
index fa3aafa..1378268 100755 (executable)
--- a/dracut
+++ b/dracut
@@ -51,9 +51,12 @@ for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do
     mkdir -p "$initdir/$d"; 
 done
 
-# source any third-party package provided modules
-for f in "$dsrc/modules"/*; do
-    [[ -x $f ]] && . "$f"
+# source all our modules
+for f in "$dsrc/modules"/*[^~]; do
+    mod=${f##*/}; mod=${mod#[0-9][0-9]}
+    if [[ $dracutmodules = all ]] || strstr "$dracutmodules" "$mod"; then 
+       [[ -x $f ]] && . "$f"
+    fi
 done
 
 ## final stuff that has to happen
index b410034..1923b26 100755 (executable)
@@ -25,6 +25,8 @@
 IF_RTLD=""
 IF_dynamic=""
 
+strstr() { [[ ! ${1#*$2*} = $1 ]]; }
+
 # $1 = file to copy to ramdisk
 # $2 (optional) Name for the file on the ramdisk
 # Location of the image dir is assumed to be $initdir
@@ -69,14 +71,16 @@ inst_binary() {
     [[ -f $initdir$target ]] && return 0
     # I love bash!
     while read line; do
-       [[ $line =~ '([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*|not found)' ]] || continue
-       FILE=${BASH_REMATCH[1]}
-        [[ $FILE = 'not found' ]] && {
+       [[ $line = 'not a dynamic executable' ]] && return 1
+       [[ $line =~ 'not found' ]] &&{
            echo "Missing a shared library required by $bin." >&2
            echo "Run \"ldd $bin\" to find out what it is." >&2
            echo "dracut cannot create an initrd." >&2
            exit 1
-       }
+       } 
+       [[ $line =~ '([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)' ]] || continue
+       FILE=${BASH_REMATCH[1]}
+       [[ -f ${initdir}$FILE ]] && continue
        # see if we are loading an optimized version of a shared lib.
        [[ $FILE =~ '^(/lib[^/]*).*' ]] && {
             TLIBDIR=${BASH_REMATCH[1]}
@@ -115,6 +119,14 @@ inst_symlink() {
     inst "$realsrc" && ln -s "$realsrc" "$target"
 }
 
+# udev rules always get installed in the same place, so
+# create a function to install them to make life simpler.
+inst_rules() { 
+    for rule in "$@"; do 
+       inst_simple "$rule" "/lib/udev/rules.d/${rule##*/}"
+    done
+}
+
 # general purpose installation function
 # Same args as above.
 inst() {
index e4f1876..e8f9269 100755 (executable)
@@ -1,2 +1,3 @@
 #!/bin/bash
-inst cryptsetup
\ No newline at end of file
+inst cryptsetup
+inst_rules "$dsrc/rules.d/63-luks.rules"
\ No newline at end of file
index d75062a..315fbb8 100755 (executable)
@@ -1,2 +1,3 @@
 #!/bin/bash
-inst lvm
\ No newline at end of file
+inst lvm
+inst_rules "$dsrc/rules.d/64-lvm.rules"
\ No newline at end of file
index 50a69f8..9801e7e 100755 (executable)
@@ -3,6 +3,8 @@
 # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
 # of the rules we want so that we just copy those in would be best
 mkdir -p "$initdir/lib/udev/rules.d"
-for rule in /lib/udev/rules.d/10-console* /lib/udev/rules.d/40-redhat* /lib/udev/rules.d/50* /lib/udev/rules.d/60-persistent-storage.rules /lib/udev/rules.d/61*edd* /lib/udev/rules.d/64* /lib/udev/rules.d/80* /lib/udev/rules.d/95* $rulesdir/*.rules ; do
-  inst "$rule" "/lib/udev/rules.d/${rule##*/}"
-done
+dracut_install udevd udevadm /lib/udev/*_id /lib/udev/console_*
+inst_rules /lib/udev/rules.d/10-console* /lib/udev/rules.d/40-redhat* \
+    /lib/udev/rules.d/50* /lib/udev/rules.d/60-persistent-storage.rules \
+    /lib/udev/rules.d/61*edd* /lib/udev/rules.d/64* /lib/udev/rules.d/80* \
+    /lib/udev/rules.d/95*
\ No newline at end of file
index c47f62b..e1c699b 100755 (executable)
@@ -1,6 +1,5 @@
 #!/bin/bash
-dracut_install mount mknod mkdir modprobe udevd udevadm pidof sleep \
-              chroot echo sed sh ls /lib/udev/vol_id /lib/udev/console_init
+dracut_install mount mknod mkdir modprobe pidof sleep chroot echo sed sh ls
 
 # install our scripts and hooks
 inst "$initfile" "/init"