]> git.decadent.org.uk Git - dak.git/commitdiff
check for a DAK_CONFIG env variable when looking for dak.conf
authorMike O'Connor <stew@dhcp-101.dfw1.kickstart.lan>
Thu, 29 Oct 2009 16:27:55 +0000 (16:27 +0000)
committerMike O'Connor <stew@dhcp-101.dfw1.kickstart.lan>
Thu, 29 Oct 2009 21:48:42 +0000 (21:48 +0000)
Signed-off-by: Mike O'Connor <stew@dhcp-101.dfw1.kickstart.lan>
daklib/config.py
daklib/utils.py

index 09df17bb06be100a2a753793c5416f3750cf3e30..c86c1b36580931bf81427b6f5c0bee48d1acd8df 100755 (executable)
@@ -28,6 +28,7 @@ Config access class
 
 ################################################################################
 
+import os
 import apt_pkg
 import socket
 
@@ -37,10 +38,9 @@ from singleton import Singleton
 
 default_config = "/etc/dak/dak.conf"
 
-def which_conf_file(Cnf):
-    res = socket.gethostbyaddr(socket.gethostname())
-    if Cnf.get("Config::" + res[0] + "::DakConfig"):
-        return Cnf["Config::" + res[0] + "::DakConfig"]
+def which_conf_file():
+    if os.getenv("DAK_CONFIG"):
+        return os.getenv("DAK_CONFIG")
     else:
         return default_config
 
@@ -57,7 +57,7 @@ class Config(Singleton):
 
         self.Cnf = apt_pkg.newConfiguration()
 
-        apt_pkg.ReadConfigFileISC(self.Cnf, default_config)
+        apt_pkg.ReadConfigFileISC(self.Cnf, which_conf_file())
 
         # Check whether our dak.conf was the real one or
         # just a pointer to our main one
index a6660ae1b9e291f89306dbc4ab1b032a09491ba5..00939c7e384e325783c146aba626b7333f0899ae 100755 (executable)
@@ -710,20 +710,24 @@ def where_am_i ():
         return res[0]
 
 def which_conf_file ():
-    res = socket.gethostbyaddr(socket.gethostname())
-    # In case we allow local config files per user, try if one exists
-    if Cnf.FindB("Config::" + res[0] + "::AllowLocalConfig"):
-        homedir = os.getenv("HOME")
-        confpath = os.path.join(homedir, "/etc/dak.conf")
-        if os.path.exists(confpath):
-            apt_pkg.ReadConfigFileISC(Cnf,default_config)
-
-    # We are still in here, so there is no local config file or we do
-    # not allow local files. Do the normal stuff.
-    if Cnf.get("Config::" + res[0] + "::DakConfig"):
-        return Cnf["Config::" + res[0] + "::DakConfig"]
+    if os.getenv("DAK_CONFIG"):
+        print(os.getenv("DAK_CONFIG"))
+        return os.getenv("DAK_CONFIG")
     else:
-        return default_config
+        res = socket.gethostbyaddr(socket.gethostname())
+        # In case we allow local config files per user, try if one exists
+        if Cnf.FindB("Config::" + res[0] + "::AllowLocalConfig"):
+            homedir = os.getenv("HOME")
+            confpath = os.path.join(homedir, "/etc/dak.conf")
+            if os.path.exists(confpath):
+                apt_pkg.ReadConfigFileISC(Cnf,default_config)
+
+        # We are still in here, so there is no local config file or we do
+        # not allow local files. Do the normal stuff.
+        if Cnf.get("Config::" + res[0] + "::DakConfig"):
+            return Cnf["Config::" + res[0] + "::DakConfig"]
+        else:
+            return default_config
 
 def which_apt_conf_file ():
     res = socket.gethostbyaddr(socket.gethostname())