From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1105575-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id EC61A138334
	for <garchives@archives.gentoo.org>; Wed, 14 Aug 2019 02:08:35 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 1EF27E0855;
	Wed, 14 Aug 2019 02:08:35 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id E8777E0855
	for <gentoo-commits@lists.gentoo.org>; Wed, 14 Aug 2019 02:08:33 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 2BCDF349AB7
	for <gentoo-commits@lists.gentoo.org>; Wed, 14 Aug 2019 02:08:32 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id A471F762
	for <gentoo-commits@lists.gentoo.org>; Wed, 14 Aug 2019 02:08:30 +0000 (UTC)
From: "Zac Medico" <zmedico@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, "Zac Medico" <zmedico@gentoo.org>
Message-ID: <1565748164.17ecafa949c87a6f2a2d2c98c7de18ed06f08f2f.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/isolated-functions.sh bin/phase-helpers.sh
X-VCS-Directories: bin/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: 17ecafa949c87a6f2a2d2c98c7de18ed06f08f2f
X-VCS-Branch: master
Date: Wed, 14 Aug 2019 02:08:30 +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: 4adbb714-0d6d-4def-aa60-d4285ea6aaca
X-Archives-Hash: 087d18f0e7f0d716910cad930c0d5c49

commit:     17ecafa949c87a6f2a2d2c98c7de18ed06f08f2f
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 12 20:20:16 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Aug 14 02:02:44 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=17ecafa9

unpack: Unconditionally die if an unpacker returns an error.

As specified by PMS: "If unpacking a supported file format fails,
unpack shall abort the build process."
https://projects.gentoo.org/pms/7/pms.html#x1-13500012.3.15:

This partially reverts commit 525e69351d45621c34a9326fcbc11ca592cb6539,
as far as unpack() is concerned.

Bug: https://bugs.gentoo.org/691776
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 bin/isolated-functions.sh | 13 ++-----
 bin/phase-helpers.sh      | 87 +++++++++++++----------------------------------
 2 files changed, 27 insertions(+), 73 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index e4e769a04..893c02f9b 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH}/eapi.sh" || exit 1
@@ -38,18 +38,11 @@ __assert_sigpipe_ok() {
 	local x pipestatus=${PIPESTATUS[*]}
 	for x in $pipestatus ; do
 		# Allow SIGPIPE through (128 + 13)
-		if [[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]]
-		then
-			__helpers_die "$@"
-			return 1
-		fi
+		[[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && die "$@"
 	done
 
 	# Require normal success for the last process (tar).
-	if [[ $x -ne 0 ]]; then
-		__helpers_die "$@"
-		return 1
-	fi
+	[[ $x -eq 0 ]] || die "$@"
 }
 
 shopt -s extdebug

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 02633125f..15fe8c682 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 if ___eapi_has_DESTTREE_INSDESTTREE; then
@@ -347,10 +347,7 @@ unpack() {
 				die "Relative paths to unpack() must be prefixed with './' in EAPI ${EAPI}"
 			fi
 		fi
-		if [[ ! -s ${srcdir}${x} ]]; then
-			__helpers_die "unpack: ${x} does not exist"
-			return 1
-		fi
+		[[ ! -s ${srcdir}${x} ]] && die "${x} does not exist"
 
 		__unpack_tar() {
 			if [[ ${y_insensitive} == tar ]] ; then
@@ -361,18 +358,15 @@ unpack() {
 						"supported with EAPI '${EAPI}'. Instead use 'tar'."
 				fi
 				$1 -c -- "$srcdir$x" | tar xof -
-				__assert_sigpipe_ok "$myfail" || return 1
+				__assert_sigpipe_ok "$myfail"
 			else
 				local cwd_dest=${x##*/}
 				cwd_dest=${cwd_dest%.*}
-				if ! $1 -c -- "${srcdir}${x}" > "${cwd_dest}"; then
-					__helpers_die "$myfail"
-					return 1
-				fi
+				$1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail"
 			fi
 		}
 
-		myfail="unpack: failure unpacking ${x}"
+		myfail="failure unpacking ${x}"
 		case "${suffix_insensitive}" in
 			tar)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -381,10 +375,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'tar'."
 				fi
-				if ! tar xof "$srcdir$x"; then
-					__helpers_die "$myfail"
-					return 1
-				fi
+				tar xof "$srcdir$x" || die "$myfail"
 				;;
 			tgz)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -393,10 +384,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'tgz'."
 				fi
-				if ! tar xozf "$srcdir$x"; then
-					__helpers_die "$myfail"
-					return 1
-				fi
+				tar xozf "$srcdir$x" || die "$myfail"
 				;;
 			tbz|tbz2)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -406,7 +394,7 @@ unpack() {
 						"with EAPI '${EAPI}'. Instead use 'tbz' or 'tbz2'."
 				fi
 				${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcdir$x" | tar xof -
-				__assert_sigpipe_ok "$myfail" || return 1
+				__assert_sigpipe_ok "$myfail"
 				;;
 			zip|jar)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -418,10 +406,8 @@ unpack() {
 				fi
 				# unzip will interactively prompt under some error conditions,
 				# as reported in bug #336285
-				if ! unzip -qo "${srcdir}${x}"; then
-					__helpers_die "$myfail"
-					return 1
-				fi < <(set +x ; while true ; do echo n || break ; done)
+				( set +x ; while true ; do echo n || break ; done ) | \
+				unzip -qo "${srcdir}${x}" || die "$myfail"
 				;;
 			gz|z)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -430,7 +416,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'gz', 'z', or 'Z'."
 				fi
-				__unpack_tar "gzip -d" || return 1
+				__unpack_tar "gzip -d"
 				;;
 			bz2|bz)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -439,8 +425,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'bz' or 'bz2'."
 				fi
-				__unpack_tar "${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d}" \
-					|| return 1
+				__unpack_tar "${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d}"
 				;;
 			7z)
 				local my_output
@@ -457,10 +442,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'rar' or 'RAR'."
 				fi
-				if ! unrar x -idq -o+ "${srcdir}${x}"; then
-					__helpers_die "$myfail"
-					return 1
-				fi
+				unrar x -idq -o+ "${srcdir}${x}" || die "$myfail"
 				;;
 			lha|lzh)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -470,10 +452,7 @@ unpack() {
 						"with EAPI '${EAPI}'." \
 						"Instead use 'LHA', 'LHa', 'lha', or 'lzh'."
 				fi
-				if ! lha xfq "${srcdir}${x}"; then
-					__helpers_die "$myfail"
-					return 1
-				fi
+				lha xfq "${srcdir}${x}" || die "$myfail"
 				;;
 			a)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -482,10 +461,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'a'."
 				fi
