Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 933100 - Prefix: install: cannot change ownership of '${EPREFIX}...//bin/egrep': Operation not permitted
Summary: Prefix: install: cannot change ownership of '${EPREFIX}...//bin/egrep': Opera...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords: PATCH
: 933681 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-05-29 05:41 UTC by Matt Jolly
Modified: 2024-07-14 13:11 UTC (History)
5 users (show)

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


Attachments
build.log (build.log,147.65 KB, text/x-log)
2024-05-29 05:48 UTC, Matt Jolly
Details
bugfix (bug_933681.patch,625 bytes, patch)
2024-07-13 19:45 UTC, Étienne Buira
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Jolly gentoo-dev 2024-05-29 05:41:30 UTC
Hi Prefix Wizards.

After resolving python and perl I'm still unable to bootstrap prefix on my equipment. I initially assumed that this had to do with resuming the prefix build, however in a clean, single execution of `prefix-bootstrap.sh` build my install ends with:

```
install: cannot change ownership of '/flash/tmp/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/flash/tmp/gentoo//bin/egrep': Operation not permitted
 * ERROR
```

I am unable to see any real reason for this, however some investigation appears to point to `dobin` failing, likely due to `PORTAGE_INST_UID` and/or  `PORTAGE_INST_GID` being unset:

https://github.com/gentoo/portage/blob/120b2ec988eebf6cd90365d5b50a1a718eebb116/bin/ebuild-helpers/dobin#L32C3-L32C90

```
install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${ED%/}/${__E_DESTTREE#/}/bin"
```

Any thoughts on this one? I'm a little stumped.
Comment 1 Matt Jolly gentoo-dev 2024-05-29 05:48:25 UTC
Created attachment 894585 [details]
build.log
Comment 2 Matt Jolly gentoo-dev 2024-05-29 05:49:40 UTC
stage3.log https://0x0.st/XNa3.log

Apologies for the pastebin, even with xz and zstd pushed to their limits I couldn't get it below 1k.
Comment 3 Matt Jolly gentoo-dev 2024-05-31 07:23:57 UTC
Added some "debug logging" to the dobin helper: 

```
+ newbin - egrep                                                                                                                                            
install -m0755 -o 0 -g 0 /flash/tmp/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/temp/.newins_tmp_I6AGbr/egrep /flash/tmp/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/flash/tmp/gentoo//bin
install: cannot change ownership of '/flash/tmp/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/flash/tmp/gentoo//bin/egrep': Operation not permitted
```

So, why at this specific point in the bootstrap process is `PORTAGE_INST_{UID,GID}` getting unset?

Since this is a new portage invocation, obviously something is changing between the previous run for app-arch/tar and this one for sys-apps/grep.
Comment 4 Matt Jolly gentoo-dev 2024-05-31 07:28:09 UTC
Curious, These vars aren't unset, they're set to '0'.
Comment 5 Matt Jolly gentoo-dev 2024-06-07 06:33:49 UTC
I've tried again on SLES 15 SP5 and encountered the same issue.

I make it to here just fine:

https://gitweb.gentoo.org/repo/proj/prefix.git/tree/scripts/bootstrap-prefix.sh#n2322

The next time Portage is invoked it seems to get confused and sets `PORTAGE_INST_UID` and `PORTAGE_INST_GID` to 0.

We're still using the bootstrap `emerge` and `python` explicitly at this stage, but I did note on my most recent prefix attempt that Python, Portage, and Perl are all built and installed in the last successful `emerge`. I wonder if something is going awry there.

genr8eofl noted that there are some SUSE specific notes in `startprefix`:

https://gitweb.gentoo.org/proj/prefix/prefix-toolkit.git/tree/startprefix?h=main#n56

Not sure if this is related, but a possible avenue of investigation.

I think I need to dig into the Portage code and work out how the environment gets setup which might shed some light on exactly where it gets these values from and why it seems to think it's running as `root`.
Comment 6 Fabian Groffen gentoo-dev 2024-06-07 07:12:28 UTC
This is RAP, which uses mainline Portage.  I'm not sure how this has worked previously, but apparently it did.  non-RAP uses Prefix Portage which doesn't fall back to '0', but to the user that installed Portage.  So the problem here is that you're neither user 250, nor 0.  Maybe this rootuid/rootgrp stuff from Prefix branch should be brought down to main.
Comment 7 Matt Jolly gentoo-dev 2024-06-10 07:43:22 UTC
I ran some tests today.

