Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.gentoo.dev > #70463

[gentoo-dev] [PATCH] rpm.eclass: don't die if grep errors out when detecting payload

From Eli Schwartz <eschwartz@gentoo.org>
Newsgroups linux.gentoo.dev
Subject [gentoo-dev] [PATCH] rpm.eclass: don't die if grep errors out when detecting payload
Date 2026-04-24 23:50 +0200
Message-ID <MNwzn-92z-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


While in theory, exquisitely timed memory exhaustion may result in grep,
and only grep, failing... in practice:

- we must handle "no match"

- "no match" simply determines which of two extraction tools to use, and
  if we choose wrongly, the tool will fail and the ebuild will still die

I guess this mean the *.src.rpm workaround was unnecessary too.

Closes: https://bugs.gentoo.org/973157
Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
---
 eclass/rpm.eclass | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/eclass/rpm.eclass b/eclass/rpm.eclass
index 920f11262bdd..1296e1f3641f 100644
--- a/eclass/rpm.eclass
+++ b/eclass/rpm.eclass
@@ -98,11 +98,11 @@ rpm_unpack() {
 		fi
 
 		local payload= usedep=""
-		if [[ ${a} = *.src.rpm ]]; then
-			payload=none
-		else
-			payload=$($(tc-getSTRINGS) "${a}" | grep -o 'PayloadIs[a-zA-Z]*'; pipestatus || die "failed to grep rpm payload")
-		fi
+		# grep may fail because no payload or because "unknown error", and distinguishing between
+		# the two is problematic. We do a token check that strings works, but rely on rpm failing
+		# with its own well-formed die if we erroneously decide no payload USE flag is needed due
+		# to external commands failing.
+		payload=$($(tc-getSTRINGS) "${a}" | grep -o 'PayloadIs[a-zA-Z]*'; if [[ ${PIPESTATUS[0]} != 0 ]]; then die "strings failed"; fi)
 
 		case ${payload} in
 			"") payload=none;; # gzip/uncompressed
-- 
2.52.0

Back to linux.gentoo.dev | Previous | NextNext in thread | Find similar


Thread

[gentoo-dev] [PATCH] rpm.eclass: don't die if grep errors out when detecting payload Eli Schwartz <eschwartz@gentoo.org> - 2026-04-24 23:50 +0200
  Re: [gentoo-dev] [PATCH] rpm.eclass: don't die if grep errors out  when detecting payload Sam James <sam@gentoo.org> - 2026-04-25 01:00 +0200

csiph-web