]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/stripper
14 if [ -n "${1#*=}" ]; then
15 excludes
+=( "!" "-path" "${1#*=}" "!" "-path" "${1#*=}/*" )
33 local type="$(readelf -h "${file}" 2>/dev/null)"
36 # Libraries and Relocatable binaries
37 *Type
:*"DYN (Shared object file)"*)
38 args
+=( "--strip-all" )
41 *Type
:*"DYN (Position-Independent Executable file)"*)
42 args
+=( "--strip-all" )
46 *Type
:*"EXEC (Executable file)"*)
47 args
+=( "--strip-all" )
51 *Type
:*"REL (Relocatable file)"*)
52 args
+=( "--strip-debug" "--remove-section=.comment" "--remove-section=.note" )
55 # Skip any unrecognised files
61 # Fetch any capabilities
62 local capabilities
="$(getfattr --no-dereference --name="security.capability
" \
63 --absolute-names --dump "${file}" 2>/dev/null)"
65 echo "Stripping ${file}..."
66 if ! "${strip}" "${args[@]}" "${file}"; then
67 return ${break_on_error}
70 # Restore capabilities
71 if [ -n "${capabilities}" ]; then
72 setfattr
--no-dereference --restore=<(echo "${capabilities}")
76 for path
in ${paths[@]}; do
77 for file in $
(find -H "${path}" -xdev "${excludes[@]}" -type f \
( -perm -0100 -or -perm -0010 -or -perm -0001 \
) 2>/dev
/null
); do
78 _strip
"${file}" ||
exit $?