Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/
Date: Mon, 02 Jan 2023 20:46:02
Message-Id: 1672691727.69f2221413852630b2c231774e1f811f350fa3e6.floppym@gentoo
1 commit: 69f2221413852630b2c231774e1f811f350fa3e6
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 31 22:01:08 2022 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 2 20:35:27 2023 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=69f22214
7
8 _doebuild_path: simplify logic used to set PATH
9
10 Remove logic to incoporate PREROOTPATH and ROOTPATH. I'm not sure where
11 PREROOTPATH was ever used, and ROOTPATH has been deprecated in
12 baselayout for a while.
13
14 Remove logic to add hard-coded directories like
15 ${EPREFIX}/{,usr{,/local}/{sbin,bin}. Adding these paths is unnecessary
16 if env.d or the calling environment have a valid PATH setting.
17
18 Add logic to ignore PATH from the calling environment if PATH is set in
19 env.d. This ensures that packages can update PATH by installing files in
20 /etc/env.d and this will work without having to restart Portage with an
21 updated environment.
22
23 Bug: https://bugs.gentoo.org/607696
24 Bug: https://bugs.gentoo.org/693308
25 Bug: https://bugs.gentoo.org/888543
26 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
27
28 lib/portage/package/ebuild/doebuild.py | 44 +++++++++++-----------------------
29 1 file changed, 14 insertions(+), 30 deletions(-)
30
31 diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py
32 index 05336e2aa..d29451efa 100644
33 --- a/lib/portage/package/ebuild/doebuild.py
34 +++ b/lib/portage/package/ebuild/doebuild.py
35 @@ -284,20 +284,8 @@ def _doebuild_path(settings, eapi=None):
36 if portage_bin_path[0] != portage.const.PORTAGE_BIN_PATH:
37 # Add a fallback path for restarting failed builds (bug 547086)
38 portage_bin_path.append(portage.const.PORTAGE_BIN_PATH)
39 - prerootpath = [x for x in settings.get("PREROOTPATH", "").split(":") if x]
40 - rootpath = [x for x in settings.get("ROOTPATH", "").split(":") if x]
41 - rootpath_set = frozenset(rootpath)
42 - overrides = [
43 - x for x in settings.get("__PORTAGE_TEST_PATH_OVERRIDE", "").split(":") if x
44 - ]
45 -
46 - prefixes = []
47 - # settings["EPREFIX"] should take priority over portage.const.EPREFIX
48 - if portage.const.EPREFIX != settings["EPREFIX"] and settings["ROOT"] == os.sep:
49 - prefixes.append(settings["EPREFIX"])
50 - prefixes.append(portage.const.EPREFIX)
51
52 - path = overrides
53 + path = [x for x in settings.get("__PORTAGE_TEST_PATH_OVERRIDE", "").split(":") if x]
54
55 if "xattr" in settings.features:
56 for x in portage_bin_path:
57 @@ -317,24 +305,20 @@ def _doebuild_path(settings, eapi=None):
58
59 for x in portage_bin_path:
60 path.append(os.path.join(x, "ebuild-helpers"))
61 - path.extend(prerootpath)
62 -
63 - for prefix in prefixes:
64 - prefix = prefix if prefix else "/"
65 - for x in (
66 - "usr/local/sbin",
67 - "usr/local/bin",
68 - "usr/sbin",
69 - "usr/bin",
70 - "sbin",
71 - "bin",
72 - ):
73 - # Respect order defined in ROOTPATH
74 - x_abs = os.path.join(prefix, x)
75 - if x_abs not in rootpath_set:
76 - path.append(x_abs)
77
78 - path.extend(rootpath)
79 + # If PATH is set in env.d, ignore PATH from the calling environment.
80 + # This allows packages to update our PATH as they get installed.
81 + if "PATH" in settings.configdict["env.d"]:
82 + settings.configdict["env"].pop("PATH", None)
83 +
84 + if "PATH" in settings:
85 + pathset = set(path)
86 + for p in settings["PATH"].split(":"):
87 + # Avoid duplicate entries.
88 + if p not in pathset:
89 + path.append(p)
90 + pathset.add(p)
91 +
92 settings["PATH"] = ":".join(path)