From: Ian Jackson Date: Tue, 10 Jul 2012 23:58:12 +0000 (+0100) Subject: make-secnet-sites: In -u mode, output file "dereferences" include directives X-Git-Tag: debian/0.3.0_beta1~24 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=commitdiff_plain;h=433b0ae83105d91d14c321a9e1369338fe7f7f7d;ds=sidebyside make-secnet-sites: In -u mode, output file "dereferences" include directives Whenm make-secnet-sites is writing the "output" sites file in -u (groupfile update) mode, it includes the effective contents of files referenced in "include" directives, rather than the "include" directive itself. So the "output" sites file does not any longer depend on any files included by the header. Signed-off-by: Ian Jackson --- diff --git a/make-secnet-sites b/make-secnet-sites index 0c19a78..aa50344 100755 --- a/make-secnet-sites +++ b/make-secnet-sites @@ -334,23 +334,22 @@ def pline(i,allow_include=False): "Process a configuration file line" global allow_defs, obstack, root w=string.split(i.rstrip('\n')) - if len(w)==0: return + if len(w)==0: return [i] keyword=w[0] current=obstack[len(obstack)-1] if keyword=='end-definitions': allow_defs=sitelevel.depth obstack=[root] - return + return [i] if keyword=='include': if not allow_include: complain("include not permitted here") - return + return [] if len(w) != 2: complain("include requires one argument") - return + return [] newfile=os.path.join(os.path.dirname(file),w[1]) - pfilepath(newfile,allow_include=allow_include) - return + return pfilepath(newfile,allow_include=allow_include) if levels.has_key(keyword): # We may go up any number of levels, but only down by one newdepth=levels[keyword].depth @@ -381,33 +380,34 @@ def pline(i,allow_include=False): current.children[w[1]]=nl current=nl obstack.append(current) - return + return [i] if current.allow_properties.has_key(keyword): set_property(current,w) - return + return [i] else: complain("Property %s not allowed at %s level"% (keyword,current.type)) - return + return [] complain("unknown keyword '%s'"%(keyword)) def pfilepath(pathname,allow_include=False): f=open(pathname) - lines=f.readlines() - pfile(pathname,lines,allow_include=allow_include) + outlines=pfile(pathname,f.readlines(),allow_include=allow_include) f.close() - return lines + return outlines def pfile(name,lines,allow_include=False): "Process a file" global file,line file=name line=0 + outlines=[] for i in lines: line=line+1 if (i[0]=='#'): continue - pline(i,allow_include=allow_include) + outlines += pline(i,allow_include=allow_include) + return outlines def outputsites(w): "Output include file for secnet configuration"