d/rules: patch out wrongly linked libraries from ELFs

Adapted from proxmox-backup's 198ebc6c ("d/rules: patch out wrongly
linked libraries from ELFs")

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-06-17 11:24:25 +02:00
parent 6346bb5599
commit e0663bd83f
3 changed files with 31 additions and 0 deletions

1
debian/control vendored
View File

@ -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,

10
debian/rules vendored
View File

@ -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

View File

@ -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