summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/actions.py8
-rw-r--r--pym/portage/__init__.py14
-rw-r--r--pym/portage/_legacy_globals.py10
3 files changed, 15 insertions, 17 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 087951016..edc0afdb1 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -2983,13 +2983,7 @@ def load_emerge_config(trees=None):
setconfig = load_default_config(settings, root_trees)
root_trees["root_config"] = RootConfig(settings, root_trees, setconfig)
- settings = trees["/"]["vartree"].settings
-
- for myroot in trees:
- if myroot != "/":
- settings = trees[myroot]["vartree"].settings
- break
-
+ settings = trees[trees._target_root]['vartree'].settings
mtimedbfile = os.path.join(settings['EROOT'], portage.CACHE_PATH, "mtimedb")
mtimedb = portage.MtimeDB(mtimedbfile)
portage.output._init(config_root=settings['PORTAGE_CONFIGROOT'])
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 7f781cf17..3dc9ae53c 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -479,9 +479,15 @@ def portageexit():
if data.secpass > 1 and os.environ.get("SANDBOX_ON") != "1":
close_portdbapi_caches()
+class _trees_dict(dict):
+ def __init__(self):
+ super(dict, self).__init__()
+ self._running_root = None
+ self._target_root = None
+
def create_trees(config_root=None, target_root=None, trees=None, env=None):
if trees is None:
- trees = {}
+ trees = _trees_dict()
else:
# clean up any existing portdbapi instances
for myroot in trees:
@@ -497,8 +503,11 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None):
env=env, _eprefix=eprefix)
settings.lock()
+ trees._target_root = settings['ROOT']
myroots = [(settings["ROOT"], settings)]
- if settings["ROOT"] != "/":
+ if settings["ROOT"] == "/":
+ trees._running_root = trees._target_root
+ else:
# When ROOT != "/" we only want overrides from the calling
# environment to apply to the config that's associated
@@ -513,6 +522,7 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None):
settings = config(config_root=None, target_root="/",
env=clean_env, _eprefix=eprefix)
settings.lock()
+ trees._running_root = settings['ROOT']
myroots.append((settings["ROOT"], settings))
for myroot, mysettings in myroots:
diff --git a/pym/portage/_legacy_globals.py b/pym/portage/_legacy_globals.py
index 615591af3..beba78563 100644
--- a/pym/portage/_legacy_globals.py
+++ b/pym/portage/_legacy_globals.py
@@ -35,19 +35,13 @@ def _get_legacy_global(name):
constructed.add('db')
del portage._initializing_globals
- settings = portage.db["/"]["vartree"].settings
-
- for root in portage.db:
- if root != "/":
- settings = portage.db[root]["vartree"].settings
- break
-
+ settings = portage.db[portage.db._target_root]["vartree"].settings
portage.output._init(config_root=settings['PORTAGE_CONFIGROOT'])
portage.settings = settings
constructed.add('settings')
- portage.root = root
+ portage.root = portage.db._target_root
constructed.add('root')
# COMPATIBILITY