Ban the direct use of DESTTREE/INSDESTTREE in EAPI 7. Use new _E_*
helper variables for into/insinto.

Bug: https://bugs.gentoo.org/173630
---
 bin/eapi.sh                 |  4 ++++
 bin/ebuild-helpers/dobin    | 16 ++++++++++++----
 bin/ebuild-helpers/doconfd  |  4 ++--
 bin/ebuild-helpers/doenvd   |  4 ++--
 bin/ebuild-helpers/doheader |  4 ++--
 bin/ebuild-helpers/doins    | 18 +++++++++++++-----
 bin/ebuild-helpers/dolib    | 10 +++++++++-
 bin/ebuild-helpers/dolib.a  | 10 +++++++++-
 bin/ebuild-helpers/dolib.so | 10 +++++++++-
 bin/ebuild-helpers/domo     | 16 ++++++++++++----
 bin/ebuild-helpers/dosbin   | 16 ++++++++++++----
 bin/phase-functions.sh      | 11 ++++++++---
 bin/phase-helpers.sh        | 33 +++++++++++++++++++++++----------
 bin/save-ebuild-env.sh      |  4 ++--
 14 files changed, 119 insertions(+), 41 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index d8c487b69..309198be4 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -190,6 +190,10 @@ ___eapi_domo_respects_into() {
        [[ ${1-${EAPI-0}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress|6)$ ]]
 }
 
