summaryrefslogtreecommitdiff
path: root/portato/backend/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'portato/backend/__init__.py')
-rw-r--r--portato/backend/__init__.py43
1 files changed, 36 insertions, 7 deletions
diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py
index ce244c5..5ee2e2a 100644
--- a/portato/backend/__init__.py
+++ b/portato/backend/__init__.py
@@ -10,19 +10,48 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-import sys, copy
+import sys, copy, os
from threading import Lock
# import portage
import portage
+class PortageSettings:
+
+ def __init__ (self):
+ self.settingslock = Lock()
+ self.load()
+
+ def load(self):
+ kwargs = {}
+ for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")):
+ kwargs[k] = os.environ.get(envvar, None)
+ self.trees = portage.create_trees(trees=None, **kwargs)
+
+ self.settings = self.trees["/"]["vartree"].settings
+
+ for myroot in self.trees:
+ if myroot != "/":
+ self.settings = self.trees[myroot]["vartree"].settings
+ break
+
+ self.settings.unlock()
+
+ root = self.settings["ROOT"]
+
+ self.porttree = self.trees[root]["porttree"]
+ self.vartree = self.trees[root]["vartree"]
+ self.virtuals = self.trees[root]["virtuals"]
+
# portage tree vars
-settingslock = Lock()
-settings = portage.config(clone=portage.settings, config_incrementals = copy.deepcopy(portage.settings.incrementals))
-porttree = portage.db[portage.root]["porttree"]
-vartree = portage.db[portage.root]["vartree"]
-virtuals = portage.db[portage.root]["virtuals"]
-trees = portage.db
+portage_settings = PortageSettings()
+
+settingslock = portage_settings.settingslock
+settings = portage_settings.settings
+trees = portage_settings.trees
+porttree = portage_settings.porttree
+vartree = portage_settings.vartree
+virtuals = portage_settings.virtuals
# this is set to "var/lib/portage/world" by default - so we add the leading /
portage.WORLD_FILE = portage.settings["ROOT"]+portage.WORLD_FILE