diff --git a/debian/control b/debian/control index 81df7b2..4cbf62c 100644 --- a/debian/control +++ b/debian/control @@ -40,6 +40,7 @@ Build-Depends: bash-completion, librust-walkdir-2+default-dev (>= 2.3.1-~~), librust-xz2-0.1+default-dev, libstd-rust-dev, + patchelf, python3-sphinx, rsync, rustc:native, diff --git a/debian/rules b/debian/rules index 444f703..8315869 100644 --- a/debian/rules +++ b/debian/rules @@ -32,3 +32,13 @@ override_dh_missing: override_dh_compress: dh_compress -X.pdf + +override_dh_strip: + dh_strip + for exe in $$(find \ + debian/proxmox-offline-mirror/usr \ + debian/proxmox-offline-mirror-helper/usr \ + -executable -type f); \ + do \ + debian/scripts/elf-strip-unused-dependencies.sh "$$exe" || true; \ + done diff --git a/debian/scripts/elf-strip-unused-dependencies.sh b/debian/scripts/elf-strip-unused-dependencies.sh new file mode 100755 index 0000000..9f89c09 --- /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