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
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
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; }
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!
}
inst_library "$FILE"
done < <(ldd $bin 2>/dev/null)
- inst_simple "$bin" "$@"
+ inst_simple "$bin" "$target"
}
# same as above, except for shell scripts.
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; }
;;
--*) 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