Skip to content

Commit

Permalink
🚸 Set PORTAGE_CONFIGROOT to / by default
Browse files Browse the repository at this point in the history
In case gcm uses portage installed in a virtual environment,
portage looks for configuration files where it's installed.
This behavior might be confusing, so it's better to make
portage use configuration files from the root by default.

For a better understanding, see the descriptions of the
EPREFIX and PORTAGE_CONFIGROOT environment variables:
  - `man emerge`
  - https://dev.gentoo.org/~zmedico/portage/doc/man/emerge.1.html
  • Loading branch information
Jamim committed May 13, 2024
1 parent 840e7be commit a47b43e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gcm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
import os

os.environ.setdefault('PORTAGE_CONFIGROOT', '/')


__name__ = 'Gentoo Cache Manager'
__version__ = '0.1.0'
16 changes: 16 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
import sys
from unittest.mock import patch


@patch.dict(os.environ)
@patch.dict(sys.modules)
def test_init():
assert os.environ['PORTAGE_CONFIGROOT'] == 'tests/data'

del os.environ['PORTAGE_CONFIGROOT']
sys.modules.pop('gcm', None)

__import__('gcm')

assert os.environ['PORTAGE_CONFIGROOT'] == '/'

0 comments on commit a47b43e

Please sign in to comment.