From 9a7e4f6b4171c13c7463591e54c3e76cef57770d Mon Sep 17 00:00:00 2001 From: Yiyang Wu Date: Thu, 4 Apr 2024 20:44:00 +0800 Subject: [PATCH] Prefixify all scripts Signed-off-by: Yiyang Wu --- bin/install-qa-check.d/05prefix | 39 ++++++++++++++------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/bin/install-qa-check.d/05prefix b/bin/install-qa-check.d/05prefix index edbd6fab2..fcc10697d 100644 --- a/bin/install-qa-check.d/05prefix +++ b/bin/install-qa-check.d/05prefix @@ -33,7 +33,7 @@ install_qa_check_prefix() { # check shebangs, bug #282539 rm -f "${T}"/non-prefix-shebangs-errs - local WHITELIST=" /usr/bin/env " + local WHITELIST="" # this is hell expensive, but how else? find "${ED}" -executable \! -type d -print0 \ | xargs -0 grep -H -n -m1 "^#!" \ @@ -76,29 +76,22 @@ install_qa_check_prefix() { fi continue fi - # unprefixed shebang, is the script directly in ${PATH} or an init script? - if [[ ":${PATH}:${EPREFIX}/etc/init.d:" == *":${fp}:"* ]] ; then - if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then - # is it unprefixed, but we can just fix it because a - # prefixed variant exists - eqawarn "QA Notice: prefixing shebang of ${fn#${D}}" - # statement is made idempotent on purpose, because - # symlinks may point to the same target, and hence the - # same real file may be sedded multiple times since we - # read the shebangs in one go upfront for performance - # reasons - sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${rf}" - continue - else - # this is definitely wrong: script in ${PATH} and invalid shebang - echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but interpreter ${line[0]} not found)" \ - >> "${T}"/non-prefix-shebangs-errs - fi + # unprefixed shebang, prefixify it! + if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then + # is it unprefixed, but we can just fix it because a + # prefixed variant exists + eqawarn "QA Notice: prefixing shebang of ${fn#${D}}" + # statement is made idempotent on purpose, because + # symlinks may point to the same target, and hence the + # same real file may be sedded multiple times since we + # read the shebangs in one go upfront for performance + # reasons + sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${rf}" + continue else - # unprefixed/invalid shebang, but outside ${PATH}, this may be - # intended (e.g. config.guess) so remain silent by default - has stricter ${FEATURES} && \ - eqawarn "QA Notice: invalid shebang in ${fn#${D}}: ${line[0]}" + # this is definitely wrong: script in ${PATH} and invalid shebang + echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but interpreter ${line[0]} not found)" \ + >> "${T}"/non-prefix-shebangs-errs fi done if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then -- 2.43.0