[PATCH 2/3] make-secnet-sites: new "include" keyword
Ian Jackson
ijackson at chiark.greenend.org.uk
Thu Dec 15 13:45:39 GMT 2011
Allow "headers" files and "sites" files to contain "include"
directives.
Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
make-secnet-sites | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/make-secnet-sites b/make-secnet-sites
index f102b1f..fe58bde 100755
--- a/make-secnet-sites
+++ b/make-secnet-sites
@@ -329,7 +329,7 @@ def set_property(obj,w):
else:
obj.properties[w[0]]=keywords[w[0]][0](w)
-def pline(i):
+def pline(i,allow_include=False):
"Process a configuration file line"
global allow_defs, obstack, root
w=string.split(i)
@@ -340,6 +340,14 @@ def pline(i):
allow_defs=sitelevel.depth
obstack=[root]
return
+ if keyword=='include':
+ if not allow_include:
+ complain("include not permitted here")
+ return
+ if len(w) != 2:
+ complain("include requires one argument")
+ pfilepath(w[1],allow_include=allow_include)
+ return
if levels.has_key(keyword):
# We may go up any number of levels, but only down by one
newdepth=levels[keyword].depth
@@ -379,12 +387,12 @@ def pline(i):
complain("unknown keyword '%s'"%(keyword))
-def pfilepath(pathname):
+def pfilepath(pathname,allow_include=False):
f=open(pathname)
- pfile(pathname,f.readlines())
+ pfile(pathname,f.readlines(),allow_include=allow_include)
f.close()
-def pfile(name,lines):
+def pfile(name,lines,allow_include=False):
"Process a file"
global file,line
file=name
@@ -393,7 +401,7 @@ def pfile(name,lines):
line=line+1
if (i[0]=='#'): continue
if (i[len(i)-1]=='\n'): i=i[:len(i)-1] # strip trailing LF
- pline(i)
+ pline(i,allow_include=allow_include)
def outputsites(w):
"Output include file for secnet configuration"
@@ -455,14 +463,14 @@ else:
if not ok:
print "caller not in group %s"%group
sys.exit(1)
- pfilepath(header)
+ pfilepath(header,allow_include=True)
userinput=sys.stdin.readlines()
pfile("user input",userinput)
else:
if len(sys.argv)>3:
print "Too many arguments"
sys.exit(1)
- pfilepath(sys.argv[1])
+ pfilepath(sys.argv[1],allow_include=True)
of=sys.stdout
if len(sys.argv)>2:
of=open(sys.argv[2],'w')
--
1.5.6.5
More information about the sgo-software-discuss
mailing list