public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH 12/18] Add tentative EAPI6 absolute path support to unpack()
Date: Mon,  1 Dec 2014 22:28:30 +0100	[thread overview]
Message-ID: <1417469316-25052-13-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1417469316-25052-1-git-send-email-mgorny@gentoo.org>

Add support for absolute paths in unpack(). Allow subdirectory-level
relative paths not to start with './'.
---
 bin/eapi.sh          |  4 ++++
 bin/phase-helpers.sh | 29 ++++++++++++++++++++++-------
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 878f8e7..6716b1c 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -162,6 +162,10 @@ ___eapi_unpack_is_case_sensitive() {
 	[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
 }
 
+___eapi_unpack_supports_absolute_paths() {
+	[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
+}
+
 # OTHERS
 
 ___eapi_enables_failglob_in_global_scope() {
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 182a872..a6e1cdb 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -276,14 +276,29 @@ unpack() {
 		y=${y##*.}
 		y_insensitive=$(LC_ALL=C tr "[:upper:]" "[:lower:]" <<< "${y}")
 
-		if [[ ${x} == "./"* ]] ; then
-			srcdir=""
-		elif [[ ${x} == ${DISTDIR%/}/* ]] ; then
-			die "Arguments to unpack() cannot begin with \${DISTDIR}."
-		elif [[ ${x} == "/"* ]] ; then
-			die "Arguments to unpack() cannot be absolute"
+		# wrt PMS 11.3.3.13 Misc Commands
+		if [[ ${x} != */* ]]; then
+			# filename without path of any kind
+			srcdir=${DISTDIR}/
+		elif [[ ${x} == ./* ]]; then
+			# relative path starting with './'
+			srcdir=
 		else
-			srcdir="${DISTDIR}/"
+			# non-'./' filename with path of some kind
+			if ___eapi_unpack_supports_absolute_paths; then
+				# EAPI 6 allows absolute and deep relative paths
+				srcdir=
+
+				if [[ ${x} == ${DISTDIR%/}/* ]]; then
+					eqawarn "QA Notice: unpack called with redundant \${DISTDIR} in path"
+				fi
+			elif [[ ${x} == ${DISTDIR%/}/* ]]; then
+				die "Arguments to unpack() cannot begin with \${DISTDIR} in EAPI ${EAPI}"
+			elif [[ ${x} == /* ]] ; then
+				die "Arguments to unpack() cannot be absolute in EAPI ${EAPI}"
+			else
+				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"
-- 
2.1.3



  parent reply	other threads:[~2014-12-01 21:30 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01 21:28 [gentoo-portage-dev] [PATCH 00/18] Updated EAPI 6 patch set Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 01/18] Respect nonfatal in unpack(), econf() and einstall() Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 02/18] Apply 'nonfatal' to helpers only Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 03/18] Support EAPI=6_pre1 for testing EAPI6 features Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 04/18] Add tentative support for EAPI6 --docdir and --htmldir Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 05/18] Add tentative support for EAPI6 get_libdir() Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 06/18] Add tentative support for EAPI6 einstalldocs function Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 07/18] Add tentative support for EAPI6 eapply function Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 08/18] Add tentative support for EAPI6 eapply_user function Michał Górny
2017-02-09 22:39   ` Zac Medico
2017-02-10 13:57     ` Michał Górny
2017-02-10 16:57       ` Zac Medico
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 09/18] Enable tentative EAPI6 failglob in global scope Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 10/18] Enable tentative support for EAPI6 profile-level directories Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 11/18] Add tentative EAPI6 .txz unpack support Michał Górny
2014-12-01 21:28 ` Michał Górny [this message]
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 13/18] Add tentative EAPI6 nonfatal support to die() Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 14/18] Add tentative EAPI6 in_iuse() function Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 15/18] Add tentative EAPI6 phase functions Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 16/18] Disallow helpers in global scope in EAPI 6 Michał Górny
2015-01-16 10:14   ` Sergei Trofimovich
2015-01-16 18:18     ` Zac Medico
2015-01-16 19:53       ` Zac Medico
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 17/18] Ban einstall for " Michał Górny
2014-12-01 21:28 ` [gentoo-portage-dev] [PATCH 18/18] Deprecate dohtml " Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417469316-25052-13-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox