d/rules: patch out wrongly linked libraries from ELFs
this is a HACK! It seems that due to lots of binaries getting compiled from a single crate the compiler is confused when linking in dependencies to each binaries ELF. It picks up the combined set (union) of all dependencies and sets those to every ELF. This results in the client, for example, linking to libapt-pkg or libsystemd even if none of that symbols are used.. This could be possibly fixed by restructuring the source tree into sub crates/workspaces or what not, not really tested and *lots* of work. So as stop gap measure use `ldd -u` to find out unused linkage and remove them using `patchelf`. While this works well, and seems to not interfere with any debug symbol usage or other usage in general it still is a hack and should be dropped once the restructuring of the source tree has shown to bring similar effects. This allows for much easier re-use of the generated client .deb package on other Debian derivaties (e.g., Ubuntu) which got blocked until now due to wrong libt-apt verison or the like. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
a8abcd9b30
commit
198ebc6c86
|
@ -85,6 +85,7 @@ Build-Depends: debhelper (>= 11),
|
||||||
fonts-open-sans <!nodoc>,
|
fonts-open-sans <!nodoc>,
|
||||||
graphviz <!nodoc>,
|
graphviz <!nodoc>,
|
||||||
latexmk <!nodoc>,
|
latexmk <!nodoc>,
|
||||||
|
patchelf,
|
||||||
pve-eslint (>= 7.12.1-1),
|
pve-eslint (>= 7.12.1-1),
|
||||||
python3-docutils,
|
python3-docutils,
|
||||||
python3-pygments,
|
python3-pygments,
|
||||||
|
|
|
@ -18,6 +18,7 @@ build_depends = [
|
||||||
"fonts-open-sans <!nodoc>",
|
"fonts-open-sans <!nodoc>",
|
||||||
"graphviz <!nodoc>",
|
"graphviz <!nodoc>",
|
||||||
"latexmk <!nodoc>",
|
"latexmk <!nodoc>",
|
||||||
|
"patchelf",
|
||||||
"pve-eslint (>= 7.12.1-1)",
|
"pve-eslint (>= 7.12.1-1)",
|
||||||
"python3-docutils",
|
"python3-docutils",
|
||||||
"python3-pygments",
|
"python3-pygments",
|
||||||
|
|
|
@ -50,5 +50,12 @@ override_dh_fixperms:
|
||||||
override_dh_dwz:
|
override_dh_dwz:
|
||||||
dh_dwz --no-dwz-multifile
|
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:
|
override_dh_compress:
|
||||||
dh_compress -X.pdf
|
dh_compress -X.pdf
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue