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

Sam James <[email protected]>
Newsgroups gmane.linux.gentoo.devel
Organization Gentoo
Message-ID <[email protected]>
Eli Schwartz <[email protected]> writes:

> 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 <[email protected]>

Reviewed-by: Sam James <[email protected]>

and pushed.

> ---
>  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
signature.asc (application/pgp-signature, 418 B)
-----BEGIN PGP SIGNATURE-----

iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmnr9HkbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx
QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkHpB
AP9x89vacvs2erOKiQjgs7Iy5zQ171hvDHWgScIdnk2eUgD+N6IA9HUT22cprfmX
lL3FHCA7wxz+OkT4KCaTDmus8A4=
=nPfi
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.