-				if ! ar x "${srcdir}${x}"; then
-					__helpers_die "$myfail"
-					return 1
-				fi
+				ar x "${srcdir}${x}" || die "$myfail"
 				;;
 			deb)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -508,32 +484,20 @@ unpack() {
 						# deb2targz always extracts into the same directory as
 						# the source file, so create a symlink in the current
 						# working directory if necessary.
-						if ! ln -sf "$srcdir$x" "$y"; then
-							__helpers_die "$myfail"
-							return 1
-						fi
+						ln -sf "$srcdir$x" "$y" || die "$myfail"
 						created_symlink=1
 					fi
-					if ! deb2targz "$y"; then
-						__helpers_die "$myfail"
-						return 1
-					fi
+					deb2targz "$y" || die "$myfail"
 					if [ $created_symlink = 1 ] ; then
 						# Clean up the symlink so the ebuild
 						# doesn't inadvertently install it.
 						rm -f "$y"
 					fi
-					if ! mv -f "${y%.deb}".tar.gz data.tar.gz; then
-						if ! mv -f "${y%.deb}".tar.xz data.tar.xz; then
-							__helpers_die "$myfail"
-							return 1
-						fi
-					fi
+					mv -f "${y%.deb}".tar.gz data.tar.gz \
+						|| mv -f "${y%.deb}".tar.xz data.tar.xz \
+						|| die "$myfail"
 				else
-					if ! ar x "$srcdir$x"; then
-						__helpers_die "$myfail"
-						return 1
-					fi
+					ar x "$srcdir$x" || die "$myfail"
 				fi
 				;;
 			lzma)
@@ -543,7 +507,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'lzma'."
 				fi
-				__unpack_tar "lzma -d" || return 1
+				__unpack_tar "lzma -d"
 				;;
 			xz)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -553,7 +517,7 @@ unpack() {
 						"with EAPI '${EAPI}'. Instead use 'xz'."
 				fi
 				if ___eapi_unpack_supports_xz; then
-					__unpack_tar "xz -d" || return 1
+					__unpack_tar "xz -d"
 				else
 					__vecho "unpack ${x}: file format not recognized. Ignoring."
 				fi
@@ -566,10 +530,7 @@ unpack() {
 						"with EAPI '${EAPI}'. Instead use 'txz'."
 				fi
 				if ___eapi_unpack_supports_txz; then
-					if ! tar xof "$srcdir$x"; then
-						__helpers_die "$myfail"
-						return 1
-					fi
+					tar xof "$srcdir$x" || die "$myfail"
 				else
 					__vecho "unpack ${x}: file format not recognized. Ignoring."
 				fi