]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blob - pkgs/build-essentials/buildsystem-tools/stripper
avahi: Update to 0.6.30.
[people/arne_f/ipfire-3.x.git] / pkgs / build-essentials / buildsystem-tools / stripper
1 #!/bin/bash
2
3 # Based on RedHat's brp-strip*.
4
5 BUILDROOT=${1}
6
7 for f in `find ${BUILDROOT} -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \
8 grep -v "^${BUILDROOT}/\?usr/lib/debug" | \
9 grep -v ' shared object,' | \
10 sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped/\1/p'`; do
11
12 # Strip ELF binaries
13 strip -g "$f" || :
14
15 note="-R .note"
16 if objdump -h $f | grep '^[ ]*[0-9]*[ ]*.note[ ]' -A 1 | \
17 grep ALLOC >/dev/null; then
18 note=
19 fi
20 strip -R .comment $note "$f" || :
21 done
22
23 # Strip ELF shared objects
24 # Please note we don't restrict our search to executable files because
25 # our libraries are not (should not be, at least) +x.
26 for f in `find ${BUILDROOT} -type f -a -exec file {} \; | \
27 grep -v "^${BUILDROOT}/\?usr/lib/debug" | \
28 grep ' shared object,' | \
29 sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped/\1/p'`; do
30 strip --strip-unneeded "$f"
31 done