diff options
author | Daniil Baturin <daniil@vyos.io> | 2023-10-03 10:15:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-03 10:15:55 +0100 |
commit | 3639462b57b96fbde39368ff4f6a8a41b6ac7537 (patch) | |
tree | a4bbdd51931f32b75546031a4d7fbf49739d7f15 /data | |
parent | 888c90b5251ca5e50d36daf20bfa1e4d5d812cad (diff) | |
parent | 51cf19f1354fdd871dd3cdcb36bcdefb9a86fd06 (diff) | |
download | vyos-build-3639462b57b96fbde39368ff4f6a8a41b6ac7537.tar.gz vyos-build-3639462b57b96fbde39368ff4f6a8a41b6ac7537.zip |
Merge pull request #426 from Apachez-/T5589
T5589: Nonstripped binaries exists in VyOS
Diffstat (limited to 'data')
-rwxr-xr-x | data/live-build-config/hooks/live/99-strip-symbols.chroot | 63 | ||||
-rw-r--r-- | data/live-build-config/package-lists/vyos-utils.list.chroot | 1 |
2 files changed, 64 insertions, 0 deletions
diff --git a/data/live-build-config/hooks/live/99-strip-symbols.chroot b/data/live-build-config/hooks/live/99-strip-symbols.chroot new file mode 100755 index 00000000..ba3356ca --- /dev/null +++ b/data/live-build-config/hooks/live/99-strip-symbols.chroot @@ -0,0 +1,63 @@ +#!/bin/sh + +# +# Discard symbols and other data from object files. +# +# Reference: +# https://www.linuxfromscratch.org/lfs/view/systemd/chapter08/stripping.html +# https://www.debian.org/doc/debian-policy/ch-files.html +# + +# Set variables. +STRIPCMD_REGULAR="strip --remove-section=.comment --remove-section=.note --preserve-dates" +STRIPCMD_DEBUG="strip --strip-debug --remove-section=.comment --remove-section=.note --preserve-dates" +STRIPCMD_UNNEEDED="strip --strip-unneeded --remove-section=.comment --remove-section=.note --preserve-dates" +STRIPDIR_REGULAR=" +" +STRIPDIR_DEBUG=" +/usr/lib/modules +" +STRIPDIR_UNNEEDED=" +/etc/hsflowd/modules +/usr/bin +/usr/lib/openvpn +/usr/lib/x86_64-linux-gnu +/usr/lib32 +/usr/lib64 +/usr/libx32 +/usr/sbin +" + +# Perform stuff. +echo "Stripping symbols..." + +# CMD: strip +for DIR in ${STRIPDIR_REGULAR}; do + echo "Parse dir (strip): ${DIR}" + find ${DIR} -type f -exec file {} \; | grep 'not stripped' | cut -d ":" -f 1 | while read FILE; do + echo "Strip file (strip): ${FILE}" + ${STRIPCMD_REGULAR} ${FILE} + done +done + +# CMD: strip --strip-debug +for DIR in ${STRIPDIR_DEBUG}; do + echo "Parse dir (strip-debug): ${DIR}" + find ${DIR} -type f -exec file {} \; | grep 'not stripped' | cut -d ":" -f 1 | while read FILE; do + echo "Strip file (strip-debug): ${FILE}" + ${STRIPCMD_DEBUG} ${FILE} + done +done + +# CMD: strip --strip-unneeded +for DIR in ${STRIPDIR_UNNEEDED}; do + echo "Parse dir (strip-unneeded: ${DIR}" + find ${DIR} -type f -exec file {} \; | grep 'not stripped' | cut -d ":" -f 1 | while read FILE; do + echo "Strip file (strip-unneeded): ${FILE}" + ${STRIPCMD_UNNEEDED} ${FILE} + done +done + +# Remove binutils package. +apt-get -y purge --autoremove binutils + diff --git a/data/live-build-config/package-lists/vyos-utils.list.chroot b/data/live-build-config/package-lists/vyos-utils.list.chroot index 0049077b..4f380ba1 100644 --- a/data/live-build-config/package-lists/vyos-utils.list.chroot +++ b/data/live-build-config/package-lists/vyos-utils.list.chroot @@ -2,3 +2,4 @@ systemd-sysv systemd-bootchart ncurses-term kitty-terminfo +binutils |