summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-11-08 16:21:07 -0800
committerZac Medico <zmedico@gentoo.org>2011-11-08 16:21:07 -0800
commit75768ea8c922c0266829458025e4b2d35ff49804 (patch)
tree00b37324920b51bd09e9554f9967b979d17e4c65 /pym
parent62a402337c6d43c448ff0b5657ada26ff004d421 (diff)
downloadportage-75768ea8c922c0266829458025e4b2d35ff49804.tar.gz
portage-75768ea8c922c0266829458025e4b2d35ff49804.tar.bz2
portage-75768ea8c922c0266829458025e4b2d35ff49804.zip
Include EPREFIX directories in PATH.
This relocates the PATH generation code from ebuild.sh to doebuild_environment, which helps to eliminate duplicate code.
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/package/ebuild/doebuild.py46
1 files changed, 36 insertions, 10 deletions
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index cb7da78c7..da95a63ac 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -115,6 +115,38 @@ def _spawn_phase(phase, settings, actionmap=None, **kwargs):
ebuild_phase.wait()
return ebuild_phase.returncode
+def _doebuild_path(settings, eapi=None):
+ """
+ Generate the PATH variable.
+ """
+
+ # Note: PORTAGE_BIN_PATH may differ from the global constant
+ # when portage is reinstalling itself.
+ portage_bin_path = settings["PORTAGE_BIN_PATH"]
+ eprefix = settings["EPREFIX"]
+ prerootpath = [x for x in settings.get("PREROOTPATH", "").split(":") if x]
+ rootpath = [x for x in settings.get("ROOTPATH", "").split(":") if x]
+
+ prefixes = []
+ if eprefix:
+ prefixes.append(eprefix)
+ prefixes.append("/")
+
+ path = []
+
+ if eapi not in (None, "0", "1", "2"):
+ path.append(os.path.join(portage_bin_path, "ebuild-helpers", "4"))
+
+ path.append(os.path.join(portage_bin_path, "ebuild-helpers"))
+ path.extend(prerootpath)
+
+ for prefix in prefixes:
+ for x in ("usr/local/sbin", "usr/local/bin", "usr/sbin", "usr/bin", "sbin", "bin"):
+ path.append(os.path.join(prefix, x))
+
+ path.extend(rootpath)
+ settings["PATH"] = ":".join(path)
+
def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
debug=False, use_cache=None, db=None):
"""
@@ -234,16 +266,6 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
else:
mysettings["PVR"]=mysplit[1]+"-"+mysplit[2]
- if "PATH" in mysettings:
- mysplit=mysettings["PATH"].split(":")
- else:
- mysplit=[]
- # Note: PORTAGE_BIN_PATH may differ from the global constant
- # when portage is reinstalling itself.
- portage_bin_path = mysettings["PORTAGE_BIN_PATH"]
- if portage_bin_path not in mysplit:
- mysettings["PATH"] = portage_bin_path + ":" + mysettings["PATH"]
-
# All temporary directories should be subdirectories of
# $PORTAGE_TMPDIR/portage, since it's common for /tmp and /var/tmp
# to be mounted with the "noexec" option (see bug #346899).
@@ -311,6 +333,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
if eapi is not None:
if not eapi_is_supported(eapi):
+ _doebuild_path(mysettings)
raise UnsupportedAPIException(mycpv, eapi)
mysettings.configdict['pkg']['EAPI'] = eapi
@@ -320,6 +343,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
eapi = mysettings["EAPI"]
if not eapi_is_supported(eapi):
# can't do anything with this.
+ _doebuild_path(mysettings)
raise UnsupportedAPIException(mycpv, eapi)
if hasattr(mydbapi, "getFetchMap") and \
@@ -346,6 +370,8 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
else:
mysettings.configdict["pkg"]["AA"] = " ".join(uri_map)
+ _doebuild_path(mysettings, eapi=eapi)
+
if not eapi_exports_KV(eapi):
# Discard KV for EAPIs that don't support it. Cache KV is restored
# from the backupenv whenever config.reset() is called.