libsolv: Update to a more recent git version.
[ipfire-2.x.git] / src / stripper
CommitLineData
fc44fa1f
MT
1#!/bin/bash
2
3function _strip() {
4 local file=${1}
5
6 local cmd="${STRIP-strip}"
7
8 case "$(file -bi ${file})" in
d9bb5239 9 application/x-sharedlib*|application/x-archive*)
fc44fa1f
MT
10 cmd="${cmd} --strip-debug --remove-section=.comment --remove-section=.note"
11 ;;
12 *)
13 cmd="${cmd} --strip-unneeded"
14 ;;
15 esac
16
17 echo "Stripping ${file}..."
18 ${cmd} ${file}
19}
20
21for dir in $@; do
d9bb5239 22 # Strip shared objects.
fc44fa1f
MT
23 find ${dir} -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \
24 | file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped/\1/p' |
25 while read file; do
26 _strip ${file}
27 done
d9bb5239
MT
28
29 # Strip static archives.
30 find ${dir} -name \*.a -a -exec file {} \; \
31 | grep 'current ar archive' | sed -n -e 's/^\(.*\):[ ]*current ar archive/\1/p' |
32 while read file; do
33 _strip ${file}
34 done
fc44fa1f 35done