Skip to content

Commit a47b43e

Browse files
committed
🚸 Set PORTAGE_CONFIGROOT to / by default
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
1 parent 840e7be commit a47b43e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/gcm/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
import os
2+
3+
os.environ.setdefault('PORTAGE_CONFIGROOT', '/')
4+
5+
16
__name__ = 'Gentoo Cache Manager'
27
__version__ = '0.1.0'

tests/test_init.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import sys
3+
from unittest.mock import patch
4+
5+
6+
@patch.dict(os.environ)
7+
@patch.dict(sys.modules)
8+
def test_init():
9+
assert os.environ['PORTAGE_CONFIGROOT'] == 'tests/data'
10+
11+
del os.environ['PORTAGE_CONFIGROOT']
12+
sys.modules.pop('gcm', None)
13+
14+
__import__('gcm')
15+
16+
assert os.environ['PORTAGE_CONFIGROOT'] == '/'

0 commit comments

Comments
 (0)