[dak/master 3/8] check for a DAK_CONFIG env variable when looking for dak.conf
Signed-off-by: Mike O'Connor <stew@dhcp-101.dfw1.kickstart.lan>
---
daklib/config.py | 10 +++++-----
daklib/utils.py | 30 +++++++++++++++++-------------
2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/daklib/config.py b/daklib/config.py
index 09df17b..c86c1b3 100755
--- a/daklib/config.py
+++ b/daklib/config.py
@@ -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
diff --git a/daklib/utils.py b/daklib/utils.py
index a6660ae..00939c7 100755
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -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())
--
1.6.3.3
Reply to: