Make USE=prefix enable EPREFIX in all EAPIs.
authorZac Medico <zmedico@gentoo.org>
Thu, 8 Dec 2011 06:22:31 +0000 (22:22 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 8 Dec 2011 06:22:31 +0000 (22:22 -0800)
This is safe because the prefix flag should be masked in all non-prefix
profiles, and older EAPIs would otherwise be useless with prefix
configurations. This brings compatibility with the prefix branch of
portage, which also supports EPREFIX for all EAPIs (for obvious
reasons).

30 files changed:
bin/ebuild-helpers/dobin
bin/ebuild-helpers/dodir
bin/ebuild-helpers/dodoc
bin/ebuild-helpers/doexe
bin/ebuild-helpers/dohard
bin/ebuild-helpers/doinfo
bin/ebuild-helpers/doins
bin/ebuild-helpers/dolib
bin/ebuild-helpers/doman
bin/ebuild-helpers/domo
bin/ebuild-helpers/dosbin
bin/ebuild-helpers/dosed
bin/ebuild-helpers/dosym
bin/ebuild-helpers/ecompressdir
bin/ebuild-helpers/fowners
bin/ebuild-helpers/fperms
bin/ebuild-helpers/prepall
bin/ebuild-helpers/prepalldocs
bin/ebuild-helpers/prepallinfo
bin/ebuild-helpers/prepallman
bin/ebuild-helpers/prepallstrip
bin/ebuild-helpers/prepinfo
bin/ebuild-helpers/preplib
bin/ebuild-helpers/prepman
bin/ebuild-helpers/prepstrip
bin/ebuild.sh
bin/misc-functions.sh
bin/phase-functions.sh
bin/phase-helpers.sh
pym/portage/package/ebuild/config.py

index af3af0d841783aacf1a86d7ebc16bf6efcde4b20..7ea29d4d4d5d14858b9df3b73640f2ca6f24f449 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
@@ -9,7 +9,8 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if [[ ! -d ${ED}${DESTTREE}/bin ]] ; then
        install -d "${ED}${DESTTREE}/bin" || { helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/bin"; exit 2; }
index 7db7cafb141b10590f50bf3e0e5a6f6f55182ea9..5bedd05c9ec6c7efeb29d16e1c47cf15f9ce1cf2 100755 (executable)
@@ -4,7 +4,8 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 install -d ${DIROPTIONS} "${@/#/${ED}/}"
 ret=$?
index 37bbc79d037b947d473ecf201875dc6c9da59bf1..6280536e5d7efb00e19e8c8c70f680b8f82f338b 100755 (executable)
@@ -9,7 +9,8 @@ if [ $# -lt 1 ] ; then
        exit 1  
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 dir="${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
 if [ ! -d "${dir}" ] ; then
index a5b9af0ebc04ea72a20febdd043425c313737a73..65f355af9a377823a12c981fba7a80e2046317fd 100755 (executable)
@@ -9,7 +9,8 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if [[ ! -d ${ED}${_E_EXEDESTTREE_} ]] ; then
        install -d "${ED}${_E_EXEDESTTREE_}"
index cf6fb112dff8a47f731aa6b9f186fb4b03724a56..7a6fc76980be4048e93033450b3a799673c8b9f8 100755 (executable)
@@ -7,7 +7,8 @@ if [[ $# -ne 2 ]] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 destdir=${2%/*}
 [[ ! -d ${ED}${destdir} ]] && dodir "${destdir}"
index a922ef1be307ae11e47295b7715445b1e8f3a3be..c4b767e9b5deb881b87560d0209772b9d87a3e2e 100755 (executable)
@@ -9,7 +9,8 @@ if [[ -z $1 ]] ; then
        exit 1  
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if [[ ! -d ${ED}usr/share/info ]] ; then
        install -d "${ED}usr/share/info" || { helpers_die "${0##*/}: failed to install ${ED}usr/share/info"; exit 1; }
index b9189d5ed90a076e7349462736e5824b82444658..c3af28905921f79bf074a77a548480e289a92f3f 100755 (executable)
@@ -27,7 +27,8 @@ else
        DOINSRECUR=n
 fi
 
-case "$EAPI" in 0|1|2) export ED="${D}" ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) export ED="${D}" ;; esac
 
 if [[ ${INSDESTTREE#${ED}} != "${INSDESTTREE}" ]]; then
        vecho "-------------------------------------------------------" 1>&2
index 9dd11d85703e32f4b40180b80146105e9f11f567..8357dfaa98c00257a2f18606cbb7988ad2a3ddac 100755 (executable)
@@ -4,7 +4,8 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 # Setup ABI cruft
 LIBDIR_VAR="LIBDIR_${ABI}"
index 27401f3b3feba6876114bba6884285e7f24f467c..817743d7ec7dc01217815831249a7906dc48b9e8 100755 (executable)
@@ -9,7 +9,8 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 i18n=""
 
index 0e3656d588f3d69533798171b090b8987051fb8a..551785e76513dd60122610e622dd919e687d626a 100755 (executable)
@@ -10,7 +10,8 @@ if [ ${mynum} -lt 1 ] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if [ ! -d "${ED}${DESTTREE}/share/locale" ] ; then
        install -d "${ED}${DESTTREE}/share/locale/"
index d0783ed33a271a08f0c05098a23a7852c99c3630..5606077541d79db2c40b3b15b719fa905d151a58 100755 (executable)
@@ -9,7 +9,8 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if [[ ! -d ${ED}${DESTTREE}/sbin ]] ; then
        install -d "${ED}${DESTTREE}/sbin" || { helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/sbin"; exit 2; }
index 00cf5da17d71127ced55ce5454e84b5e9dbc15a6..200b011fb59aa1fe096f60da12c31cbbd9b8919c 100755 (executable)
@@ -7,7 +7,8 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 ret=0
 file_found=0
index 8b7b304ee869258f20e827e6739abdac4d58abbd..8925001e481912b45ffcae41cdc23faf0db44c7e 100755 (executable)
@@ -9,7 +9,8 @@ if [[ $# -ne 2 ]] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if [[ ${2} == */ ]] || \
        [[ -d ${ED}${2} && ! -L ${ED}${2} ]] ; then
index f9a846a90bc463346413a7c77bd26d09cce10355..937ba268bfac8e695f0b159b98c16880bfa0d3dc 100755 (executable)
@@ -9,7 +9,8 @@ if [[ -z $1 ]] ; then
        exit 1
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 case $1 in
        --ignore)
index 3f51b4e540527eac1fdb66646ffdd2db2378018d..b3e4555cd26ef0a4604476dd02609258410f8273 100755 (executable)
@@ -4,7 +4,8 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 # we can't prefix all arguments because
 # chown takes random options
index 9a2971ae568ede6e16008e868a7437e709a51efb..207cf54a586f6ede578003976f91d8061710e70d 100755 (executable)
@@ -4,7 +4,9 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+
 # we can't prefix all arguments because
 # chmod takes random options
 slash="/"
index 611c4ce79348793c88c33ea7a425d53c4988a81c..512feb33a98d04c3998590d14f821d01d35c37dd 100755 (executable)
@@ -4,7 +4,8 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if has chflags $FEATURES ; then
        # Save all the file flags for restoration at the end of prepall.
index 540d02500baa1aeabbde6a5a4bb1aa74d54bd779..1d0224981ba5a0480f462ef9c858c4b5aa34f6ca 100755 (executable)
@@ -8,7 +8,8 @@ if [[ -n $1 ]] ; then
        vecho "${0##*/}: invalid usage; takes no arguments" 1>&2
 fi
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 [[ -d ${ED}usr/share/doc ]] || exit 0
 
index e351f878bec3348dcd73cef4dd684c0a562fc342..183e1ca62057d5057c10ec2838b805de7b108486 100755 (executable)
@@ -4,7 +4,8 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 [[ -d ${ED}usr/share/info ]] || exit 0
 
index be7f19453d53d47b349bcee2a4b9e70a4b52260e..a5699c2f15805a32bd353874477786c04be5be34 100755 (executable)
@@ -7,7 +7,8 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 # replaced by controllable compression in EAPI 4
 has "${EAPI}" 0 1 2 3 || exit 0
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 ret=0
 
index e9f5f8e3e65a531f6aa4d4e39282f2b9ae9facfe..6032b48c922e797df5cb12da25a3ae87d18f6fd9 100755 (executable)
@@ -2,6 +2,7 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 exec prepstrip "${ED}"
index afe214c6b9e2a66388ff0042e11269eee65cf526..7c60d9b86c063994d0d4b612d846641d128b0d62 100755 (executable)
@@ -4,7 +4,8 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if [[ -z $1 ]] ; then
        infodir="/usr/share/info"
index 8c62921010b17aa16b2b2ffa22897f2afe2db753..cbff76d4c7fe95cd1414a5b38c1216aadef80a87 100755 (executable)
@@ -6,7 +6,8 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
 eqawarn "QA Notice: Deprecated call to 'preplib'"
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 LIBDIR_VAR="LIBDIR_${ABI}"
 if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
index 8ea7607df87f1486a6274616a81317265e3dac5c..18c0f992ae2e7e476ef373192185d3bb4fe9d3c5 100755 (executable)
@@ -4,7 +4,8 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 if [[ -z $1 ]] ; then 
        mandir="${ED}usr/share/man"
index fac20b24f6fd06bf35aa1f5345af7bfa83bf8aca..085c93d56b9a72e6153a72d78b4dead1ef4ec100 100755 (executable)
@@ -18,7 +18,8 @@ exp_tf() {
 exp_tf FEATURES installsources nostrip splitdebug
 exp_tf RESTRICT binchecks installsources strip
 
-case "$EAPI" in 0|1|2) ED=${D} ;; esac
+[[ " ${USE} " == *" prefix "* ]] || \
+       case "$EAPI" in 0|1|2) ED=${D} ;; esac
 
 banner=false
 SKIP_STRIP=false
index a3ac1e0bb5318d4fbae024fe43cb1d08c60e3074..d77b52c853d4400f19115bce2624159d8c064cd6 100755 (executable)
@@ -670,6 +670,8 @@ else
        declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS
        case "$EAPI" in
                0|1|2)
+                       [[ " ${USE} " == *" prefix "* ]] && \
+                               declare -r ED EPREFIX EROOT
                        ;;
                *)
                        declare -r ED EPREFIX EROOT
index 1c11dc51a897866b17368b837d823348fc0caa72..584d16a00613a51cdd74f602ab1835e17c835803 100755 (executable)
@@ -17,7 +17,8 @@ shift $#
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}/ebuild.sh"
 
 install_symlink_html_docs() {
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
        cd "${ED}" || die "cd failed"
        #symlink the html documentation (if DOC_SYMLINKS_DIR is set in make.conf)
        if [ -n "${DOC_SYMLINKS_DIR}" ] ; then
@@ -65,7 +66,8 @@ canonicalize() {
 prepcompress() {
        local -a include exclude incl_d incl_f
        local f g i real_f real_d
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
 
        # Canonicalize path names and check for their existence.
        real_d=$(canonicalize "${ED}")
@@ -147,7 +149,8 @@ prepcompress() {
 
 install_qa_check() {
        local f i x
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
 
        cd "${ED}" || die "cd failed"
 
@@ -886,7 +889,8 @@ preinst_mask() {
                 return 1
        fi
 
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
 
        # Make sure $PWD is not ${D} so that we don't leave gmon.out files
        # in there in case any tools were built with -pg in CFLAGS.
@@ -914,7 +918,8 @@ preinst_sfperms() {
                 return 1
        fi
 
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
 
        # Smart FileSystem Permissions
        if has sfperms $FEATURES; then
@@ -952,7 +957,8 @@ preinst_suid_scan() {
                 return 1
        fi
 
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
 
        # total suid control.
        if has suidctl $FEATURES; then
@@ -1017,7 +1023,8 @@ preinst_selinux_labels() {
 
 dyn_package() {
 
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
 
        # Make sure $PWD is not ${D} so that we don't leave gmon.out files
        # in there in case any tools were built with -pg in CFLAGS.
@@ -1097,7 +1104,8 @@ __END1__
 
 dyn_rpm() {
 
-       case "$EAPI" in 0|1|2) local EPREFIX= ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local EPREFIX= ;; esac
 
        cd "${T}" || die "cd failed"
        local machine_name=$(uname -m)
index f46368d688ebf19a195390a4b55f236cbe0d88f3..351ae9e1d6d8e9f0433e67b200288dca177b3075 100644 (file)
@@ -96,6 +96,8 @@ filter_readonly_variables() {
        # supported by the current EAPI.
        case "${EAPI:-0}" in
                0|1|2)
+                       [[ " ${USE} " == *" prefix "* ]] && \
+                               filtered_vars+=" ED EPREFIX EROOT"
                        ;;
                *)
                        filtered_vars+=" ED EPREFIX EROOT"
@@ -500,7 +502,8 @@ dyn_install() {
        ebuild_phase pre_src_install
 
        _x=${ED}
-       case "$EAPI" in 0|1|2) _x=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) _x=${D} ;; esac
        rm -rf "${D}"
        mkdir -p "${_x}"
        unset _x
index 04cf35aa44bb94b257cbe651fc73b3233261ba87..aadfac17dca0f7f14b1acf928a3011ba0da7b5a8 100644 (file)
@@ -19,7 +19,8 @@ into() {
                export DESTTREE=""
        else
                export DESTTREE=$1
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+               [[ " ${USE} " == *" prefix "* ]] || \
+                       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
                if [ ! -d "${ED}${DESTTREE}" ]; then
                        install -d "${ED}${DESTTREE}"
                        local ret=$?
@@ -36,7 +37,8 @@ insinto() {
                export INSDESTTREE=""
        else
                export INSDESTTREE=$1
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+               [[ " ${USE} " == *" prefix "* ]] || \
+                       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
                if [ ! -d "${ED}${INSDESTTREE}" ]; then
                        install -d "${ED}${INSDESTTREE}"
                        local ret=$?
@@ -53,7 +55,8 @@ exeinto() {
                export _E_EXEDESTTREE_=""
        else
                export _E_EXEDESTTREE_="$1"
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+               [[ " ${USE} " == *" prefix "* ]] || \
+                       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
                if [ ! -d "${ED}${_E_EXEDESTTREE_}" ]; then
                        install -d "${ED}${_E_EXEDESTTREE_}"
                        local ret=$?
@@ -70,7 +73,8 @@ docinto() {
                export _E_DOCDESTTREE_=""
        else
                export _E_DOCDESTTREE_="$1"
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+               [[ " ${USE} " == *" prefix "* ]] || \
+                       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
                if [ ! -d "${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" ]; then
                        install -d "${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
                        local ret=$?
@@ -137,7 +141,8 @@ docompress() {
 keepdir() {
        dodir "$@"
        local x
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
        if [ "$1" == "-R" ] || [ "$1" == "-r" ]; then
                shift
                find "$@" -type d -printf "${ED}%p/.keep_${CATEGORY}_${PN}-${SLOT}\n" \
@@ -374,7 +379,8 @@ unpack() {
 econf() {
        local x
 
-       case "$EAPI" in 0|1|2) local EPREFIX= ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local EPREFIX= ;; esac
 
        _hasg() {
                local x s=$1
@@ -470,7 +476,8 @@ econf() {
 einstall() {
        # CONF_PREFIX is only set if they didn't pass in libdir above.
        local LOCAL_EXTRA_EINSTALL="${EXTRA_EINSTALL}"
-       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       [[ " ${USE} " == *" prefix "* ]] || \
+               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
        LIBDIR_VAR="LIBDIR_${ABI}"
        if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
                CONF_LIBDIR="${!LIBDIR_VAR}"
@@ -600,7 +607,8 @@ has_version() {
        local eroot
        case "$EAPI" in
                0|1|2)
-                       eroot=${ROOT}
+                       [[ " ${USE} " == *" prefix "* ]] && \
+                               eroot=${ROOT%/}${EPREFIX}/ || eroot=${ROOT}
                        ;;
                *)
                        eroot=${ROOT%/}${EPREFIX}/
@@ -634,7 +642,8 @@ best_version() {
        local eroot
        case "$EAPI" in
                0|1|2)
-                       eroot=${ROOT}
+                       [[ " ${USE} " == *" prefix "* ]] && \
+                               eroot=${ROOT%/}${EPREFIX}/ || eroot=${ROOT}
                        ;;
                *)
                        eroot=${ROOT%/}${EPREFIX}/
index 2995740bca12566db1a33cfe67e5823141d899ea..1ccaee7c8f7263b0a41fba19484bf8e32be59bbc 100644 (file)
@@ -2238,8 +2238,17 @@ class config(object):
                if not eapi_exports_merge_type(eapi):
                        mydict.pop("MERGE_TYPE", None)
 
-               # Prefix variables are supported starting with EAPI 3.
-               if phase == 'depend' or eapi is None or not eapi_supports_prefix(eapi):
+               # Prefix variables are supported beginning with EAPI 3, or when EPREFIX
+               # is non-empty (implying that EPREFIX support is required in the
+               # current environment, regardless of EAPI). For EAPIs prior to 3,
+               # ebuild helpers rely on these variables only when USE=prefix is
+               # enabled. This is safe because the prefix flag should be masked in all
+               # non-prefix profiles, and older EAPIs would otherwise be useless with
+               # prefix configurations. This brings compatibility with the prefix
+               # branch of portage, which also supports EPREFIX for all EAPIs (for
+               # obvious reasons).
+               if phase == 'depend' or eapi is None or \
+                       (not eapi_supports_prefix(eapi) and not mydict.get("EPREFIX")):
                        mydict.pop("ED", None)
                        mydict.pop("EPREFIX", None)
                        mydict.pop("EROOT", None)