]>
git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - src/stripper
9 excludes
+=( "!" "-path" "${1#*=}/*" )
23 local type="$(readelf -h "${file}" 2>/dev/null)"
26 # Libraries and Relocatable binaries
27 *Type
:*"DYN (Shared object file)"*)
28 args
+=( "--strip-all" )
32 *Type
:*"EXEC (Executable file)"*)
33 args
+=( "--strip-all" )
37 *Type
:*"REL (Relocatable file)"*)
38 args
+=( "--strip-debug" "--remove-section=.comment" "--remove-section=.note" )
41 # Skip any unrecognised files
47 # Fetch any capabilities
48 local capabilities
="$(getfattr --no-dereference --name="security.capability
" \
49 --absolute-names --dump "${file}" 2>/dev/null)"
51 echo "Stripping ${file}..."
52 if ! strip
"${args[@]}" "${file}"; then
57 # Restore capabilities
58 if [ -n "${capabilities}" ]; then
59 setfattr
--no-dereference --restore=<(echo "${capabilities}")
63 for path
in ${paths[@]}; do
64 for file in $
(find -H "${path}" -xdev "${excludes[@]}" -type f \
( -perm -0100 -or -perm -0010 -or -perm -0001 \
) 2>/dev
/null
); do
65 _strip
"${file}" ||
exit $?