blob: eac0887b45364def174b7c2fc945edf3ed4bd312 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
TMPL_DIR := templates-cfg
OP_TMPL_DIR := templates-op
BUILD_DIR := build
DATA_DIR := data
SHIM_DIR := src/shim
LIBS := -lzmq
CFLAGS :=
BUILD_ARCH := $(shell dpkg-architecture -q DEB_BUILD_ARCH)
J2LINT := $(shell command -v j2lint 2> /dev/null)
PYLINT_FILES := $(shell (git ls-files '*.py' src/migration-scripts; git grep -lE '^\#!.*python' -- ':!*.py') | sort -u)
config_xml_src = $(wildcard interface-definitions/*.xml.in)
config_xml_obj = $(config_xml_src:.xml.in=.xml)
op_xml_src = $(wildcard op-mode-definitions/*.xml.in)
op_xml_obj = $(op_xml_src:.xml.in=.xml)
.PHONY: libvyosconfig
libvyosconfig:
@if [ ! -f /usr/lib/libvyosconfig.so.0 ]; then \
make -C libvyosconfig clean ; \
make -C libvyosconfig all ; \
sudo make -C libvyosconfig install ; \
fi
%.xml: %.xml.in
@echo Generating $(BUILD_DIR)/$@ from $<
mkdir -p $(BUILD_DIR)/$(dir $@)
$(CURDIR)/scripts/transclude-template $< > $(BUILD_DIR)/$@
.PHONY: interface_definitions
.ONESHELL:
interface_definitions: libvyosconfig $(config_xml_obj)
rm -rf $(TMPL_DIR); mkdir -p $(TMPL_DIR)
$(CURDIR)/scripts/override-default $(BUILD_DIR)/interface-definitions
$(CURDIR)/scripts/override-help $(BUILD_DIR)/interface-definitions
$(CURDIR)/scripts/check-properties-collision $(BUILD_DIR)/interface-definitions
find $(BUILD_DIR)/interface-definitions -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-templates {} $(CURDIR)/schema/interface_definition.rng $(TMPL_DIR) || exit 1
# XXX: delete top level node.def's that now live in other packages
# IPSec VPN EAP-RADIUS does not support source-address
rm -rf $(TMPL_DIR)/vpn/ipsec/remote-access/radius/source-address
# T2472 - EIGRP support
rm -rf $(TMPL_DIR)/protocols/eigrp
# T2773 - EIGRP support for VRF
rm -rf $(TMPL_DIR)/vrf/name/node.tag/protocols/eigrp
# Pass excluded paths in format above for ease of comparison, as they
# will be converted by script.
$(CURDIR)/python/vyos/xml_ref/generate_cache.py --xml-dir $(BUILD_DIR)/interface-definitions --internal-cache $(DATA_DIR)/reftree.cache \
--exclude-paths '/vpn/ipsec/remote-access/radius/source-address' '/protocols/eigrp' '/vrf/name/node.tag/protocols/eigrp' || exit 1
# XXX: test if there are empty node.def files - this is not allowed as these
# could mask help strings or mandatory priority statements
find $(TMPL_DIR) -name node.def -type f -empty -exec false {} + || sh -c 'echo "There are empty node.def files! Check your interface definitions." && exit 1'
.PHONY: op_mode_definitions
.ONESHELL:
op_mode_definitions: $(op_xml_obj)
rm -rf $(OP_TMPL_DIR); mkdir -p $(OP_TMPL_DIR)
find $(BUILD_DIR)/op-mode-definitions/ -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-op-templates {} $(CURDIR)/schema/op-mode-definition.rng $(OP_TMPL_DIR) || exit 1
$(CURDIR)/python/vyos/xml_ref/generate_op_cache.py --xml-dir $(BUILD_DIR)/op-mode-definitions --export-json $(DATA_DIR)/op_cache.json || exit 1
# XXX: tcpdump, ping, traceroute and mtr must be able to recursively call themselves as the
# options are provided from the scripts themselves
ln -s ../node.tag $(OP_TMPL_DIR)/ping/node.tag/node.tag/
ln -s ../node.tag $(OP_TMPL_DIR)/traceroute/node.tag/node.tag/
ln -s ../node.tag $(OP_TMPL_DIR)/mtr/node.tag/node.tag/
ln -s ../node.tag $(OP_TMPL_DIR)/monitor/traceroute/node.tag/node.tag/
ln -s ../node.tag $(OP_TMPL_DIR)/monitor/traffic/interface/node.tag/node.tag/
ln -s ../node.tag $(OP_TMPL_DIR)/execute/port-scan/host/node.tag/node.tag/
# XXX: test if there are empty node.def files - this is not allowed as these
# could mask help strings or mandatory priority statements
find $(OP_TMPL_DIR) -name node.def -type f -empty -exec false {} + || sh -c 'echo "There are empty node.def files! Check your interface definitions." && exit 1'
.PHONY: vyshim
vyshim:
$(MAKE) -C $(SHIM_DIR)
.PHONY: ocaml
ocaml: libvyosconfig
$(MAKE) -C src/ocaml
.PHONY: all
all: clean copyright check_scripts_not_executable libvyosconfig pylint interface_definitions op_mode_definitions test j2lint vyshim generate-configd-include-json generate-activation-scripts-json ocaml
.PHONY: copyright
copyright:
@if git grep -q -E "Copyright( \(C\))? (19|20)[0-9]{2}(-[0-9]{4})? VyOS maintainers"; then \
echo "Error: Legacy copyright notice found."; \
exit 1; \
fi
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
rm -rf $(TMPL_DIR)
rm -rf $(OP_TMPL_DIR)
$(MAKE) -C $(SHIM_DIR) clean
$(MAKE) -C src/ocaml clean
.PHONY: test
test: generate-configd-include-json
set -e; python3 -m compileall -q -x '/vmware-tools/scripts/' .
PYTHONPATH=python/ python3 -m nose2 -v
.PHONY: check_scripts_not_executable
check_scripts_not_executable:
@echo "Checking that conf_mode and migration scripts have no executable bit set..."
@find src/conf_mode src/migration-scripts -type f -perm /111 -print -exec false {} + || sh -c 'echo "Found executable files! Remove executable bit." && exit 1'
.PHONY: pylint
pylint: interface_definitions
@echo Running "pylint ..."
# relative-beyond-top-level: the GraphQL scripts import relative to their
# package only when loaded as one
PYTHONPATH="python/:smoketest/scripts/cli/" pylint --jobs 0 \
--disable=all --enable=E,F,W0611 --disable=relative-beyond-top-level \
$(PYLINT_FILES)
.PHONY: j2lint
j2lint:
ifndef J2LINT
$(error "j2lint binary not found, consider installing: pip install git+https://github.com/aristanetworks/j2lint.git@341b5d5db86")
endif
$(J2LINT) data/
deb:
dpkg-buildpackage -uc -us -tc -b
.PHONY: generate-configd-include-json
generate-configd-include-json:
@scripts/generate-configd-include-json.py
.PHONY: generate-activation-scripts-json
generate-activation-scripts-json:
@scripts/generate-activation-scripts-json.py
.PHONY: schema
schema:
trang -I rnc -O rng schema/interface_definition.rnc schema/interface_definition.rng
trang -I rnc -O rng schema/op-mode-definition.rnc schema/op-mode-definition.rng
|