commit:     7f6e83707daf4a7d8231b968078a1ba94d80c697
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  1 00:05:47 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug  6 21:00:28 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7f6e8370

estrip: avoid spurious NEEDED warning when no ELF installed (< EAPI 7)

If no ELF files are installed, then we're obviously
not going to have a NEEDED file.

The reason this didn't get hit sooner is because
apparently very few of us are actually testing
EAPI 6 actively - which figures.

We only take this path for < EAPI 7 (non-dostrip)
which means we're actually missing the estrip
optimisation in bug #749624 for newer EAPIs!

(Will be fixed in a followup).

Bug: https://bugs.gentoo.org/749624
Bug: https://bugs.gentoo.org/862606
Fixes: bb88e766897f5e7e0b0a10c48cf99a04edb73a40
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/estrip | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/bin/estrip b/bin/estrip
index 6935470d3..f45211bdb 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -417,12 +417,20 @@ while read -r x ; do
        inode_link=$(get_inode_number "${x}") || die "stat failed unexpectedly"
        echo "${x}" >> "${inode_link}" || die "echo failed unexpectedly"
 done < <(
-       # Use sort -u to eliminate duplicates for bug #445336.
+       # NEEDED may not exist for some packages (bug #862606)
+       if [[ -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED ]] ; then
+               needed_contents=$(cat "${PORTAGE_BUILDDIR}"/build-info/NEEDED | 
cut -d ' ' -f1 | sed -e "s:^:${D%/}:")
+       else
+               needed_contents=""
+       fi
+
+       # Use sort -u to eliminate duplicates (bug #445336).
        (
+               [[ -n ${needed_contents[@]} ]] && printf "%s\n" 
"${needed_contents[@]}"
                find "$@" -type f ! -type l -name '*.a'
-               cut -d ' ' -f1 < "${PORTAGE_BUILDDIR}"/build-info/NEEDED \
-                       | sed -e "s:^:${D%/}:"
        ) | LC_ALL=C sort -u
+
+       unset needed_contents
 )
 else
 while IFS= read -d '' -r x ; do

Reply via email to