Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 947822 - Feature Request: Use /var/lib/portage/home as a template to populate build HOME directory
Summary: Feature Request: Use /var/lib/portage/home as a template to populate build HO...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on: 939444
Blocks:
  Show dependency tree
 
Reported: 2025-01-10 18:17 UTC by John R. Graham
Modified: 2025-01-22 00:30 UTC (History)
2 users (show)

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


Attachments
Patch implements proposed new feature. (portage-home-dir-template-copy.patch,2.79 KB, patch)
2025-01-10 18:17 UTC, John R. Graham
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John R. Graham gentoo-dev 2025-01-10 18:17:51 UTC
Created attachment 916239 [details, diff]
Patch implements proposed new feature.

I'm not sure when exactly this changed, but I /used/ to be able to use the standard portage user's home directory (the one retrievable via "getent passwd portage") to specify ssh keys and known_hosts to access git repositories with an encrypted connection through the git-r3 eclass. For details on what I was doing, see [1]. But at some point, Portage started creating an empty homedir under the "${PORTAGE_TMPDIR}/portage/${CATEGORY}/${P}" directory and defining HOME to point to /that/ in the build environment. I think I understand the reason for the change: it's more correct and more robust to start out with an absolutely predictable build environment so that ebuilds are guaranteed to produce the same results on successive runs, because no build remnants are possible through the HOME directory.

But I don't think it violate that principle to /populate/ the build environment HOME directory with a small and (relatively) constant set of files. Also, what's useful to put under the portage user's home directory is very small, so shouldn't have a measurable impact on performance.

As a second justification for this feature, git has gotten more pedantically secure over the years and, when run from the git-r3 eclass, now occasionally issues advice that /does not work/ (see [2], where I first discussed the problem and potential solution).

If the Portage developers think this feature is not unthinkable (and hopefully potentially useful), could I ask them to review my attached patch, please? I've tied the new feature to "home-dir-template-copy" in FEATURES. There's no Portage behavior change without that feature enabled.

After applying constructive criticism, I'll be ready to submit a pull request. That'll be against git@github.com:gentoo/portage.git, yes?

[1] https://forums.gentoo.org/viewtopic-t-1070842.html
[2] https://forums.gentoo.org/viewtopic-t-1171988.html
Comment 1 Zac Medico gentoo-dev 2025-01-11 03:12:48 UTC
(In reply to John R. Graham from comment #0)
> After applying constructive criticism, I'll be ready to submit a pull
> request. That'll be against git@github.com:gentoo/portage.git, yes?

The idea seems reasonable. Yes please go ahead and submit a pull request.
Comment 2 John R. Graham gentoo-dev 2025-01-12 21:15:20 UTC
Thanks, Zac. I'm stress testing the feature a little bit before submitting the pull request.
Comment 3 John R. Graham gentoo-dev 2025-01-17 14:31:02 UTC
Pull request created: https://github.com/gentoo/portage/pull/1424
Comment 4 Larry the Git Cow gentoo-dev 2025-01-19 17:57:59 UTC
The bug has been referenced in the following commit(s):

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

commit 7b9f6ffb277a9ba01b299b8d1d7714834fca3fc0
Author:     John R. Graham <john_r_graham@gentoo.org>
AuthorDate: 2025-01-16 20:14:01 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2025-01-19 17:57:36 +0000

    prepare_build_dirs.py: Support for new home-dir-template-copy FEATURE
    
    If enabled, as part of the ebuild environment setup, copies the PORTAGE_USERNAME
    home directory into the build environment HOME directory. Useful predominantly
    for ebuilds that use the git-r3 eclass, to give a place to put SSH keys and user-
    specific git configuration files used during the build.
    
    Bug: https://bugs.gentoo.org/947822
    Closes: https://github.com/gentoo/portage/pull/1424
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 NEWS                                             |  2 ++
 lib/portage/const.py                             |  1 +
 lib/portage/package/ebuild/prepare_build_dirs.py | 22 ++++++++++++++++++++++
 man/make.conf.5                                  | 17 +++++++++++++++++
 4 files changed, 42 insertions(+)
Comment 5 Larry the Git Cow gentoo-dev 2025-01-22 00:30:26 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03f41049a0fe0632eabd8cddaaca898e45943201

commit 03f41049a0fe0632eabd8cddaaca898e45943201
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2025-01-22 00:29:50 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2025-01-22 00:30:02 +0000

    sys-apps/portage: add 3.0.67
    
    Closes: https://bugs.gentoo.org/703520
    Closes: https://bugs.gentoo.org/707980
    Closes: https://bugs.gentoo.org/904702
    Closes: https://bugs.gentoo.org/906044
    Closes: https://bugs.gentoo.org/923530
    Closes: https://bugs.gentoo.org/938164
    Closes: https://bugs.gentoo.org/939299
    Closes: https://bugs.gentoo.org/940120
    Closes: https://bugs.gentoo.org/942512
    Closes: https://bugs.gentoo.org/942760
    Closes: https://bugs.gentoo.org/945382
    Closes: https://bugs.gentoo.org/945861
    Closes: https://bugs.gentoo.org/946326
    Closes: https://bugs.gentoo.org/947822
    Closes: https://bugs.gentoo.org/948067
    Closes: https://bugs.gentoo.org/939444
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.67.ebuild | 231 +++++++++++++++++++++++++++++++++
 2 files changed, 232 insertions(+)