Browse Source

Config manager now stores its data in @localstatedir@/@package@/b10-config.db
If run from source tree, it will store it in @abs_top_srcdir@/b10-config.db
if you depend on you data in /tmp/parkinglot.db, copy that one to the correct file


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@688 e5f2f494-b856-4b98-b285-d166d9295462

Jelte Jansen 15 years ago
parent
commit
1a2234a583
3 changed files with 16 additions and 5 deletions
  1. 0 2
      src/bin/bind10/bind10.py.in
  2. 3 0
      src/bin/cfgmgr/Makefile.am
  3. 13 3
      src/bin/cfgmgr/b10-cfgmgr.py.in

+ 0 - 2
src/bin/bind10/bind10.py.in

@@ -34,8 +34,6 @@ else:
     DATAROOTDIR = "@datarootdir@"
     SPECFILE_LOCATION = "@datadir@/@PACKAGE@/bob.spec".replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
     
-
-
 # TODO: start up statistics thingy
 
 import subprocess

+ 3 - 0
src/bin/cfgmgr/Makefile.am

@@ -4,6 +4,9 @@ pkglibexec_SCRIPTS = b10-cfgmgr
 
 CLEANFILES = b10-cfgmgr.py
 
+b10_cfgmgrdir = @localstatedir@/@PACKAGE@
+b10_cfgmgr_DATA = 
+
 # TODO: does this need $$(DESTDIR) also?
 # this is done here since configure.ac AC_OUTPUT doesn't expand exec_prefix
 b10-cfgmgr: b10-cfgmgr.py

+ 13 - 3
src/bin/cfgmgr/b10-cfgmgr.py.in

@@ -9,10 +9,20 @@ import pprint
 import os
 from ISC.CC import data
 
+# If B10_FROM_SOURCE is set in the environment, we use data files
+# from a directory relative to that, otherwise we use the ones
+# installed on the system
+if "B10_FROM_SOURCE" in os.environ:
+    DATA_PATH = os.environ["B10_FROM_SOURCE"]
+else:
+    PREFIX = "@prefix@"
+    DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
+    
+
 class ConfigManagerData:
     CONFIG_VERSION = 1
-    DB_FILENAME = "/tmp/parkinglot.db"
-    
+    DB_FILENAME = DATA_PATH  + "/b10-config.db"
+
     def __init__(self):
         self.data = {}
         self.data['version'] = ConfigManagerData.CONFIG_VERSION
@@ -24,7 +34,7 @@ class ConfigManagerData:
     def read_from_file():
         config = ConfigManagerData()
         try:
-            file = open(ConfigManagerData.DB_FILENAME, 'r')
+            file = open(self.DB_FILENAME, 'r')
             file_config = ast.literal_eval(file.read())
             if 'version' in file_config and \
                 file_config['version'] == ConfigManagerData.CONFIG_VERSION: