commit:     ba6bc7e9a747ff24e4f45957ffd8c7a2de70d96b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  6 22:06:07 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Mar  6 22:10:07 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ba6bc7e9

sys-apps/portage: batch EPREFIX shebang sed calls with xargs

Batch EPREFIX shebang sed calls with xargs, and also use
find -executable since we only care about executables.

Package-Manager: Portage-3.0.16, Repoman-3.0.2
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 sys-apps/portage/portage-9999.ebuild | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sys-apps/portage/portage-9999.ebuild 
b/sys-apps/portage/portage-9999.ebuild
index f229af539a2..feff21265f7 100644
--- a/sys-apps/portage/portage-9999.ebuild
+++ b/sys-apps/portage/portage-9999.ebuild
@@ -128,13 +128,17 @@ python_prepare_all() {
                        -w "/_BINARY/" lib/portage/const.py
 
                einfo "Prefixing shebangs ..."
+               > "${T}/shebangs" || die
                while read -r -d $'\0' ; do
                        local shebang=$(head -n1 "$REPLY")
                        if [[ ${shebang} == "#!"* && ! ${shebang} == 
"#!${EPREFIX}/"* ]] ; then
-                               sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" 
"$REPLY" || \
-                                       die "sed failed"
+                               echo "${REPLY}" >> "${T}/shebangs" || die
                        fi
-               done < <(find . -type f ! -name etc-update -print0)
+               done < <(find . -type f -executable ! -name etc-update -print0)
+
+               if [[ -s ${T}/shebangs ]]; then
+                       xargs sed -i -e "1s:^#!:#!${EPREFIX}:" < 
"${T}/shebangs" || die "sed failed"
+               fi
 
                einfo "Adjusting make.globals, repos.conf and etc-update ..."
                hprefixify cnf/{make.globals,repos.conf} bin/etc-update

Reply via email to