Browse Source

use the B10_FROM_SOURCE to also find the location of passwd.csv
(and, to prepare for future specfiles, for cmdctl.spec which isn't used yet afaik)


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

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

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

@@ -2,6 +2,9 @@ pkglibexecdir = $(libexecdir)/@PACKAGE@
 
 pkglibexec_SCRIPTS = b10-cmdctl
 
+b10_cmdctldir = $(DESTDIR)$(pkgdatadir)
+b10_cmdctl_DATA = passwd.csv
+
 CLEANFILES=	b10-cmdctl.py
 
 # TODO: does this need $$(DESTDIR) also?

+ 13 - 0
src/bin/cmdctl/b10-cmdctl.py.in

@@ -27,6 +27,7 @@ resut to client.
 '''
 
 import sys; sys.path.append ('@@PYTHONPATH@@')
+import os
 import http.server
 import urllib.parse
 import json
@@ -46,6 +47,18 @@ except ImportError:
 URL_PATTERN = re.compile('/([\w]+)(?:/([\w]+))?/?')
 USER_INFO_FILE = "passwd.csv"
 CERTIFICATE_FILE = 'b10-cmdctl.pem'
+
+# 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:
+    SPECFILE_PATH = os.environ["B10_FROM_SOURCE"] + "/src/bin/cmdctl"
+else:
+    PREFIX = "@prefix@"
+    DATAROOTDIR = "@datarootdir@"
+    SPECFILE_PATH = "@datadir@/@PACKAGE@".replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
+SPECFILE_LOCATION = SPECFILE_PATH + "/cmdctl.spec"
+USER_INFO_FILE = SPECFILE_PATH + "/passwd.csv"
         
 class SecureHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
     '''https connection request handler.