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

Bug 832855

Summary: sys-apps/portage: installed in venv fails if ROOT!=/ due to wrong profile check
Product: Portage Development Reporter: Michał Górny <mgorny>
Component: CoreAssignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-02-07 16:03:51 UTC
If you install Portage in a venv and then run it with PORTAGE_CONFIGROOT!=/ and ROOT!=/, the resulting config becomes broken.  API calls don't match any repositories, and e.g. emerge fails to start with:

```
!!! /tmp/.venv/etc/portage/make.profile is not a symlink and will probably prevent most merges.
!!! It should point into a profile within /tmp/pytest-of-mgorny/pytest-0/root0/usr/portage/profiles/
!!! (You can safely ignore this message when syncing. It's harmless.)


!!! Your current profile is invalid. If you have just changed your profile
!!! configuration, you should revert back to the previous configuration.
!!! Allowed actions are limited to --help, --info, --search, --sync, and
!!! --version.
```


This is apparently because of the logic in portage/__init__.py.  The create_trees() function first creates settings instance with the correct config_root.  Then it determines that ROOT != '/' and replaces settings with a "clean" object that ignores config_root.  Then everything falls apart because it goes looking for make.profile inside the venv.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-02-07 21:49:17 UTC
My reproducer:

git clone https://github.com/mgorny/gentoopm
cd gentoopm
tox

Basically, tests work just fine with Gentoo-installed Portage but fail when run inside venv.

You can then use e.g.:

. .tox/py310/bin/activate
export PORTAGE_CONFIGROOT=/tmp/pytest-of-<username>/pytest-current/rootcurrent/
export ROOT=${PORTAGE_CONFIGROOT}
emerge