commit: 69f2221413852630b2c231774e1f811f350fa3e6
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 31 22:01:08 2022 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Mon Jan 2 20:35:27 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=69f22214
_doebuild_path: simplify logic used to set PATH
Remove logic to incoporate PREROOTPATH and ROOTPATH. I'm not sure where
PREROOTPATH was ever used, and ROOTPATH has been deprecated in
baselayout for a while.
Remove logic to add hard-coded directories like
${EPREFIX}/{,usr{,/local}/{sbin,bin}. Adding these paths is unnecessary
if env.d or the calling environment have a valid PATH setting.
Add logic to ignore PATH from the calling environment if PATH is set in
env.d. This ensures that packages can update PATH by installing files in
/etc/env.d and this will work without having to restart Portage with an
updated environment.
Bug: https://bugs.gentoo.org/607696
Bug: https://bugs.gentoo.org/693308
Bug: https://bugs.gentoo.org/888543
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
lib/portage/package/ebuild/doebuild.py | 44 +++++++++++-----------------------
1 file changed, 14 insertions(+), 30 deletions(-)
diff --git a/lib/portage/package/ebuild/doebuild.py
b/lib/portage/package/ebuild/doebuild.py
index 05336e2aa..d29451efa 100644
--- a/lib/portage/package/ebuild/doebuild.py
+++ b/lib/portage/package/ebuild/doebuild.py
@@ -284,20 +284,8 @@ def _doebuild_path(settings, eapi=None):
if portage_bin_path[0] != portage.const.PORTAGE_BIN_PATH:
# Add a fallback path for restarting failed builds (bug 547086)
portage_bin_path.append(portage.const.PORTAGE_BIN_PATH)
- prerootpath = [x for x in settings.get("PREROOTPATH", "").split(":") if x]
- rootpath = [x for x in settings.get("ROOTPATH", "").split(":") if x]
- rootpath_set = frozenset(rootpath)
- overrides = [
- x for x in settings.get("__PORTAGE_TEST_PATH_OVERRIDE", "").split(":")
if x
- ]
-
- prefixes = []
- # settings["EPREFIX"] should take priority over portage.const.EPREFIX
- if portage.const.EPREFIX != settings["EPREFIX"] and settings["ROOT"] ==
os.sep:
- prefixes.append(settings["EPREFIX"])
- prefixes.append(portage.const.EPREFIX)
- path = overrides
+ path = [x for x in settings.get("__PORTAGE_TEST_PATH_OVERRIDE",
"").split(":") if x]
if "xattr" in settings.features:
for x in portage_bin_path:
@@ -317,24 +305,20 @@ def _doebuild_path(settings, eapi=None):
for x in portage_bin_path:
path.append(os.path.join(x, "ebuild-helpers"))
- path.extend(prerootpath)
-
- for prefix in prefixes:
- prefix = prefix if prefix else "/"
- for x in (
- "usr/local/sbin",
- "usr/local/bin",
- "usr/sbin",
- "usr/bin",
- "sbin",
- "bin",
- ):
- # Respect order defined in ROOTPATH
- x_abs = os.path.join(prefix, x)
- if x_abs not in rootpath_set:
- path.append(x_abs)
- path.extend(rootpath)
+ # If PATH is set in env.d, ignore PATH from the calling environment.
+ # This allows packages to update our PATH as they get installed.
+ if "PATH" in settings.configdict["env.d"]:
+ settings.configdict["env"].pop("PATH", None)
+
+ if "PATH" in settings:
+ pathset = set(path)
+ for p in settings["PATH"].split(":"):
+ # Avoid duplicate entries.
+ if p not in pathset:
+ path.append(p)
+ pathset.add(p)
+
settings["PATH"] = ":".join(path)