[pve-devel] [PATCH installer v3 09/20] debian: strip unused library dependencies

Christoph Heiss c.heiss at proxmox.com
Wed Aug 21 11:40:11 CEST 2024


Rust links in some dynamic libraries even if only used by a disabled
feature gate.

This will be needed due to moving http-related code into the
proxmox-installer-common crate and thus pulling it in at more places.

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Changes v2 -> v3:
  * no changes

Changes v1 -> v2:
  * print libraries being stripped from each binary

 debian/control |  1 +
 debian/rules   | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/debian/control b/debian/control
index eb4d3be..b7ddc11 100644
--- a/debian/control
+++ b/debian/control
@@ -26,6 +26,7 @@ Build-Depends: cargo:native,
                librust-toml-0.7-dev,
                librust-ureq-2.6-dev,
                libtest-mockmodule-perl,
+               patchelf,
                perl,
                rustc:native,
                shellcheck,
diff --git a/debian/rules b/debian/rules
index 1c03065..3cebdff 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,3 +10,16 @@ export BUILD_MODE=release
 
 override_dh_missing:
 	dh_missing --fail-missing
+
+override_dh_strip:
+	dh_strip
+	for f in $$(find debian/proxmox-installer debian/proxmox-auto-install-assistant -executable -type f); do \
+	  if file -bi "$$f" | grep -qP '^application'; then \
+	    deps="$$(ldd -u "$$f" | grep -oP '[^/:]+$$')"; \
+	    if [ ! -z "$$deps" ]; then \
+	      printf "stripping unused dependencies from $$f: "; \
+	      echo "$$deps" | tr '\n' ' '; echo; \
+	      echo "$$deps" | sed 's/^/--remove-needed /g' | xargs patchelf "$$f"; \
+	    fi \
+	  fi; \
+	done
-- 
2.45.2





More information about the pve-devel mailing list