commit:     58c27aec81262d6840e36f2f56c32bec68c414c1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 29 23:35:47 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Dec  2 18:29:35 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=58c27aec

ebuild.sh: fix pkg_setup env for binary packages (528274)

In commit 743b3337644fbb3ea461d3a9137c9ac85e163f03, support for binary
packages broke, since binary packages must load the environment from
$T/environment. This patch fixes the logic to handle binary packages
correctly.

Fixes: 743b3337644f ("ebuild.sh: force fresh env for pkg_setup (528274)")
X-Gentoo-Bug: 528274
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=528274
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

---
 bin/ebuild.sh                          | 6 ++++--
 pym/portage/package/ebuild/config.py   | 4 +++-
 pym/portage/package/ebuild/doebuild.py | 7 +++++--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 232bf44..2ed1335 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -501,7 +501,8 @@ fi
 export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)}
 trap 'exit 1' SIGTERM
 
-if ! has "$EBUILD_PHASE" clean cleanrm depend setup && \
+if ! has "$EBUILD_PHASE" clean cleanrm depend && \
+       ! [[ $EMERGE_FROM = ebuild && $EBUILD_PHASE = setup ]] && \
        [ -f "${T}"/environment ] ; then
        # The environment may have been extracted from environment.bz2 or
        # may have come from another version of ebuild.sh or something.
@@ -550,7 +551,8 @@ eval 
"PORTAGE_ECLASS_LOCATIONS=(${PORTAGE_ECLASS_LOCATIONS})"
 # Source the ebuild every time for FEATURES=noauto, so that ebuild
 # modifications take effect immediately.
 if ! has "$EBUILD_PHASE" clean cleanrm ; then
-       if [[ $EBUILD_PHASE =~ ^(depend|setup)$ || ! -f $T/environment || \
+       if [[ $EBUILD_PHASE = setup && $EMERGE_FROM = ebuild ]] || \
+               [[ $EBUILD_PHASE = depend || ! -f $T/environment || \
                -f $PORTAGE_BUILDDIR/.ebuild_changed || \
                " ${FEATURES} " == *" noauto "* ]] ; then
                # The bashrcs get an opportunity here to set aliases that will 
be expanded

diff --git a/pym/portage/package/ebuild/config.py 
b/pym/portage/package/ebuild/config.py
index ca15f81..59e239b 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -2663,9 +2663,11 @@ class config(object):
                eapi = self.get('EAPI')
                eapi_attrs = _get_eapi_attrs(eapi)
                phase = self.get('EBUILD_PHASE')
+               emerge_from = self.get('EMERGE_FROM')
                filter_calling_env = False
                if self.mycpv is not None and \
-                       phase not in ('clean', 'cleanrm', 'depend', 'fetch', 
'setup'):
+                       not (emerge_from == 'ebuild' and phase == 'setup') and \
+                       phase not in ('clean', 'cleanrm', 'depend', 'fetch'):
                        temp_dir = self.get('T')
                        if temp_dir is not None and \
                                os.path.exists(os.path.join(temp_dir, 
'environment')):

diff --git a/pym/portage/package/ebuild/doebuild.py 
b/pym/portage/package/ebuild/doebuild.py
index 6df3c69..bf97660 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -913,12 +913,15 @@ def doebuild(myebuild, mydo, _unused=DeprecationWarning, 
settings=None, debug=0,
                if eapi_exports_merge_type(mysettings["EAPI"]) and \
                        "MERGE_TYPE" not in mysettings.configdict["pkg"]:
                        if tree == "porttree":
-                               mysettings.configdict["pkg"]["EMERGE_FROM"] = 
"ebuild"
                                mysettings.configdict["pkg"]["MERGE_TYPE"] = 
"source"
                        elif tree == "bintree":
-                               mysettings.configdict["pkg"]["EMERGE_FROM"] = 
"binary"
                                mysettings.configdict["pkg"]["MERGE_TYPE"] = 
"binary"
 
+               if tree == "porttree":
+                       mysettings.configdict["pkg"]["EMERGE_FROM"] = "ebuild"
+               elif tree == "bintree":
+                       mysettings.configdict["pkg"]["EMERGE_FROM"] = "binary"
+
                # NOTE: It's not possible to set REPLACED_BY_VERSION for prerm
                #       and postrm here, since we don't necessarily know what
                #       versions are being installed. This could be a problem

Reply via email to