proxmox-offline-mirror/debian/scripts/elf-strip-unused-dependencies.sh
Thomas Lamprecht e0663bd83f 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>
2023-06-29 13:10:07 +02:00

21 lines
361 B
Bash
Executable File

#!/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