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

Bug 712222

Summary: sys-apps/portage-2.3.93: emerge --buildpkgonly tries to install sources with FEATURES=installsources
Product: Portage Development Reporter: Guilherme Amadio <amadio>
Component: CoreAssignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: normal CC: amadio, zmedico
Priority: Normal Keywords: InVCS
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=490732
https://github.com/gentoo/portage/pull/1305
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 925481    
Bug Blocks:    

Description Guilherme Amadio gentoo-dev 2020-03-12 09:39:58 UTC
I am using emerge --buildpkgonly as a regular user to test packages. I tried this for a package I have enabled debugging, and for that one portage errors out trying to install sources into /usr/src/debug:

$ FEATURES=test emerge --buildpkgonly --jobs=1 -av1 clhep
[snip]
>>> Completed installing sci-physics/clhep-2.4.1.2 into /tmp/portage/sci-physics/clhep-2.4.1.2/image

 * Final size of build directory: 414268 KiB (404.5 MiB)
 * Final size of installed tree:  106892 KiB (104.3 MiB)

strip: x86_64-pc-linux-gnu-strip --strip-unneeded -N __gentoo_check_ldflags__ -R .comment -R .GCC.command.line -R .note.gnu.gold-version
   /usr/lib64/libCLHEP-2.4.1.2.a
   /usr/lib64/libCLHEP-2.4.1.2.so
   /usr/lib64/libCLHEP-Evaluator-2.4.1.2.so
   /usr/lib64/libCLHEP-Evaluator-2.4.1.2.a
   /usr/lib64/libCLHEP-Vector-2.4.1.2.a
   /usr/lib64/libCLHEP-GenericFunctions-2.4.1.2.a
   /usr/lib64/libCLHEP-Vector-2.4.1.2.so
   /usr/lib64/libCLHEP-GenericFunctions-2.4.1.2.so
   /usr/lib64/libCLHEP-RandomObjects-2.4.1.2.a
   /usr/lib64/libCLHEP-RandomObjects-2.4.1.2.so
   /usr/lib64/libCLHEP-Geometry-2.4.1.2.so
   /usr/lib64/libCLHEP-Geometry-2.4.1.2.a
   /usr/lib64/libCLHEP-Matrix-2.4.1.2.so
   /usr/lib64/libCLHEP-Cast-2.4.1.2.so
   /usr/lib64/libCLHEP-Matrix-2.4.1.2.a
   /usr/lib64/libCLHEP-Cast-2.4.1.2.a
   /usr/lib64/libCLHEP-Random-2.4.1.2.so
   /usr/lib64/libCLHEP-Random-2.4.1.2.a
   /usr/lib64/libCLHEP-RefCount-2.4.1.2.so
   /usr/lib64/libCLHEP-RefCount-2.4.1.2.a
   /usr/lib64/libCLHEP-Exceptions-2.4.1.2.so
   /usr/lib64/libCLHEP-Exceptions-2.4.1.2.a
installsources: rsyncing source files
/usr/lib/portage/python3.6/misc-functions.sh: line 467: /var/cache/binpkgs/sci-physics/clhep-2.4.1.2.tbz2.606931: Permission denied
./
./usr/
./usr/src/
./usr/src/debug/
./usr/src/debug/sci-physics/
./usr/src/debug/sci-physics/clhep-2.4.1.2/
./usr/src/debug/sci-physics/clhep-2.4.1.2/clhep-2.4.1.2_build/

I think that when only building the package, portage should not try to install sources into /usr/src/debug.
Comment 1 Guilherme Amadio gentoo-dev 2024-03-09 16:29:35 UTC
Has anyone had a chance to look at this? I tried with Portage 3.0.63 and this is still an issue.
Comment 2 Zac Medico gentoo-dev 2024-03-09 18:25:09 UTC
I think installsources actually was successful and the true problem was the permissions on the /var/cache/binpkgs/sci-physics directory:

