From: Michał Górny <mgo...@gentoo.org>

Bug: https://bugs.gentoo.org/203891
Closes: https://github.com/mgorny/portage/issues/8
---
 bin/eapi.sh            |  4 ++++
 bin/ebuild.sh          |  2 +-
 bin/phase-helpers.sh   | 26 ++++++++++++++++++++++++++
 bin/save-ebuild-env.sh |  2 +-
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 326eb387e..1445c3ec7 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -76,6 +76,10 @@ ___eapi_has_docompress() {
        [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
+___eapi_has_dostrip() {
+       [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|5|6)$ ]]
+}
+
 ___eapi_has_nonfatal() {
        [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 061b1aff4..11441bfb2 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -59,7 +59,7 @@ else
        # These dummy functions are for things that are likely to be called
        # in global scope, even though they are completely useless during
        # the "depend" phase.
-       funcs="diropts docompress exeopts get_KV insopts
+       funcs="diropts docompress dostrip exeopts get_KV insopts
                KV_major KV_micro KV_minor KV_to_int
                libopts register_die_hook register_success_hook
                __strip_duplicate_slashes
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 020a49592..556d089b5 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -163,6 +163,32 @@ docompress() {
        fi
 }
 
+dostrip() {
+       ___eapi_has_dostrip || die "'${FUNCNAME}' not supported in this EAPI"
+
+       local f g
+       if [[ $1 = "-x" ]]; then
+               shift
+               for f; do
+                       f=$(__strip_duplicate_slashes "${f}"); f=${f%/}
+                       [[ ${f:0:1} = / ]] || f="/${f}"
+                       for g in "${PORTAGE_DOSTRIP_SKIP[@]}"; do
+                               [[ ${f} = "${g}" ]] && continue 2
+                       done
+                       PORTAGE_DOSTRIP_SKIP+=( "${f}" )
+               done
+       else
+               for f; do
+                       f=$(__strip_duplicate_slashes "${f}"); f=${f%/}
+                       [[ ${f:0:1} = / ]] || f="/${f}"
+                       for g in "${PORTAGE_DOSTRIP[@]}"; do
+                               [[ ${f} = "${g}" ]] && continue 2
+                       done
+                       PORTAGE_DOSTRIP+=( "${f}" )
+               done
+       fi
+}
+
 useq() {
        has $EBUILD_PHASE prerm postrm || eqawarn \
                "QA Notice: The 'useq' function is deprecated (replaced by 
'use')"
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index f624f44ec..947ac79d5 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -60,7 +60,7 @@ __save_ebuild_env() {
                unpack __strip_duplicate_slashes econf einstall \
                __dyn_setup __dyn_unpack __dyn_clean \
                into insinto exeinto docinto \
-               insopts diropts exeopts libopts docompress \
+               insopts diropts exeopts libopts docompress dostrip \
                __abort_handler __abort_prepare __abort_configure 
__abort_compile \
                __abort_test __abort_install __dyn_prepare __dyn_configure \
                __dyn_compile __dyn_test __dyn_install \
-- 
2.13.6


Reply via email to