]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Fix broken -c handling and give instmods a little optimization.
authorVictor Lowther <victor.lowther@gmail.com>
Sat, 7 Mar 2009 03:41:31 +0000 (21:41 -0600)
committerVictor Lowther <victor.lowther@gmail.com>
Sat, 7 Mar 2009 03:41:31 +0000 (21:41 -0600)
dracut
dracut-functions

diff --git a/dracut b/dracut
index ff22a670e406b53cc3770cdc65d6b08a8bf77eb1..d8da6d69a78af640404649ff7a30a3ab8be60375 100755 (executable)
--- a/dracut
+++ b/dracut
@@ -15,7 +15,7 @@ while (($# > 0)); do
        -h|--help) echo "Usage: $0 [-f] <initramfs> <kernel-version>"
            exit 1 ;;
        -v|--verbose) set -x;;
-       -c|--conf) conffile="$2"
+       -c|--conf) conffile="$2" ;;
        -l|--local) allowlocal="yes" ;;
        --allow-missing) : ;;
        *) break ;;
index cb66790c3b043ba981fc4076c46940127c74caf3..be06ae0fe500fe1b361ca070d174a00c2de15844 100755 (executable)
 IF_RTLD=""
 IF_dynamic=""
 
+# Generic substring function.  If $2 is in $1, return 0.
 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
+# We never overwrite the target if it exists.
 inst_simple() {
     local src target
     [[ -f $1 ]] || return 1
@@ -40,6 +42,9 @@ inst_simple() {
     cp -fL "$src" "$target"
 }
 
+# Same as above, but specialzed to handle dynamic libraries.
+# It handles making symlinks according to how the original library
+# is referenced.
 inst_library() {
     local src=$1 dest=${2:-$1}
     [[ -f $initdir$dest ]] && return 0
@@ -53,7 +58,9 @@ inst_library() {
        inst_simple "$src" "$dest"
     fi
 }
-       
+
+# find a binary.  If we were not passed the full path directly,
+# search in the usual places to find the binary.
 find_binary() {
     local binpath="/bin /sbin /usr/bin /usr/sbin" p
     [[ -x $1 ]] && { echo $1; return 0; }
@@ -63,13 +70,12 @@ find_binary() {
     return 1
 }
 
-# Same as above.
-# If the file is a binary executable, install all its
-# shared library dependencies, if any.
+# Same as above, but specialized to install binary executables.
+# Install binary executable, and all shared library dependencies, if any.
 inst_binary() {
     local bin target
     bin=$(find_binary "$1") || return 1
-    shift
+    target=${2:-$bin}
     local LDSO NAME IO FILE ADDR I1 n f TLIBDIR
     [[ -f $initdir$target ]] && return 0
     # I love bash!
@@ -100,7 +106,7 @@ inst_binary() {
        }
         inst_library "$FILE" 
     done < <(ldd $bin 2>/dev/null)
-    inst_simple "$bin" "$@"
+    inst_simple "$bin" "$target"
 }
 
 # same as above, except for shell scripts.
@@ -123,6 +129,7 @@ inst_symlink() {
     inst "$realsrc" && ln -s "$realsrc" "$target"
 }
 
+# find a rule in the usual places.
 find_rule() {
     for r in . /lib/udev/rules.d /etc/udev/rules.d $dsrc/rules.d; do
        [[ -f $r/$1 ]] && { echo "$r/$1"; return 0; }
@@ -196,6 +203,7 @@ instmods() {
                ;;
            --*) mpargs+=" $mod";;
            *)  mod=${mod##*/}
+               [[ -f $initdir/$1 ]] && { shift; continue; }
                 modprobe $mpargs --ignore-install --set-version $kernel \
                    --show-depends $mod 2>/dev/null | \
                    while read cmd modpath options; do