[Xorp-hackers] [PATCH] xorp: etc: templates: Add option for skipping click entry in fea.tp.raw
igorm at etf.rs
igorm at etf.rs
Mon Feb 20 07:22:38 PST 2012
From: Igor Maravic <igorm at etf.rs>
Added this option, so the created fea.tp would be without click code, when click is not compiled
in to the Xorp. This code works when click code starts with "click {". That's the case for now.
Signed-off-by: Igor Maravic <igorm at etf.rs>
---
xorp/etc/templates/SConscript | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/xorp/etc/templates/SConscript b/xorp/etc/templates/SConscript
index 62aa501..fcab12e 100644
--- a/xorp/etc/templates/SConscript
+++ b/xorp/etc/templates/SConscript
@@ -96,9 +96,13 @@ if env['enable_xorpsh']:
def BuildXrlTemplate(target, source, env):
# base = tp[:-len('.raw')]
skip_fw = False
+ skip_click = True
if (env.has_key('disable_fw') and env['disable_fw']):
skip_fw = True
+ if (env.has_key('enable_click') and env['enable_click']):
+ skip_click = False
+
sfname = str(source[0])
print "source: ", sfname
@@ -109,11 +113,27 @@ def BuildXrlTemplate(target, source, env):
if sfname == 'etc/templates/fea.tp.raw':
ignore_ln = re.compile(".*firewall.*")
+
+ opened_brackets = 0
+ opened_bracket_ln = re.compile(".*{.*")
+ closed_bracket_ln = re.compile(".*}.*")
+ click_ln = re.compile(".*click.*")
+
for line in ifile.readlines():
- if not (skip_fw and ignore_ln.match(line)):
- if line[-1] == "\n":
- # trim trailing newline
- line = line[0 : -1]
+ if opened_brackets > 0:
+ if opened_bracket_ln.match(line):
+ opened_brackets += 1
+ if closed_bracket_ln.match(line):
+ opened_brackets -= 1
+ continue
+ if (skip_fw and ignore_ln.match(line)):
+ continue
+ if (skip_click and click_ln.match(line)):
+ opened_brackets = 1
+ continue
+ if line[-1] == "\n":
+ # trim trailing newline
+ line = line[0 : -1]
print >>ofile, "%s" % line
else:
return -1 # error
--
1.7.5.4
More information about the Xorp-hackers
mailing list