[pve-devel] [RFC PATCH installer] buildsys: add static version of proxmox-auto-install-assistant

Christoph Heiss c.heiss at proxmox.com
Fri Aug 16 18:19:03 CEST 2024


This adds a separate debian package to the build, containing a
statically-built version of `proxmox-auto-install-assistant`, as
was suggested in #4788 [0] (for proxmox-backup-client), separately by 
Thomas also.

Rust nowadays makes building static binaries pretty easy, even when
OpenSSL etc. is used.

NB: When run through lintian, the resulting package produces the
`shared-library-lacks-prerequisites`, which overalls seems rather
irrelevant (or even bogus?) in our case [1].

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=4788
[1] https://lists.debian.org/debian-lint-maint/2023/02/msg00045.html

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Marked RFC to see if the packaging is overall sane -- I haven't done a
lot of (Debian) packaging yet, so please don't hesitate with
suggestions.

 Makefile                                      | 22 +++++++++++++++----
 debian/control                                | 10 +++++++++
 ...xmox-auto-install-assistant-static.install |  1 +
 ...roxmox-auto-install-assistant-static.links |  1 +
 4 files changed, 30 insertions(+), 4 deletions(-)
 create mode 100644 debian/proxmox-auto-install-assistant-static.install
 create mode 100644 debian/proxmox-auto-install-assistant-static.links

diff --git a/Makefile b/Makefile
index e96a0f2..d288e82 100644
--- a/Makefile
+++ b/Makefile
@@ -5,14 +5,19 @@ BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
 
 DEB=$(PACKAGE)_$(DEB_VERSION)_$(DEB_HOST_ARCH).deb
 ASSISTANT_DEB=proxmox-auto-install-assistant_$(DEB_VERSION)_$(DEB_HOST_ARCH).deb
+ASSISTANT_STATIC_DEB=proxmox-auto-install-assistant-static_$(DEB_VERSION)_$(DEB_HOST_ARCH).deb
 DSC=$(PACKAGE)_$(DEB_VERSION).dsc
 
 CARGO ?= cargo
+CARGO_STATIC_TARGET ?= x86_64-unknown-linux-gnu
+
 ifeq ($(BUILD_MODE), release)
 CARGO_BUILD_ARGS += --release
 CARGO_COMPILEDIR := target/release
+CARGO_STATIC_COMPILEDIR := target/$(CARGO_STATIC_TARGET)/release
 else
 CARGO_COMPILEDIR := target/debug
+CARGO_STATIC_COMPILEDIR := target/$(CARGO_STATIC_TARGET)/debug
 endif
 
 INSTALLER_SOURCES=$(shell git ls-files) country.dat
@@ -71,9 +76,10 @@ country.dat: country.pl
 
 deb: $(DEB)
 $(ASSISTANT_DEB): $(DEB)
+$(ASSISTANT_STATIC_DEB): auto-install-assistant-static
 $(DEB): $(BUILDDIR)
 	cd $(BUILDDIR); dpkg-buildpackage -b -us -uc
-	lintian $(DEB)
+	lintian $(DEB) $(ASSISTANT_STATIC_DEB)
 
 test-$(DEB): $(INSTALLER_SOURCES)
 	rsync --exclude='test*.img' --exclude='*.deb' --exclude='build' -a * build
@@ -109,7 +115,7 @@ VARLIBDIR=$(DESTDIR)/var/lib/proxmox-installer
 HTMLDIR=$(VARLIBDIR)/html/common
 
 .PHONY: install
-install: $(INSTALLER_SOURCES) $(COMPILED_BINS)
+install: $(INSTALLER_SOURCES) $(COMPILED_BINS) auto-install-assistant-static
 	$(MAKE) -C banner install
 	$(MAKE) -C Proxmox install
 	install -D -m 644 interfaces $(DESTDIR)/etc/network/interfaces
@@ -120,6 +126,7 @@ install: $(INSTALLER_SOURCES) $(COMPILED_BINS)
 	install -D -m 755 proxinstall $(DESTDIR)/usr/bin/proxinstall
 	install -D -m 755 proxmox-low-level-installer $(DESTDIR)/$(BINDIR)/proxmox-low-level-installer
 	$(foreach i,$(USR_BIN), install -m755 $(CARGO_COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
+	install -D -m 755 $(CARGO_STATIC_COMPILEDIR)/proxmox-auto-install-assistant $(DESTDIR)$(BINDIR)/proxmox-auto-install-assistant-static
 	install -D -m 755 checktime $(DESTDIR)/usr/bin/checktime
 	install -D -m 644 xinitrc $(DESTDIR)/.xinitrc
 	install -D -m 755 spice-vdagent.sh $(DESTDIR)/.spice-vdagent.sh
@@ -134,13 +141,20 @@ cargo-build:
 		--package proxmox-auto-install-assistant --bin proxmox-auto-install-assistant \
 		--package proxmox-chroot --bin proxmox-chroot $(CARGO_BUILD_ARGS)
 
+.PHONY: auto-install-assistant-static
+auto-install-assistant-static:
+	RUSTFLAGS='-C target-feature=+crt-static' cargo build \
+		--package proxmox-auto-install-assistant \
+		--target $(CARGO_STATIC_TARGET) $(CARGO_BUILD_ARGS)
+
 %-banner.png: %-banner.svg
 	rsvg-convert -o $@ $<
 
 .PHONY: upload
 upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
-upload: $(DEB) $(ASSISTANT_DEB)
-	tar cf - $(DEB) $(ASSISTANT_DEB) | ssh -X repoman at repo.proxmox.com -- upload --product pve,pmg,pbs --dist $(UPLOAD_DIST)
+upload: $(DEB) $(ASSISTANT_DEB) $(ASSISTANT_STATIC_DEB)
+	tar cf - $(DEB) $(ASSISTANT_DEB) $(ASSISTANT_STATIC_DEB) \
+		| ssh -X repoman at repo.proxmox.com -- upload --product pve,pmg,pbs --dist $(UPLOAD_DIST)
 
 %.img:
 	truncate -s 2G $@
diff --git a/debian/control b/debian/control
index 04b0c6e..6bf3cd5 100644
--- a/debian/control
+++ b/debian/control
@@ -61,3 +61,13 @@ Description: Assistant to help with automated installations
  Provides a helper that can assist with creating an answer file for a automated
  installation of a Proxmox project, and preparing a official ISO image to use
  this answer file.
+
+Package: proxmox-auto-install-assistant-static
+Architecture: any
+Recommends: xorriso,
+Conflicts: proxmox-auto-install-assistant
+Provides: proxmox-auto-install-assistant
+Description: Assistant to help with automated installations - static build
+ Provides a helper that can assist with creating an answer file for a automated
+ installation of a Proxmox project, and preparing a official ISO image to use
+ this answer file.
diff --git a/debian/proxmox-auto-install-assistant-static.install b/debian/proxmox-auto-install-assistant-static.install
new file mode 100644
index 0000000..abd2c64
--- /dev/null
+++ b/debian/proxmox-auto-install-assistant-static.install
@@ -0,0 +1 @@
+usr/bin/proxmox-auto-install-assistant-static
diff --git a/debian/proxmox-auto-install-assistant-static.links b/debian/proxmox-auto-install-assistant-static.links
new file mode 100644
index 0000000..28e003c
--- /dev/null
+++ b/debian/proxmox-auto-install-assistant-static.links
@@ -0,0 +1 @@
+usr/bin/proxmox-auto-install-assistant-static usr/bin/proxmox-auto-install-assistant
-- 
2.45.2





More information about the pve-devel mailing list