diff --git a/debian/control b/debian/control index d78e575d..8a4d1dd1 100644 --- a/debian/control +++ b/debian/control @@ -85,6 +85,7 @@ Build-Depends: debhelper (>= 11), fonts-open-sans , graphviz , latexmk , + patchelf, pve-eslint (>= 7.12.1-1), python3-docutils, python3-pygments, diff --git a/debian/debcargo.toml b/debian/debcargo.toml index afb9ffa0..612b5e33 100644 --- a/debian/debcargo.toml +++ b/debian/debcargo.toml @@ -18,6 +18,7 @@ build_depends = [ "fonts-open-sans ", "graphviz ", "latexmk ", + "patchelf", "pve-eslint (>= 7.12.1-1)", "python3-docutils", "python3-pygments", diff --git a/debian/rules b/debian/rules index 9012f82f..22671c0a 100755 --- a/debian/rules +++ b/debian/rules @@ -50,5 +50,12 @@ override_dh_fixperms: override_dh_dwz: dh_dwz --no-dwz-multifile +override_dh_strip: + dh_strip + for exe in $$(find debian/proxmox-backup-client/usr \ + debian/proxmox-backup-server/usr -executable -type f); do \ + debian/scripts/elf-strip-unused-dependencies.sh "$$exe" || true; \ + done + override_dh_compress: dh_compress -X.pdf diff --git a/debian/scripts/elf-strip-unused-dependencies.sh b/debian/scripts/elf-strip-unused-dependencies.sh new file mode 100755 index 00000000..9f89c09c --- /dev/null +++ b/debian/scripts/elf-strip-unused-dependencies.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +binary=$1 + +exec 3< <(ldd -u "$binary" | grep -oP '[^/:]+$') + +patchargs="" +dropped="" +while read -r dep; do + dropped="$dep $dropped" + patchargs="--remove-needed $dep $patchargs" +done <&3 +exec 3<&- + +if [[ $dropped == "" ]]; then + exit 0 +fi + +echo -e "patchelf '$binary' - removing unused dependencies:\n $dropped" +patchelf $patchargs $binary