talos/hack/cleanup.sh
Andrey Smirnov fc1237343f
chore: clean up /usr/bin
Based on importing following `pkgs` PRs:

* https://github.com/siderolabs/pkgs/pull/1242
* https://github.com/siderolabs/pkgs/pull/1243
* https://github.com/siderolabs/pkgs/pull/1244

Plus removing broken symlinks that exist because static binaries
are removed.

Remove outdated cleanup steps.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2025-05-22 15:07:54 +04:00

24 lines
909 B
Bash
Executable File

#!/bin/bash
PREFIX="${1}"
# Remove any archives as we do not need them since everything is dynamically linked.
find ${PREFIX} -type f -name \*.a -delete
find ${PREFIX} -type f -name \*.la -delete
# Remove static binaries.
find ${PREFIX} -type f \( -name \*.static -o -name \*.o \) -delete
# Strip debug symbols from all libraries and binaries.
find ${PREFIX}/{lib,usr/lib} -type f \( -name \*.so* -a ! -name \*dbg \) -exec strip --strip-unneeded {} ';' || true
find ${PREFIX}/usr/bin -type f -exec strip --strip-all {} ';' || true
# Remove header files, man files, and any other non-runtime dependencies.
rm -rf ${PREFIX}/usr/lib/pkgconfig/ \
${PREFIX}/{include,usr/include}/* \
${PREFIX}/share/* \
${PREFIX}/usr/lib/cmake \
${PREFIX}/usr/lib/gconv/ \
${PREFIX}/usr/libexec/getconf \
${PREFIX}/var/db
# Drop broken symlinks.
find ${PREFIX} -xtype l -print -delete