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


Reply via email to