Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 12/18] Add tentative EAPI6 absolute path support to unpack()
Date: Mon, 01 Dec 2014 21:30:42
Message-Id: 1417469316-25052-13-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 00/18] Updated EAPI 6 patch set by "Michał Górny"
1 Add support for absolute paths in unpack(). Allow subdirectory-level
2 relative paths not to start with './'.
3 ---
4 bin/eapi.sh | 4 ++++
5 bin/phase-helpers.sh | 29 ++++++++++++++++++++++-------
6 2 files changed, 26 insertions(+), 7 deletions(-)
7
8 diff --git a/bin/eapi.sh b/bin/eapi.sh
9 index 878f8e7..6716b1c 100644
10 --- a/bin/eapi.sh
11 +++ b/bin/eapi.sh
12 @@ -162,6 +162,10 @@ ___eapi_unpack_is_case_sensitive() {
13 [[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
14 }
15
16 +___eapi_unpack_supports_absolute_paths() {
17 + [[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
18 +}
19 +
20 # OTHERS
21
22 ___eapi_enables_failglob_in_global_scope() {
23 diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
24 index 182a872..a6e1cdb 100644
25 --- a/bin/phase-helpers.sh
26 +++ b/bin/phase-helpers.sh
27 @@ -276,14 +276,29 @@ unpack() {
28 y=${y##*.}
29 y_insensitive=$(LC_ALL=C tr "[:upper:]" "[:lower:]" <<< "${y}")
30
31 - if [[ ${x} == "./"* ]] ; then
32 - srcdir=""
33 - elif [[ ${x} == ${DISTDIR%/}/* ]] ; then
34 - die "Arguments to unpack() cannot begin with \${DISTDIR}."
35 - elif [[ ${x} == "/"* ]] ; then
36 - die "Arguments to unpack() cannot be absolute"
37 + # wrt PMS 11.3.3.13 Misc Commands
38 + if [[ ${x} != */* ]]; then
39 + # filename without path of any kind
40 + srcdir=${DISTDIR}/
41 + elif [[ ${x} == ./* ]]; then
42 + # relative path starting with './'
43 + srcdir=
44 else
45 - srcdir="${DISTDIR}/"
46 + # non-'./' filename with path of some kind
47 + if ___eapi_unpack_supports_absolute_paths; then
48 + # EAPI 6 allows absolute and deep relative paths
49 + srcdir=
50 +
51 + if [[ ${x} == ${DISTDIR%/}/* ]]; then
52 + eqawarn "QA Notice: unpack called with redundant \${DISTDIR} in path"
53 + fi
54 + elif [[ ${x} == ${DISTDIR%/}/* ]]; then
55 + die "Arguments to unpack() cannot begin with \${DISTDIR} in EAPI ${EAPI}"
56 + elif [[ ${x} == /* ]] ; then
57 + die "Arguments to unpack() cannot be absolute in EAPI ${EAPI}"
58 + else
59 + die "Relative paths to unpack() must be prefixed with './' in EAPI ${EAPI}"
60 + fi
61 fi
62 if [[ ! -s ${srcdir}${x} ]]; then
63 __helpers_die "unpack: ${x} does not exist"
64 --
65 2.1.3