From: Victor Lowther Date: Sat, 7 Mar 2009 03:41:31 +0000 (-0600) Subject: Fix broken -c handling and give instmods a little optimization. X-Git-Tag: 0.1~314 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3198f1711ffd44f19477739325027b458e661107;p=thirdparty%2Fdracut.git Fix broken -c handling and give instmods a little optimization. --- diff --git a/dracut b/dracut index ff22a670e..d8da6d69a 100755 --- a/dracut +++ b/dracut @@ -15,7 +15,7 @@ while (($# > 0)); do -h|--help) echo "Usage: $0 [-f] " exit 1 ;; -v|--verbose) set -x;; - -c|--conf) conffile="$2" + -c|--conf) conffile="$2" ;; -l|--local) allowlocal="yes" ;; --allow-missing) : ;; *) break ;; diff --git a/dracut-functions b/dracut-functions index cb66790c3..be06ae0fe 100755 --- a/dracut-functions +++ b/dracut-functions @@ -25,11 +25,13 @@ 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