summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-05-17 06:51:44 +0200
committerDaniil Baturin <daniil@baturin.org>2018-05-17 06:51:44 +0200
commit362a791650858eea3b79e154a218630c7a4fdbea (patch)
treed30a1e9fb4c16d820a5296c6b7161eec99d4e89d
parentaf97e7d09644cd14b7cd0c2aab42d329dcbd9ae1 (diff)
downloadvyos-1x-362a791650858eea3b79e154a218630c7a4fdbea.tar.gz
vyos-1x-362a791650858eea3b79e154a218630c7a4fdbea.zip
T646: prevent convertors from overwriting existing node.def files.
-rw-r--r--Makefile2
-rwxr-xr-xscripts/build-command-op-templates20
-rwxr-xr-xscripts/build-command-templates9
3 files changed, 24 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index d1ac73c2f..cec6d7076 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ op_mode_definitions:
rm -f $(OP_TMPL_DIR)/monitor/node.def
.PHONY: all
-all: interface_definitions op_mode_definitions
+all: clean interface_definitions op_mode_definitions
.PHONY: clean
clean:
diff --git a/scripts/build-command-op-templates b/scripts/build-command-op-templates
index 865590c2c..25f03cf91 100755
--- a/scripts/build-command-op-templates
+++ b/scripts/build-command-op-templates
@@ -169,8 +169,13 @@ def process_node(n, tmpl_dir):
if debug:
print("Processing node {}".format(name))
- with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f:
- f.write(make_node_def(props, command))
+ nodedef_path = os.path.join(make_path(my_tmpl_dir), "node.def")
+ if not os.path.exists(nodedef_path):
+ with open(nodedef_path, "w") as f:
+ f.write(make_node_def(props, command))
+ else:
+ # Something has already generated this file
+ pass
if children is not None:
inner_nodes = children.iterfind("*")
@@ -182,14 +187,21 @@ def process_node(n, tmpl_dir):
os.makedirs(make_path(my_tmpl_dir), exist_ok=True)
- with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f:
- f.write('help: {0}\0'.format(props['help']))
+ nodedef_path = os.path.join(make_path(my_tmpl_dir), "node.def")
+ if not os.path.exists(nodedef_path):
+ with open(nodedef_path, "w") as f:
+ f.write('help: {0}\n'.format(props['help']))
+ else:
+ # Something has already generated this file
+ pass
+ # Create the inner node.tag part
my_tmpl_dir.append("node.tag")
os.makedirs(make_path(my_tmpl_dir), exist_ok=True)
if debug:
print("Created path for the tagNode: {}".format(make_path(my_tmpl_dir)), end="")
+ # Not sure if we want partially defined tag nodes, write the file unconditionally
with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f:
f.write(make_node_def(props, command))
diff --git a/scripts/build-command-templates b/scripts/build-command-templates
index a99f317d7..88223ea80 100755
--- a/scripts/build-command-templates
+++ b/scripts/build-command-templates
@@ -265,8 +265,13 @@ def process_node(n, tmpl_dir):
props["tag"] = "True"
- with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f:
- f.write(make_node_def(props))
+ nodedef_path = os.path.join(make_path(my_tmpl_dir), "node.def")
+ if not os.path.exists(nodedef_path):
+ with open(nodedef_path, "w") as f:
+ f.write(make_node_def(props))
+ else:
+ # Something has already generated that file
+ pass
if node_type == "node":