This also makes the individual inst functions more robust and easily callable as seperate functions. --- dracut-functions | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dracut-functions b/dracut-functions index bb6e972..fe86a10 100755 --- a/dracut-functions +++ b/dracut-functions @@ -31,7 +31,9 @@ strstr() { [[ ! ${1#*$2*} = $1 ]]; } # $2 (optional) Name for the file on the ramdisk # Location of the image dir is assumed to be $initdir inst_simple() { - local src=$1 target="${initdir}${2:-$1}" + local src target + [[ -f $1 ]] || return 1 + src=$1 target="${initdir}${2:-$1}" [[ -f $target ]] && return 0 mkdir -p "${target%/*}" echo "Installing $src" >&2 @@ -66,7 +68,9 @@ find_binary() { # If the file is a binary executable, install all its # shared library dependencies, if any. inst_binary() { - local bin="$1" target="${2:-$1}" + local bin target + bin=$(find_binary "$1") || return 1 + shift local LDSO NAME IO FILE ADDR I1 n f TLIBDIR [[ -f $initdir$target ]] && return 0 # I love bash! @@ -97,12 +101,13 @@ inst_binary() { } inst_library "$FILE" done < <(ldd $bin 2>/dev/null) - inst_simple "$bin" "$target" + inst_simple "$bin" "$@" } # same as above, except for shell scripts. # If your shell script does not start with shebang, it is not a shell script. inst_script() { + [[ -f $1 ]] || return 1 local src=$1 target=${2:-$1} line read -r -n 80 line <"$src" [[ $line =~ '(#! *)(/[^ ]+).*' ]] || return 1 @@ -142,14 +147,8 @@ inst() { echo "usage: inst <file> <root> [<destination file>]" return 1 fi - local src dest - src=$(find_binary "$1") || { - echo "Cannot find requested file $1. Exiting." - exit 1 - } - local dest=${2:-$src} for x in inst_symlink inst_script inst_binary inst_simple; do - $x "$src" "$dest" && return 0 + $x "$@" && return 0 done return 1 } @@ -176,7 +175,7 @@ dracut_install() { done } -srcmods="/lib/modules/$kernel/" +srcmods="/lib/modules/$kernel" instmods() { local mod mpargs modpath modname cmd while (($# > 0)); do -- 1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html