From: Alexander Tsoy Date: Mon, 25 May 2020 16:02:05 +0000 (+0300) Subject: dracut-functions: fix find_binary() to return full path X-Git-Tag: 051~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f769154bccf22d2b5caf5e4888f88bf7edde2662;p=thirdparty%2Fdracut.git dracut-functions: fix find_binary() to return full path Fixes: a01204202b30 (Allow running on a cross-compiled rootfs) --- diff --git a/dracut-functions.sh b/dracut-functions.sh index 3cb9c7afd..b5c28248a 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -41,31 +41,36 @@ str_ends() { [ "${1%*"$2"}" != "$1" ]; } # search in the usual places to find the binary. find_binary() { local _delim + local _path local l local p [[ -z ${1##/*} ]] || _delim="/" if [[ "$1" == *.so* ]]; then for l in libdirs ; do - if { $DRACUT_LDD "$dracutsysrootdir$l$_delim$1" &>/dev/null; }; then - printf "%s\n" "$1" + _path="${l}${_delim}${1}" + if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then + printf "%s\n" "${_path}" return 0 fi done - if { $DRACUT_LDD "$dracutsysrootdir$_delim$1" &>/dev/null; }; then - printf "%s\n" "$1" + _path="${_delim}${1}" + if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then + printf "%s\n" "${_path}" return 0 fi fi if [[ "$1" == */* ]]; then - if [[ -L $dracutsysrootdir$_delim$1 ]] || [[ -x $dracutsysrootdir$_delim$1 ]]; then - printf "%s\n" "$1" + _path="${_delim}${1}" + if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then + printf "%s\n" "${_path}" return 0 fi fi for p in $DRACUT_PATH ; do - if [[ -L $dracutsysrootdir$p$_delim$1 ]] || [[ -x $dracutsysrootdir$p$_delim$1 ]]; then - printf "%s\n" "$1" + _path="${p}${_delim}${1}" + if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then + printf "%s\n" "${_path}" return 0 fi done