From 9b0209c041eb181b6eb916c1ab64fe662eaa3f8f Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 18 Feb 2025 15:57:15 +0100 Subject: [PATCH 1/6] Makefile: do not build twice netavark netavark-dhcp-proxy-client is alreayd build as part of the normal cargo build. So there is really no need to build again. Signed-off-by: Paul Holzinger --- Makefile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 4b0a18a8..11e4d575 100644 --- a/Makefile +++ b/Makefile @@ -50,12 +50,10 @@ $(CARGO_TARGET_DIR): mkdir -p $@ .PHONY: build -build: build_netavark build_proxy_client - -.PHONY: build_netavark -build_netavark: bin $(CARGO_TARGET_DIR) +build: bin $(CARGO_TARGET_DIR) $(CARGO) build $(release) cp $(CARGO_TARGET_DIR)/$(profile)/netavark bin/netavark$(if $(debug),.debug,) + cp $(CARGO_TARGET_DIR)/$(profile)/netavark-dhcp-proxy-client bin/netavark-dhcp-proxy-client$(if $(debug),.debug,) .PHONY: examples examples: bin $(CARGO_TARGET_DIR) @@ -152,8 +150,3 @@ mock-rpm: .PHONY: help help: @echo "usage: make $(prog) [debug=1]" - -.PHONY: build_proxy_client -build_proxy_client: bin $(CARGO_TARGET_DIR) - $(CARGO) build --bin netavark-dhcp-proxy-client $(release) - cp $(CARGO_TARGET_DIR)/$(profile)/netavark-dhcp-proxy-client bin/netavark-dhcp-proxy-client$(if $(debug),.debug,) From c1518c9fd1deb57aa2c7cf0fd2aba28da5f971b6 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 18 Feb 2025 16:42:40 +0100 Subject: [PATCH 2/6] Makefile: build docs by default A normal make should build the binaries and docs. Signed-off-by: Paul Holzinger --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 11e4d575..9f3dfafd 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ else endif .PHONY: all -all: build +all: build docs bin: mkdir -p $@ From 86686431eb288627e754c6a6f2e66fad847d009d Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 18 Feb 2025 16:52:48 +0100 Subject: [PATCH 3/6] docs/Makefile: several fixes - build docs on install if needed - clean should remove the .7 page - add uninstall target so users can remove the pages from the system Fixes #1179 Signed-off-by: Paul Holzinger --- Makefile | 1 + docs/Makefile | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9f3dfafd..2099a50f 100644 --- a/Makefile +++ b/Makefile @@ -102,6 +102,7 @@ install: $(NV_UNIT_FILES) .PHONY: uninstall uninstall: + $(MAKE) -C docs uninstall rm -f $(DESTDIR)$(LIBEXECPODMAN)/netavark rm -f $(PREFIX)/share/man/man1/netavark*.1 rm -f ${DESTDIR}${SYSTEMDDIR}/netavark-dhcp-proxy.service diff --git a/docs/Makefile b/docs/Makefile index 72449fb2..9d24f303 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -17,12 +17,17 @@ docs: $(patsubst %.md,%,$(wildcard *.[0-9].md)) $(GO) install github.com/cpuguy83/go-md2man/v2@latest .PHONY: install -install: +install: docs install -d ${DESTDIR}/${MANDIR}/man1 install -m 0644 *.1 ${DESTDIR}/${MANDIR}/man1 install -d ${DESTDIR}/${MANDIR}/man7 install -m 0644 *.7 ${DESTDIR}/${MANDIR}/man7 +.PHONY: uninstall +uninstall: + rm -f ${DESTDIR}/${MANDIR}/man1/*.1 + rm -f ${DESTDIR}/${MANDIR}/man7/*.7 + .PHONY: clean clean: - $(RM) *.1 + $(RM) *.1 *.7 From 4ac156310e5534821b2dd649e2ac236ff5032b03 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 18 Feb 2025 17:04:11 +0100 Subject: [PATCH 4/6] Makefile: uninstall netavark-firewalld-reload.service Ensure we also uninstall netavark-firewalld-reload.service. Signed-off-by: Paul Holzinger --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 2099a50f..9337b3f0 100644 --- a/Makefile +++ b/Makefile @@ -107,6 +107,7 @@ uninstall: rm -f $(PREFIX)/share/man/man1/netavark*.1 rm -f ${DESTDIR}${SYSTEMDDIR}/netavark-dhcp-proxy.service rm -f ${DESTDIR}${SYSTEMDDIR}/netavark-dhcp-proxy.socket + rm -f ${DESTDIR}${SYSTEMDDIR}/netavark-firewalld-reload.service .PHONY: test test: unit integration From a08bb557fd606e12cc5b6452df0e88fbc544fe67 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 18 Feb 2025 17:22:17 +0100 Subject: [PATCH 5/6] Makefile: do not rebuild if nothing changed If the src has not changed there is no need to rebuild. This removes the -debug suffix from the binary if build with debug set, I doubt anyone actually uses this and we need the same name for the bin/netavark target to actually work. This is even better because now you could build a debug binary and run the test with it without changing the test path manually. Fixes #1178 Signed-off-by: Paul Holzinger --- Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9337b3f0..210eb4c7 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,8 @@ CARGO ?= cargo CARGO_TARGET_DIR ?= targets export CARGO_TARGET_DIR # 'cargo' is sensitive to this env. var. value. +SOURCES = src/** Cargo.toml Cargo.lock + ifdef debug $(info debug is $(debug)) # These affect both $(CARGO_TARGET_DIR) layout and contents @@ -50,10 +52,13 @@ $(CARGO_TARGET_DIR): mkdir -p $@ .PHONY: build -build: bin $(CARGO_TARGET_DIR) +build: bin/netavark + +bin/netavark: $(SOURCES) bin $(CARGO_TARGET_DIR) $(CARGO) build $(release) - cp $(CARGO_TARGET_DIR)/$(profile)/netavark bin/netavark$(if $(debug),.debug,) - cp $(CARGO_TARGET_DIR)/$(profile)/netavark-dhcp-proxy-client bin/netavark-dhcp-proxy-client$(if $(debug),.debug,) + cp $(CARGO_TARGET_DIR)/$(profile)/netavark bin/netavark + cp $(CARGO_TARGET_DIR)/$(profile)/netavark-dhcp-proxy-client bin/netavark-dhcp-proxy-client + .PHONY: examples examples: bin $(CARGO_TARGET_DIR) From f990a783a089c231d608cd7d46abf4194ad4b0d3 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 20 Feb 2025 12:07:36 +0100 Subject: [PATCH 6/6] cirrus: do not build debug bins They are not used anywhere so it is just a waste of time and given we no longer use a different name we cannot store them. Instead build the examples as part of the build task. Signed-off-by: Paul Holzinger --- .cirrus.yml | 2 -- contrib/cirrus/runner.sh | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 49894815..6e0c51fc 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -257,10 +257,8 @@ success_task: API_URL_BASE: "https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}" EXP_BINS: >- netavark - netavark.debug netavark.info netavark.aarch64-unknown-linux-gnu - netavark.debug.aarch64-unknown-linux-gnu netavark.info.aarch64-unknown-linux-gnu clone_script: *noop bin_cache: *ro_bin_cache diff --git a/contrib/cirrus/runner.sh b/contrib/cirrus/runner.sh index 6ecdb6e7..2202ea49 100755 --- a/contrib/cirrus/runner.sh +++ b/contrib/cirrus/runner.sh @@ -19,9 +19,9 @@ _run_noarg() { _run_build() { # Assume we're on a fast VM, compile everything needed by the # rest of CI since subsequent tasks may have limited resources. - make all debug=1 make build_unit # reuses some debug binaries make all # optimized/non-debug binaries + make examples # build the examples binaries needed by the integration tests # This will get scooped up and become part of the artifact archive. # Identify where the binary came from to benefit downstream consumers. cat | tee bin/netavark.info << EOF