[pbs-devel] [PATCH proxmox-backup] build: include pxar in static binary compilation and package

Christian Ebner c.ebner at proxmox.com
Thu Apr 10 16:00:15 CEST 2025


The debian package providing the dynamically linked version of the
proxmox-backup-client is packaged together with the pxar executable.

To be in line and for user convenience, include a statically linked
version of pxar to the static package as well.

Renames STATIC_BIN env variable to STATIC_BINS to reflect that this
now covers multiple binaries and store rustc flags in its own
variable so they can be reused since `cargo rustc` does not allow
invocations with multiple `--package` arguments at once.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 Makefile                                      | 19 ++++++++++++-------
 ...oxmox-backup-client-static.bash-completion |  1 +
 debian/proxmox-backup-client-static.install   |  2 ++
 debian/rules                                  |  1 +
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index d74701462..2f81dc91d 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,8 @@ COMPILEDIR := target/$(DEB_HOST_RUST_TYPE)/debug
 STATIC_COMPILEDIR := $(STATIC_TARGET_DIR)/$(DEB_HOST_RUST_TYPE)/debug
 endif
 
+STATIC_RUSTC_FLAGS := -C target-feature=+crt-static -L $(STATIC_COMPILEDIR)/deps-stubs/
+
 ifeq ($(valgrind), yes)
 CARGO_BUILD_ARGS += --features valgrind
 endif
@@ -59,8 +61,8 @@ CARGO ?= cargo
 COMPILED_BINS := \
 	$(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN) $(RESTORE_BIN))
 
-STATIC_BIN := \
-	$(addprefix $(STATIC_COMPILEDIR)/,proxmox-backup-client-static)
+STATIC_BINS := \
+	$(addprefix $(STATIC_COMPILEDIR)/,proxmox-backup-client-static pxar-static)
 
 export DEB_VERSION DEB_VERSION_UPSTREAM
 
@@ -207,7 +209,7 @@ $(COMPILED_BINS) $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen: .do-
 lint:
 	cargo clippy -- -A clippy::all -D clippy::correctness
 
-install: $(COMPILED_BINS) $(STATIC_BIN)
+install: $(COMPILED_BINS) $(STATIC_BINS)
 	install -dm755 $(DESTDIR)$(BINDIR)
 	install -dm755 $(DESTDIR)$(ZSH_COMPL_DEST)
 	$(foreach i,$(USR_BIN), \
@@ -227,6 +229,7 @@ install: $(COMPILED_BINS) $(STATIC_BIN)
 	$(foreach i,$(SERVICE_BIN), \
 	    install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
 	install -m755 $(STATIC_COMPILEDIR)/proxmox-backup-client $(DESTDIR)$(BINDIR)/proxmox-backup-client-static
+	install -m755 $(STATIC_COMPILEDIR)/pxar $(DESTDIR)$(BINDIR)/pxar-static
 	$(MAKE) -C www install
 	$(MAKE) -C docs install
 	$(MAKE) -C templates install
@@ -244,11 +247,13 @@ upload: $(SERVER_DEB) $(CLIENT_DEB) $(RESTORE_DEB) $(DOC_DEB) $(STATIC_CLIENT_DE
 
 .PHONY: proxmox-backup-client-static
 proxmox-backup-client-static:
-	rm -f $(STATIC_BIN)
-	$(MAKE) $(STATIC_BIN)
+	rm -f $(STATIC_BINS)
+	$(MAKE) $(STATIC_BINS)
 
-$(STATIC_BIN):
+$(STATIC_BINS):
 	mkdir -p $(STATIC_COMPILEDIR)/deps-stubs/ && \
           echo '!<arch>' > $(STATIC_COMPILEDIR)/deps-stubs/libsystemd.a # workaround for to greedy linkage and proxmox-systemd
+	$(CARGO) rustc $(CARGO_BUILD_ARGS) --package pxar-bin --bin pxar \
+	  --target-dir $(STATIC_TARGET_DIR) -- $(STATIC_RUSTC_FLAGS)
 	$(CARGO) rustc $(CARGO_BUILD_ARGS) --package proxmox-backup-client --bin proxmox-backup-client \
-          --target-dir $(STATIC_TARGET_DIR) -- -C target-feature=+crt-static -L $(STATIC_COMPILEDIR)/deps-stubs/
+	  --target-dir $(STATIC_TARGET_DIR) -- $(STATIC_RUSTC_FLAGS)
diff --git a/debian/proxmox-backup-client-static.bash-completion b/debian/proxmox-backup-client-static.bash-completion
index f8b9b4394..437360175 100644
--- a/debian/proxmox-backup-client-static.bash-completion
+++ b/debian/proxmox-backup-client-static.bash-completion
@@ -1 +1,2 @@
 debian/proxmox-backup-client.bc proxmox-backup-client
+debian/pxar.bc pxar
diff --git a/debian/proxmox-backup-client-static.install b/debian/proxmox-backup-client-static.install
index f8a681d0a..6a913b677 100644
--- a/debian/proxmox-backup-client-static.install
+++ b/debian/proxmox-backup-client-static.install
@@ -1,2 +1,4 @@
 usr/share/man/man1/proxmox-backup-client.1
+usr/share/man/man1/pxar.1
 usr/share/zsh/vendor-completions/_proxmox-backup-client
+usr/share/zsh/vendor-completions/_pxar
diff --git a/debian/rules b/debian/rules
index be7c93c2e..70cec4754 100755
--- a/debian/rules
+++ b/debian/rules
@@ -49,6 +49,7 @@ override_dh_auto_install:
 	    LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
 	mkdir -p debian/proxmox-backup-client-static/usr/bin
 	mv debian/tmp/usr/bin/proxmox-backup-client-static debian/proxmox-backup-client-static/usr/bin/proxmox-backup-client
+	mv debian/tmp/usr/bin/pxar-static debian/proxmox-backup-client-static/usr/bin/pxar
 
 override_dh_installsystemd:
 	dh_installsystemd -pproxmox-backup-server  proxmox-backup-daily-update.timer
-- 
2.39.5





More information about the pbs-devel mailing list