$ grep ROOTPATH= /etc/env.d/* /etc/env.d/05gcc-i686-pc-linux-gnu:ROOTPATH="/usr/i686-pc-linux-gnu/gcc-bin/4.9.2" /etc/env.d/10llvm-9992:ROOTPATH="/usr/lib/llvm/7/bin" /etc/env.d/10llvm-9993:ROOTPATH="/usr/lib/llvm/6/bin" /etc/env.d/10llvm-9994:ROOTPATH="/usr/lib/llvm/5/bin" /etc/env.d/50baselayout:ROOTPATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin" With modern baselayout, this means that root's environment will have PATH constructed from all those, in order. Most notably, all LLVM directories will be before standard system bindirs. However, Portage seems to additionally prepend those standard paths before env.d, creating path such as e.g.: /usr/lib/ccache/bin /usr/lib/portage/python3.7/ebuild-helpers /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/i686-pc-linux-gnu/gcc-bin/4.9.2 /usr/lib/llvm/7/bin /usr/lib/llvm/6/bin /usr/lib/llvm/5/bin /usr/local/sbin ...
Some de-duplication logic might do the trick.
Maybe something like this: > diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py > index 941a597e2..f27ed897f 100644 > --- a/lib/portage/package/ebuild/doebuild.py > +++ b/lib/portage/package/ebuild/doebuild.py > @@ -214,2 +214,3 @@ def _doebuild_path(settings, eapi=None): > rootpath = [x for x in settings.get("ROOTPATH", "").split(":") if x] > + rootpath_set = frozenset(rootpath) > overrides = [x for x in settings.get( > @@ -245,3 +246,5 @@ def _doebuild_path(settings, eapi=None): > for x in ("usr/local/sbin", "usr/local/bin", "usr/sbin", "usr/bin", "sbin", "bin"): > - path.append(os.path.join(prefix, x)) > + x_abs = os.path.join(prefix, x) > + if x_abs not in rootpath_set: > + path.append(x_abs)
Looks good at a first glance.
Patch posted for review: https://archives.gentoo.org/gentoo-portage-dev/message/7b602d63d3cc6361b50957a387c2651f https://github.com/gentoo/portage/pull/375
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=01b8e9277b3f6970ea09135def26b70dbf072a16 commit 01b8e9277b3f6970ea09135def26b70dbf072a16 Author: Zac Medico <zmedico@gentoo.org> AuthorDate: 2018-10-08 02:37:59 +0000 Commit: Zac Medico <zmedico@gentoo.org> CommitDate: 2018-10-08 04:29:34 +0000 _doebuild_path: Respect order defined in ROOTPATH (bug 667662) Respect the order of paths defined in /etc/env.d/*, so that packages like llvm can rely on ordering relative to paths defined in /etc/env.d/50baselayout since baselayout-2.6. See: https://gitweb.gentoo.org/proj/baselayout.git/commit/?id=277e5b9e55717873b87eb541a95f4f2ae0c60a4d Bug: https://bugs.gentoo.org/667662 Signed-off-by: Zac Medico <zmedico@gentoo.org> lib/portage/package/ebuild/doebuild.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)