summaryrefslogtreecommitdiff
path: root/portato/backend/__init__.py
diff options
context:
space:
mode:
authornecoro <>2006-12-29 01:48:41 +0000
committernecoro <>2006-12-29 01:48:41 +0000
commitf268e6d065e3cbb2d694889e37373c8fc3d55198 (patch)
tree9e132541981309a10a8719b5b738da50d14b03c8 /portato/backend/__init__.py
parente24a27421f04df124425499babe660db15246985 (diff)
downloadportato-f268e6d065e3cbb2d694889e37373c8fc3d55198.tar.gz
portato-f268e6d065e3cbb2d694889e37373c8fc3d55198.tar.bz2
portato-f268e6d065e3cbb2d694889e37373c8fc3d55198.zip
enhancement for the settings-handling (better reloading-support, moving into a class), enhanced update_world-check
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