]>
git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - src/stripper
4 excludes
="/dev /proc /sys /run"
9 excludes
="${excludes} ${1#*=}"
20 local strip
="${STRIP-strip}"
23 for exclude
in ${excludes}; do
25 if [ "${file:0:${l}}" = "${exclude}" ]; then
30 # Fetch any capabilities
31 local capabilities
="$(getfattr --no-dereference --name="security.capability
" \
32 --absolute-names --dump "${file}")"
34 local cmd
=( "${strip}" )
36 case "$(file -bi ${file})" in
37 application
/x-archive
*)
38 cmd
+=( "--strip-debug" "--remove-section=.comment" "--remove-section=.note" )
41 cmd
+=( "--strip-all" )
45 echo "Stripping ${file}..."
48 # Restore capabilities
49 if [ -n "${capabilities}" ]; then
50 setfattr
--no-dereference --restore=<(echo "${capabilities}")
54 for dir
in ${dirs}; do
55 # Strip shared objects.
56 find ${dir} -type f \
( -perm -0100 -or -perm -0010 -or -perm -0001 \
) \
57 |
file -N -f - |
sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped.*/\1/p' |
59 _strip
${file} ||
exit $?
62 # Strip static archives.
63 find ${dir} -name \
*.a
-a -exec file {} \
; \
64 |
grep 'current ar archive' |
sed -n -e 's/^\(.*\):[ ]*current ar archive/\1/p' |
66 _strip
${file} ||
exit $?