+___eapi_has_DESTTREE_INSDESTTREE() {
+       [[ ${1-${EAPI-0}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress|6)$ ]]
+}
+
 # OTHERS
 
 ___eapi_enables_failglob_in_global_scope() {
diff --git a/bin/ebuild-helpers/dobin b/bin/ebuild-helpers/dobin
index 9f4d73dc4..f43871f49 100755
--- a/bin/ebuild-helpers/dobin
+++ b/bin/ebuild-helpers/dobin
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
@@ -13,15 +13,23 @@ if ! ___eapi_has_prefix_variables; then
        ED=${D}
 fi
 
-if [[ ! -d ${ED}${DESTTREE}/bin ]] ; then
-       install -d "${ED}${DESTTREE}/bin" || { __helpers_die "${0##*/}: failed 
to install ${ED}${DESTTREE}/bin"; exit 2; }
+if ! ___eapi_has_DESTTREE_INSDESTTREE; then
+       [[ -n ${DESTTREE} ]] &&
+               die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; 
use 'into' instead"
+else
+       # backwards compatibility
+       _E_DESTTREE_=${DESTTREE}
+fi
+
+if [[ ! -d ${ED}${_E_DESTTREE_}/bin ]] ; then
+       install -d "${ED}${_E_DESTTREE_}/bin" || { __helpers_die "${0##*/}: 
failed to install ${ED}${_E_DESTTREE_}/bin"; exit 2; }
 fi
 
 ret=0
 
 for x in "$@" ; do
        if [[ -e ${x} ]] ; then
-               install -m0755 -o ${PORTAGE_INST_UID:-0} -g 
${PORTAGE_INST_GID:-0} "${x}" "${ED}${DESTTREE}/bin"
+               install -m0755 -o ${PORTAGE_INST_UID:-0} -g 
${PORTAGE_INST_GID:-0} "${x}" "${ED}${_E_DESTTREE_}/bin"
        else
                echo "!!! ${0##*/}: $x does not exist" 1>&2
                false
diff --git a/bin/ebuild-helpers/doconfd b/bin/ebuild-helpers/doconfd
index 926c31839..38cf58234 100755
--- a/bin/ebuild-helpers/doconfd
+++ b/bin/ebuild-helpers/doconfd
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 if [[ $# -lt 1 ]] ; then
@@ -8,4 +8,4 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-INSDESTTREE='/etc/conf.d/' exec doins "$@"
+_E_INSDESTTREE_='/etc/conf.d/' exec doins "$@"
diff --git a/bin/ebuild-helpers/doenvd b/bin/ebuild-helpers/doenvd
index eb31f375b..a15cec7f2 100755
--- a/bin/ebuild-helpers/doenvd
+++ b/bin/ebuild-helpers/doenvd
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 if [[ $# -lt 1 ]] ; then
@@ -8,4 +8,4 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-INSDESTTREE='/etc/env.d/' exec doins "$@"
+_E_INSDESTTREE_='/etc/env.d/' exec doins "$@"
diff --git a/bin/ebuild-helpers/doheader b/bin/ebuild-helpers/doheader
index b827086ec..03bf23b1c 100755
--- a/bin/ebuild-helpers/doheader
+++ b/bin/ebuild-helpers/doheader
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
@@ -13,4 +13,4 @@ if [[ $# -lt 1 ]] || [[ $1 == -r && $# -lt 2 ]] ; then
        exit 1
 fi
 
-INSDESTTREE='/usr/include/' exec doins "$@"
+_E_INSDESTTREE_='/usr/include/' exec doins "$@"
diff --git a/bin/ebuild-helpers/doins b/bin/ebuild-helpers/doins
index 73c9d8b91..327d409a4 100755
--- a/bin/ebuild-helpers/doins
+++ b/bin/ebuild-helpers/doins
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
@@ -15,7 +15,15 @@ if [[ ${helper} == dodoc ]] ; then
                exit 0
        fi
        export INSOPTIONS=-m0644
-       export INSDESTTREE=usr/share/doc/${PF}/${_E_DOCDESTTREE_}
+       export _E_INSDESTTREE_=usr/share/doc/${PF}/${_E_DOCDESTTREE_}
+else
+       if ! ___eapi_has_DESTTREE_INSDESTTREE; then
+               [[ -n ${INSDESTTREE} ]] &&
+                       die "${0##*/}: \${INSDESTTREE} has been banned for EAPI 
'$EAPI'; use 'into' instead"
+       else
+               # backwards compatibility
+               _E_INSDESTTREE_=${INSDESTTREE}
+       fi
 fi
 
 if [ $# -lt 1 ] ; then
@@ -33,10 +41,10 @@ if ! ___eapi_has_prefix_variables; then
        export ED="${D}"
 fi
 
-if [[ ${INSDESTTREE#${ED}} != "${INSDESTTREE}" ]]; then
+if [[ ${_E_INSDESTTREE_#${ED}} != "${_E_INSDESTTREE_}" ]]; then
        __vecho "-------------------------------------------------------" 1>&2
        __vecho "You should not use \${D} or \${ED} with helpers." 1>&2
-       __vecho "  --> ${INSDESTTREE}" 1>&2
+       __vecho "  --> ${_E_INSDESTTREE_}" 1>&2
        __vecho "-------------------------------------------------------" 1>&2
        __helpers_die "${helper} used with \${D} or \${ED}"
        exit 1
@@ -75,7 +83,7 @@ fi
 
 DOINS_ARGS+=(
        "--helper=${helper}"
-       "--dest=${ED}${INSDESTTREE}"
+       "--dest=${ED}${_E_INSDESTTREE_}"
 )
 
 # Explicitly set PYTHONPATH to non empty.
diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
index 4be4aa4ea..30fe25e84 100755
--- a/bin/ebuild-helpers/dolib
+++ b/bin/ebuild-helpers/dolib
@@ -13,6 +13,14 @@ if ! ___eapi_has_prefix_variables; then
        ED=${D}
 fi
 
+if ! ___eapi_has_DESTTREE_INSDESTTREE; then
+       [[ -n ${DESTTREE} ]] &&
+               die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; 
use 'into' instead"
+else
+       # backwards compatibility
+       _E_DESTTREE_=${DESTTREE}
+fi
+
 # Setup ABI cruft
 LIBDIR_VAR="LIBDIR_${ABI}"
 if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
@@ -21,7 +29,7 @@ fi
 unset LIBDIR_VAR
 # we need this to default to lib so that things dont break
 CONF_LIBDIR=${CONF_LIBDIR:-lib}
-libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
+libdir="${ED}${_E_DESTTREE_}/${CONF_LIBDIR}"
 
 
 if [[ $# -lt 1 ]] ; then
diff --git a/bin/ebuild-helpers/dolib.a b/bin/ebuild-helpers/dolib.a
index 9c1cbeca1..b93b425d4 100755
--- a/bin/ebuild-helpers/dolib.a
+++ b/bin/ebuild-helpers/dolib.a
@@ -8,6 +8,14 @@ if ! ___eapi_has_prefix_variables; then
        ED=${D}
 fi
 
+if ! ___eapi_has_DESTTREE_INSDESTTREE; then
+       [[ -n ${DESTTREE} ]] &&
+               die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; 
use 'into' instead"
+else
+       # backwards compatibility
+       _E_DESTTREE_=${DESTTREE}
+fi
+
 # Setup ABI cruft
 LIBDIR_VAR="LIBDIR_${ABI}"
 if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
@@ -16,7 +24,7 @@ fi
 unset LIBDIR_VAR
 # we need this to default to lib so that things dont break
 CONF_LIBDIR=${CONF_LIBDIR:-lib}
-libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
+libdir="${ED}${_E_DESTTREE_}/${CONF_LIBDIR}"
 
 
 if [[ $# -lt 1 ]] ; then
diff --git a/bin/ebuild-helpers/dolib.so b/bin/ebuild-helpers/dolib.so
index e99962ae4..f86520e57 100755
--- a/bin/ebuild-helpers/dolib.so
+++ b/bin/ebuild-helpers/dolib.so
@@ -8,6 +8,14 @@ if ! ___eapi_has_prefix_variables; then
        ED=${D}
 fi
 
+if ! ___eapi_has_DESTTREE_INSDESTTREE; then
+       [[ -n ${DESTTREE} ]] &&
+               die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; 
use 'into' instead"
+else
+       # backwards compatibility
+       _E_DESTTREE_=${DESTTREE}
+fi
+
 # Setup ABI cruft
 LIBDIR_VAR="LIBDIR_${ABI}"
 if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
@@ -16,7 +24,7 @@ fi
 unset LIBDIR_VAR
 # we need this to default to lib so that things dont break
 CONF_LIBDIR=${CONF_LIBDIR:-lib}
-libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
+libdir="${ED}${_E_DESTTREE_}/${CONF_LIBDIR}"
 
 
 if [[ $# -lt 1 ]] ; then
diff --git a/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo
index e08e55a3a..70f93d61e 100755
--- a/bin/ebuild-helpers/domo
+++ b/bin/ebuild-helpers/domo
@@ -14,13 +14,21 @@ if ! ___eapi_has_prefix_variables; then
        ED=${D}
 fi
 
+if ! ___eapi_has_DESTTREE_INSDESTTREE; then
+       [[ -n ${DESTTREE} ]] &&
+               die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; 
use 'into' instead"
+else
+       # backwards compatibility
+       _E_DESTTREE_=${DESTTREE}
+fi
+
 # newer EAPIs force /usr consistently with other /usr/share helpers
 if ! ___eapi_domo_respects_into; then
-       DESTTREE=/usr
+       _E_DESTTREE_=/usr
 fi
 
-if [ ! -d "${ED}${DESTTREE}/share/locale" ] ; then
-       install -d "${ED}${DESTTREE}/share/locale/"
+if [ ! -d "${ED}${_E_DESTTREE_}/share/locale" ] ; then
+       install -d "${ED}${_E_DESTTREE_}/share/locale/"
 fi
 
 ret=0
@@ -28,7 +36,7 @@ ret=0
 for x in "$@" ; do
        if [ -e "${x}" ] ; then
                mytiny="${x##*/}"
-               mydir="${ED}${DESTTREE}/share/locale/${mytiny%.*}/LC_MESSAGES"
+               
mydir="${ED}${_E_DESTTREE_}/share/locale/${mytiny%.*}/LC_MESSAGES"
                if [ ! -d "${mydir}" ] ; then
                        install -d "${mydir}"
                fi
diff --git a/bin/ebuild-helpers/dosbin b/bin/ebuild-helpers/dosbin
index 2fee9d4e9..f698f6fbb 100755
--- a/bin/ebuild-helpers/dosbin
+++ b/bin/ebuild-helpers/dosbin
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
@@ -13,15 +13,23 @@ if ! ___eapi_has_prefix_variables; then
        ED=${D}
 fi
 
-if [[ ! -d ${ED}${DESTTREE}/sbin ]] ; then
-       install -d "${ED}${DESTTREE}/sbin" || { __helpers_die "${0##*/}: failed 
to install ${ED}${DESTTREE}/sbin"; exit 2; }
+if ! ___eapi_has_DESTTREE_INSDESTTREE; then
+       [[ -n ${DESTTREE} ]] &&
+               die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; 
use 'into' instead"
+else
+       # backwards compatibility
+       _E_DESTTREE_=${DESTTREE}
+fi
+
+if [[ ! -d ${ED}${_E_DESTTREE_}/sbin ]] ; then
+       install -d "${ED}${_E_DESTTREE_}/sbin" || { __helpers_die "${0##*/}: 
failed to install ${ED}${_E_DESTTREE_}/sbin"; exit 2; }
 fi
 
 ret=0
 
 for x in "$@" ; do
        if [[ -e ${x} ]] ; then
-               install -m0755 -o ${PORTAGE_INST_UID:-0} -g 
${PORTAGE_INST_GID:-0} "${x}" "${ED}${DESTTREE}/sbin"
+               install -m0755 -o ${PORTAGE_INST_UID:-0} -g 
${PORTAGE_INST_GID:-0} "${x}" "${ED}${_E_DESTTREE_}/sbin"
        else
                echo "!!! ${0##*/}: ${x} does not exist" 1>&2
                false
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 0ffabd99e..d95012d6b 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # Hardcoded bash lists are needed for backward compatibility with
@@ -584,8 +584,13 @@ __dyn_install() {
        # Reset exeinto(), docinto(), insinto(), and into() state variables
        # in case the user is running the install phase multiple times
        # consecutively via the ebuild command.
-       export DESTTREE=/usr
-       export INSDESTTREE=""
+       if ___eapi_has_DESTTREE_INSDESTTREE; then
+               export DESTTREE=/usr
+               export INSDESTTREE=""
+       else
+               export _E_DESTTREE_=/usr
+               export _E_INSDESTTREE_=""
+       fi
        export _E_EXEDESTTREE_=""
        export _E_DOCDESTTREE_=""
 
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 12ccf6716..3a2138636 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -2,8 +2,13 @@
 # Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-export DESTTREE=/usr
-export INSDESTTREE=""
+if ___eapi_has_DESTTREE_INSDESTTREE; then
+       export DESTTREE=/usr
+       export INSDESTTREE=""
+else
+       export _E_DESTTREE_=/usr
+       export _E_INSDESTTREE_=""
+fi
 export _E_EXEDESTTREE_=""
 export _E_DOCDESTTREE_=""
 export INSOPTIONS="-m0644"
@@ -18,14 +23,14 @@ declare -a PORTAGE_DOCOMPRESS_SKIP=( 
/usr/share/doc/${PF}/html )
 
 into() {
        if [ "$1" == "/" ]; then
-               export DESTTREE=""
+               export _E_DESTTREE_=""
        else
-               export DESTTREE=$1
+               export _E_DESTTREE_=$1
                if ! ___eapi_has_prefix_variables; then
                        local ED=${D}
                fi
-               if [ ! -d "${ED}${DESTTREE}" ]; then
-                       install -d "${ED}${DESTTREE}"
+               if [ ! -d "${ED}${_E_DESTTREE_}" ]; then
+                       install -d "${ED}${_E_DESTTREE_}"
                        local ret=$?
                        if [[ $ret -ne 0 ]] ; then
                                __helpers_die "${FUNCNAME[0]} failed"
@@ -33,18 +38,22 @@ into() {
                        fi
                fi
        fi
+
+       if ___eapi_has_DESTTREE_INSDESTTREE; then
+               export DESTTREE=${_E_DESTTREE_}
+       fi
 }
 
 insinto() {
        if [ "$1" == "/" ]; then
-               export INSDESTTREE=""
+               export _E_INSDESTTREE_=""
        else
-               export INSDESTTREE=$1
+               export _E_INSDESTTREE_=$1
                if ! ___eapi_has_prefix_variables; then
                        local ED=${D}
                fi
-               if [ ! -d "${ED}${INSDESTTREE}" ]; then
-                       install -d "${ED}${INSDESTTREE}"
+               if [ ! -d "${ED}${_E_INSDESTTREE_}" ]; then
+                       install -d "${ED}${_E_INSDESTTREE_}"
                        local ret=$?
                        if [[ $ret -ne 0 ]] ; then
                                __helpers_die "${FUNCNAME[0]} failed"
@@ -52,6 +61,10 @@ insinto() {
                        fi
                fi
        fi
+
+       if ___eapi_has_DESTTREE_INSDESTTREE; then
+               export INSDESTTREE=${_E_INSDESTTREE_}
+       fi
 }
 
 exeinto() {
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index f0bf00130..e5ae8af88 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @FUNCTION: __save_ebuild_env
@@ -13,7 +13,7 @@
 __save_ebuild_env() {
        (
        if has --exclude-init-phases $* ; then
-               unset S _E_DOCDESTTREE_ _E_EXEDESTTREE_ \
+               unset S _E_DESTTREE _E_INSDESTTREE _E_DOCDESTTREE_ 
_E_EXEDESTTREE_ \
                        PORTAGE_DOCOMPRESS_SIZE_LIMIT PORTAGE_DOCOMPRESS \
                        PORTAGE_DOCOMPRESS_SKIP
                if [[ -n $PYTHONPATH &&
-- 
2.16.2


Reply via email to