e2fsprogs: use the private version of blkid statically, it is significantly smaller...
[openwrt/svn-archive/archive.git] / scripts / rstrip.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8 SELF=${0##*/}
9
10 [ -z "$STRIP" ] && {
11 echo "$SELF: strip command not defined (STRIP variable not set)"
12 exit 1
13 }
14
15 TARGETS=$*
16
17 [ -z "$TARGETS" ] && {
18 echo "$SELF: no directories / files specified"
19 echo "usage: $SELF [PATH...]"
20 exit 1
21 }
22
23 find $TARGETS -type f -a -exec file {} \; | \
24 sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.* stripped/\1:\2/p' | \
25 (
26 IFS=":"
27 while read F S; do
28 echo "$SELF: $F:$S"
29 [ "${S}" = "relocatable" ] && {
30 eval "$STRIP_KMOD $F"
31 } || {
32 b=$(stat -c '%a' $F)
33 eval "$STRIP $F"
34 a=$(stat -c '%a' $F)
35 [ "$a" = "$b" ] || chmod $b $F
36 }
37 done
38 true
39 )