Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 693306

Summary: Optimize PATH in ebuild environment
Product: Portage Development Reporter: Arfrever Frehtes Taifersar Arahesis <arfrever.fta>
Component: CoreAssignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: normal Keywords: PATCH
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=693366
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Patch

Description Arfrever Frehtes Taifersar Arahesis 2019-09-02 05:30:26 UTC
Portage sets custom PATH with hardcoded elements:
https://gitweb.gentoo.org/proj/portage.git/tree/lib/portage/package/ebuild/doebuild.py?id=26c8526293bd93906390d8fc830dc55052fc4d40#n204

...

	for prefix in prefixes:
		prefix = prefix if prefix else "/"
		for x in ("usr/local/sbin", "usr/local/bin", "usr/sbin", "usr/bin", "sbin", "bin"):
...


When some of these directories are merged (e.g. /bin + /sbin + /usr/bin + /usr/sbin), then it is not necessary to include effectively duplicate elements in PATH.
I suggest to also canonicalize paths to make them look better.
Comment 1 Arfrever Frehtes Taifersar Arahesis 2019-09-02 05:35:02 UTC
Created attachment 588682 [details, diff]
Patch
Comment 2 Larry the Git Cow gentoo-dev 2019-09-02 20:13:50 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=7cb7196fe8aa668e76437a8a4500a7bcb9fd3c75

commit 7cb7196fe8aa668e76437a8a4500a7bcb9fd3c75
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
AuthorDate: 2019-09-02 05:32:09 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-09-02 20:11:26 +0000

    _doebuild_path: Optimize PATH in ebuild environment.
    
    Canonicalize paths of directories in PATH.
    Avoid duplicates when some directories (e.g. bin and sbin) are merged.
    
    Bug: https://bugs.gentoo.org/693306
    Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/package/ebuild/doebuild.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Comment 3 Zac Medico gentoo-dev 2019-09-02 20:14:44 UTC
Thanks!
Comment 4 Zac Medico gentoo-dev 2019-09-03 15:39:35 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=c9c2bcc619c6ff60e452205f94ae26d4afd44d82

commit c9c2bcc619c6ff60e452205f94ae26d4afd44d82
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2019-09-03 08:34:08 -0700
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-09-03 08:36:23 -0700

    Revert "_doebuild_path: Optimize PATH in ebuild environment."
    
    This reverts commit 7cb7196fe8aa668e76437a8a4500a7bcb9fd3c75.
    Since binary and installed packages have persistent PATH
    settings in environment.bz2, using realpath on PATH components
    can break binary and installed package phases if the symlink
    layout is somehow modified. Therefore, the implications of
    changes like this need to be considered very carefully.
    
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/package/ebuild/doebuild.py | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)