Steps to reproduce:

- Install OpenSUSE Leap (15.5) in a VM.
- `zypper in autoconf automake gcc gcc-c++`
- curl bootstrap-prefix.sh
- bootstrap prefix

It will fail at the same point after around an hour on 15 threads.

> I'm not sure how this has worked previously, but apparently it did.

It appears to only fail on SUSE flavours - other users report it working for them on other distros.

> non-RAP uses Prefix Portage which doesn't fall back to '0',

What I'm seeing after modifying the `dobin` script is that the uid and gid are set in the environment when it's invoked, I'm assuming the rootuid bits will fix that?
Comment 8 Det 2024-06-10 08:03:29 UTC
Hi,
I get the same message with Rocky Linux release 8.10. 

...
install: cannot change ownership of '/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/home/prefix/gentoo//bin/egrep': Operation not permitted
 * ERROR: sys-apps/grep-3.11-r1::gentoo failed (install phase):
 *   dobin failed
...
* ERROR: sys-apps/grep-3.11-r1::gentoo failed (install phase):
 *   newbin failed
...
Comment 9 Det 2024-06-17 07:13:00 UTC
Hi,
tried again today. 


>>> Install sys-apps/grep-3.11-r1 into /home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image
make SHELL=/home/prefix/gentoo/bin/bash -j48 DESTDIR=/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image install 
Making install in po
make[1]: Entering directory '/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/work/grep-3.11/po'

```

/home/prefix/gentoo/usr/bin/install -c -m 644 grep.1 '/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/home/prefix/gentoo/usr/share/man/man1'
 /home/prefix/gentoo/usr/bin/install -c -m 644 ./grep.info '/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/home/prefix/gentoo/usr/share/info'
 install-info --info-dir='/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/home/prefix/gentoo/usr/share/info' '/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/home/prefix/gentoo/usr/share/info/grep.info'

```

make[1]: Leaving directory '/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/work/grep-3.11'
install: cannot change ownership of '/home/prefix/gentoo/var/tmp/portage/sys-apps/grep-3.11-r1/image/home/prefix/gentoo//bin/egrep': Operation not permitted
 * ERROR: sys-apps/grep-3.11-r1::gentoo failed (install phase):
 *   dobin failed

```

 CHOST:     x86_64-pc-linux-gnu
 IDENT:     x86_64-rap-linux-rocky8.10
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-07-09 07:19:21 UTC
*** Bug 933681 has been marked as a duplicate of this bug. ***
Comment 11 Étienne Buira 2024-07-09 12:08:46 UTC
Those vars looks like to be set to default 0/0 in lib/portage/package/ebuild/config.py (lines around 1095), but the bash scripts already puts a default if unset, maybe a clean way to resolve this bug.

BTW, a few lines below, there is unreachable code (a raise OSError before os.stat(), as well as its else clause), and i'm not sure it makes sense to use eroot stat results for that.
Comment 12 Étienne Buira 2024-07-13 19:45:28 UTC
Created attachment 897541 [details, diff]
bugfix

Bootstraps ok with that.
Comment 13 Fabian Groffen gentoo-dev 2024-07-14 12:37:18 UTC
yes thank you, let's do this
Comment 14 Larry the Git Cow gentoo-dev 2024-07-14 13:11:25 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=55888020536b3866ff29f27d6b4e6ede77ae791f

commit 55888020536b3866ff29f27d6b4e6ede77ae791f
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2024-07-14 13:09:51 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2024-07-14 13:09:51 +0000

    scripts/bootstrap-prefix: define PORTAGE_INST_{UID,GID}
    
    Based on the patch by Etienne Buira <etienne.buira@free.fr> in bug #933100.
    
    Mainline Portage doesn't set the Portage UID/GID, so define them in
    make.conf during bootstrap for RAP targets.
    
    Closes: https://bugs.gentoo.org/933100
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 scripts/bootstrap-prefix.sh | 9 +++++++++
 1 file changed, 9 insertions(+)