Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 667662 - sys-apps/portage: (ROOT)PATH reconstruction inconsistent with modern baselayout behavior
Summary: sys-apps/portage: (ROOT)PATH reconstruction inconsistent with modern baselayo...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 666956
  Show dependency tree
 
Reported: 2018-10-03 17:51 UTC by Michał Górny
Modified: 2018-12-08 23:14 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-10-03 17:51:18 UTC
$ 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
  ...
Comment 1 Zac Medico gentoo-dev 2018-10-03 18:03:07 UTC
Some de-duplication logic might do the trick.
Comment 2 Zac Medico gentoo-dev 2018-10-03 18:17:45 UTC
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)
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-10-03 18:21:54 UTC
Looks good at a first glance.
Comment 5 Larry the Git Cow gentoo-dev 2018-10-08 21:40:59 UTC
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(-)