Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 832855 - sys-apps/portage: installed in venv fails if ROOT!=/ due to wrong profile check
Summary: sys-apps/portage: installed in venv fails if ROOT!=/ due to wrong profile check
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-07 16:03 UTC by Michał Górny
Modified: 2022-02-07 21:49 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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