/usr/lib/portage/python3.6/misc-functions.sh: line 467: /var/cache/binpkgs/sci-physics/clhep-2.4.1.2.tbz2.606931: Permission denied
Comment 3 Zac Medico gentoo-dev 2024-03-09 18:28:53 UTC
There's code from bug 490732 to check for write access earlier, but it only checks the root /var/cache/binpkgs directory.
Comment 4 Zac Medico gentoo-dev 2024-03-09 18:34:58 UTC
Also, we have this code in the bin/misc-functions.sh dyn_package function that creates directories without propagating permissions from the parent directories:

    mkdir -p "${PORTAGE_BINPKG_TMPFILE%/*}" || die "mkdir failed"
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-09 18:51:00 UTC
(To be clear, in bin/estrip, we write installsources artefacts into ${D}.)
Comment 6 Guilherme Amadio gentoo-dev 2024-03-09 19:43:07 UTC
I see, so then the "problem" is that portage creates /var/cache/binpkgs and its subdirectories as root if you run as root, so if I try to run it later as regular user, there's the permission denied. That's fair enough. If I remove /var/cache/binpkgs and try again it works (I applied the patch from the pull request and the error message is much clearer). Ok, I think we can close this, but if you want, you could create things with portage:portage as owner, so users in the portage group can still run things as themselves later on. Thanks!
Comment 7 Larry the Git Cow gentoo-dev 2024-03-09 22:54:56 UTC
The bug has been referenced in the following commit(s):

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

commit d55d415a4f68b0d2b0c4dca00cce2d9aee934faa
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2024-03-09 22:01:18 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2024-03-09 22:49:03 +0000

    EbuildPhase/EbuildBinpkg: Ensure PKGDIR subdirectory permissions
    
    Bug: https://bugs.gentoo.org/712222
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 bin/misc-functions.sh        |  8 ++++++--
 lib/_emerge/EbuildBinpkg.py  |  3 ++-
 lib/_emerge/EbuildPhase.py   |  3 +++
 lib/portage/dbapi/bintree.py | 18 +++++++++++++-----
 4 files changed, 24 insertions(+), 8 deletions(-)
Comment 8 Zac Medico gentoo-dev 2024-03-09 22:58:29 UTC
(In reply to Guilherme Amadio from comment #6)
> I see, so then the "problem" is that portage creates /var/cache/binpkgs and
> its subdirectories as root if you run as root, so if I try to run it later
> as regular user, there's the permission denied. That's fair enough. If I
> remove /var/cache/binpkgs and try again it works (I applied the patch from
> the pull request and the error message is much clearer). Ok, I think we can
> close this, but if you want, you could create things with portage:portage as
> owner, so users in the portage group can still run things as themselves
> later on. Thanks!

Yeah, the intention is for each subdirectory to inherit permissions from the top-level /var/cache/binpkgs directory, which can have any permissions you want. It's fixed to do that in d55d415a4f68b0d2b0c4dca00cce2d9aee934faa.
Comment 9 Larry the Git Cow gentoo-dev 2024-04-28 00:32:38 UTC
The bug has been closed via the following commit(s):

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

commit f1e53b9368c215451e3af78b557d8b86a2db9677
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-04-28 00:31:29 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-04-28 00:31:29 +0000

    sys-apps/portage: add 3.0.64
    
    Closes: https://bugs.gentoo.org/925481
    Closes: https://bugs.gentoo.org/675748
    Closes: https://bugs.gentoo.org/712222
    Closes: https://bugs.gentoo.org/920330
    Closes: https://bugs.gentoo.org/925213
    Closes: https://bugs.gentoo.org/925863
    Closes: https://bugs.gentoo.org/925888
    Closes: https://bugs.gentoo.org/925907
    Closes: https://bugs.gentoo.org/926048
    Closes: https://bugs.gentoo.org/926221
    Closes: https://bugs.gentoo.org/927059
    Closes: https://bugs.gentoo.org/927632
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.64.ebuild | 242 +++++++++++++++++++++++++++++++++
 2 files changed, 243 insertions(+)