root/trunk/freewrt/scripts/rstrip.sh

Revision 3186, 1.5 kB (checked in by tg, 1 year ago)

add debugging output, trunk is currently unusable

Line 
1 # $FreeWRT$
2 #-
3 # This file is part of the FreeWRT project. FreeWRT is copyrighted
4 # material, please see the LICENCE file in the top-level directory
5 # or at http://www.freewrt.org/licence for details.
6
7 [[ -n $BASH_VERSION ]] && shopt -s extglob
8
9 SELF=${0##*/}
10
11 if [[ -z $prefix ]]; then
12         echo >&2 "$SELF: strip command not defined ('prefix' variable not set)"
13         exit 1
14 fi
15
16 if [[ $1 = +keep ]]; then
17         stripcomm=
18         shift
19 else
20         stripcomm=" -R .comment"
21 fi
22
23 TARGETS=$*
24
25 if [[ -z $TARGETS ]]; then
26         echo >&2 "$SELF: no directories / files specified"
27         echo >&2 "usage: $SELF [PATH...]"
28         exit 1
29 fi
30
31 find $TARGETS -type f -a -exec file {} \; | \
32     while IFS= read -r line; do
33         F=${line%%:*}
34         V=${F##*/fake-+([!/])/}
35         T="${prefix}strip"
36         [[ $F = */fwwif/* ]] || T=$T$stripcomm
37         case $line in
38         *ELF*executable*statically\ linked*)
39                 echo >&2 "$SELF: *WARNING* '$V' is not dynamically linked!"
40                 ;;
41         esac
42         case $line in
43         *ELF*executable*,\ not\ stripped*)
44                 S=executable ;;
45         */lib/modules/2.*.o:*ELF*relocatable*,\ not\ stripped* | \
46         */lib/modules/2.*.ko:*ELF*relocatable*,\ not\ stripped*)
47                 # kernel module parametres must not be stripped off
48                 T="$T --strip-unneeded $(echo $(${prefix}nm $F | \
49                     sed -n -e '/__param_/s/^.*__param_/-K /p' \
50                     -e '/__module_parm_/s/^.*__module_parm_/-K /p'))"
51                 S='kernel module' ;;
52         *ELF*relocatable*,\ not\ stripped*)
53                 S=relocatable ;;
54         *ELF*shared\ object*,\ not\ stripped*)
55                 S='shared object' ;;
56         *)
57                 continue ;;
58         esac
59         echo "$SELF: $V:$S"
60         echo "+ $T $F"
61         eval "$T $F"
62 done
Note: See TracBrowser for help on using the browser.