summaryrefslogtreecommitdiffstats
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
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.
-rwxr-xr-xbin/ebuild.sh19
-rw-r--r--bin/phase-functions.sh1
-rw-r--r--pym/portage/package/ebuild/doebuild.py46
3 files changed, 37 insertions, 29 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 8ca7a4121..226b9f6e5 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -5,13 +5,6 @@
PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"
PORTAGE_PYM_PATH="${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}"
-ROOTPATH=${ROOTPATH##:}
-ROOTPATH=${ROOTPATH%%:}
-PREROOTPATH=${PREROOTPATH##:}
-PREROOTPATH=${PREROOTPATH%%:}
-PATH=$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin${ROOTPATH:+:}$ROOTPATH
-export PATH
-
# Prevent aliases from causing portage to act inappropriately.
# Make sure it's before everything so we don't mess aliases that follow.
unalias -a
@@ -585,18 +578,6 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
if [[ $EBUILD_PHASE != depend ]] ; then
- case "$EAPI" in
- 0|1|2|3)
- _ebuild_helpers_path="$PORTAGE_BIN_PATH/ebuild-helpers"
- ;;
- *)
- _ebuild_helpers_path="$PORTAGE_BIN_PATH/ebuild-helpers/4:$PORTAGE_BIN_PATH/ebuild-helpers"
- ;;
- esac
-
- PATH=$_ebuild_helpers_path:$PREROOTPATH${PREROOTPATH:+:}/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin${ROOTPATH:+:}$ROOTPATH
- unset _ebuild_helpers_path
-
_eprefix=${EPREFIX}
case "$EAPI" in 0|1|2) _eprefix= ;; esac
# Use default ABI libdir in accordance with bug #355283.
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index f46368d68..a686dcdc7 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -229,6 +229,7 @@ dyn_unpack() {
return 0
fi
if [ ! -d "${WORKDIR}" ]; then
+ echo PATH=$PATH
install -m${PORTAGE_WORKDIR_MODE:-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
fi
cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`"
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.