dispatch-conf: experimental prefix support
authorZac Medico <zmedico@gentoo.org>
Thu, 8 Dec 2011 07:26:02 +0000 (23:26 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 8 Dec 2011 07:26:02 +0000 (23:26 -0800)
bin/dispatch-conf
pym/portage/dispatch_conf.py

index 3089329db08619d8f12219f9415a57fd1d5cd7ff..1cad9e01167629395c562afda39d75e469c01b67 100755 (executable)
@@ -85,7 +85,7 @@ class dispatch:
         confs = []
         count = 0
 
-        config_root = '/'
+        config_root = os.environ.get("__PORTAGE_TEST_EPREFIX", "/")
         self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS)
 
         if "log-file" in self.options:
@@ -120,7 +120,8 @@ class dispatch:
         #
 
         for path in config_paths:
-            path = portage.normalize_path(path)
+            path = portage.normalize_path(
+                 os.path.join(config_root, path.lstrip(os.sep)))
             try:
                 mymode = os.stat(path).st_mode
             except OSError:
index 4991020306b30cf654fa8974c749b5c14e5f69cc..f5beba5c01f205ea436c0f471308c8833356e68c 100644 (file)
@@ -38,8 +38,9 @@ def diffstatusoutput_len(cmd):
         return (1, 1)
 
 def read_config(mandatory_opts):
-    loader = KeyValuePairFileLoader(
-        '/etc/dispatch-conf.conf', None)
+    eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX", "/")
+    config_path = os.path.join(eprefix, "etc/dispatch-conf.conf")
+    loader = KeyValuePairFileLoader(config_path, None)
     opts, errors = loader.load()
     if not opts:
         print(_('dispatch-conf: Error reading /etc/dispatch-conf.conf; fatal'), file=sys.stderr)