summaryrefslogtreecommitdiff
path: root/portato/backend/__init__.py
diff options
context:
space:
mode:
authornecoro <>2007-02-19 23:04:14 +0000
committernecoro <>2007-02-19 23:04:14 +0000
commitfba60a84b9a838ad32def950210a6b62d9bcdbff (patch)
treed581e4fa141851323a05d4500ad95afe50ed6e02 /portato/backend/__init__.py
parentb4c88233aa6dabd2d9301350a240b8ddcf09255a (diff)
downloadportato-fba60a84b9a838ad32def950210a6b62d9bcdbff.tar.gz
portato-fba60a84b9a838ad32def950210a6b62d9bcdbff.tar.bz2
portato-fba60a84b9a838ad32def950210a6b62d9bcdbff.zip
Back to our own revision solution as the eclass-one checks _before_ updating
Diffstat (limited to 'portato/backend/__init__.py')
-rw-r--r--portato/backend/__init__.py75
1 files changed, 20 insertions, 55 deletions
diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py
index a72923b..83ee1d6 100644
--- a/portato/backend/__init__.py
+++ b/portato/backend/__init__.py
@@ -10,67 +10,32 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-import os
-from threading import Lock
+from system_interface import SystemInterface
-# import portage
-import portage
+SYSTEM = "portage"
+_sys = None
-class PortageSettings:
- """Encapsulation of the portage settings.
-
- @ivar settings: portage settings
- @ivar settingslock: a simple Lock
- @ivar trees: a dictionary of the trees
- @ivar porttree: shortcut to C{trees[root]["porttree"]}
- @ivar vartree: shortcut to C{trees[root]["vartree"]}
- @ivar virtuals: shortcut to C{trees[root]["virtuals"]}"""
+class SystemWrapper (object, SystemInterface):
+ def __getattribute__ (self, name):
+ global _sys
+ return eval ("_sys.%s" % name)
- def __init__ (self):
- """Initializes the instance. Calls L{load()}."""
- self.settingslock = Lock()
- self.load()
-
- def load(self):
- """(Re)loads the portage settings and sets the variables."""
+def set_system (new_sys):
+ global SYSTEM
+ SYSTEM = new_sys
+ load_system()
- 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)
+def load_system ():
+ global _sys
- self.settings = self.trees["/"]["vartree"].settings
+ if SYSTEM == "portage":
+ from portato.backend.portage import PortageSystem
+ _sys = PortageSystem ()
- for myroot in self.trees:
- if myroot != "/":
- self.settings = self.trees[myroot]["vartree"].settings
- break
+system = SystemWrapper()
- 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.settings = None # we use our own one ...
-
-# portage tree vars
-portage_settings = PortageSettings()
-
-# for the moment ;)
-settingslock = portage_settings.settingslock
-settings = portage_settings.settings
-trees = portage_settings.trees
-porttree = portage_settings.porttree
-vartree = portage_settings.vartree
-virtuals = portage_settings.virtuals
+from exceptions import *
+from package import Package
-# this is set to "var/lib/portage/world" by default - so we add the leading /
-portage.WORLD_FILE = portage_settings.settings["ROOT"]+portage.WORLD_FILE
+load_system()
-# import our packages
-from exceptions import *
-from package import *
-from portage_helper import *