From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1425695-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id C304E158094
	for <garchives@archives.gentoo.org>; Sat,  6 Aug 2022 21:01:28 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 7C9F0E0C9E;
	Sat,  6 Aug 2022 21:01:27 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id A8A10E0C9E
	for <gentoo-commits@lists.gentoo.org>; Sat,  6 Aug 2022 21:01:26 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 71747341230
	for <gentoo-commits@lists.gentoo.org>; Sat,  6 Aug 2022 21:01:25 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id A6080561
	for <gentoo-commits@lists.gentoo.org>; Sat,  6 Aug 2022 21:01:23 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1659819628.7f6e83707daf4a7d8231b968078a1ba94d80c697.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/estrip
X-VCS-Directories: bin/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 7f6e83707daf4a7d8231b968078a1ba94d80c697
X-VCS-Branch: master
Date: Sat,  6 Aug 2022 21:01:23 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 0347c3f1-f415-4af2-8cd9-f65091526954
X-Archives-Hash: 9b2d020f48b2c50b512a24e6f1c9c853

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