diff --git a/usr/share/archboot/patches/functions b/usr/share/archboot/patches/functions index 80eaa803b..eb5a9a438 100644 --- a/usr/share/archboot/patches/functions +++ b/usr/share/archboot/patches/functions @@ -717,11 +717,11 @@ add_binary() { # detect if the file has a shebang if IFS='' LC_ALL=C read -rn2 -d '' shebang < "$binary" && [[ "$shebang" == '#!' ]]; then read -r shebang < "$binary" - interpreter="${shebang##\#\!}" + interpreter="${shebang##\#\!*([[:space:]])}" # strip /usr/bin/env and warn if it is missing if [[ "$interpreter" == '/usr/bin/env'* ]]; then [[ -e "${BUILDROOT}/usr/bin/env" ]] || warning "Possibly missing '/usr/bin/env' for script: %s" "$binary" - interpreter="${interpreter##'/usr/bin/env'[[:space:]]}" + interpreter="${interpreter##'/usr/bin/env'+([[:space:]])}" fi # strip parameters interpreter="${interpreter%%[[:space:]]*}" @@ -730,8 +730,11 @@ add_binary() { interpreter="$(PATH="${BUILDROOT}/usr/local/sbin:${BUILDROOT}/usr/local/bin:${BUILDROOT}/usr/bin" type -P "$interpreter")" fi - # check if the interpreter exists in BUILDROOT - if [[ ! -e "${BUILDROOT}/${interpreter}" ]]; then + if [[ "$interpreter" != '/'* ]] && PATH="${BUILDROOT}/usr/local/sbin:${BUILDROOT}/usr/local/bin:${BUILDROOT}/usr/bin" type -P "$interpreter" &>/dev/null; then + : + elif [[ -e "${BUILDROOT}/${interpreter}" ]]; then + : + else warning "Possibly missing '%s' for script: %s" "$interpreter" "$binary" fi fi