wireless-tools: re-enable support for enabling/disabling powersave
[openwrt.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
9 find_modparams() {
10 FILE="$1"
11 $NM "$FILE" | awk '
12 BEGIN {
13 FS=" "
14 }
15 ($3 ~ /^__module_parm_/) && ($3 !~ /^__module_parm_desc/) {
16 gsub(/__module_parm_/, "", $3)
17 printf "-K " $3 " "
18 }
19 ($2 ~ /r/) && ($3 ~ /__param_/) {
20 gsub(/__param_/, "", $3)
21 printf "-K " $3 " "
22 }
23 '
24 }
25
26
27 SELF=${0##*/}
28
29 [ -z "$STRIP" ] && {
30 echo "$SELF: strip command not defined (STRIP variable not set)"
31 exit 1
32 }
33
34 TARGETS=$*
35
36 [ -z "$TARGETS" ] && {
37 echo "$SELF: no directories / files specified"
38 echo "usage: $SELF [PATH...]"
39 exit 1
40 }
41
42 find $TARGETS -type f -a -exec file {} \; | \
43 sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.* stripped/\1:\2/p' | \
44 (
45 IFS=":"
46 while read F S; do
47 echo "$SELF: $F:$S"
48 [ "${S}" = "relocatable" ] && {
49 eval "$STRIP_KMOD -w -K '__param*' -K '__mod*' $(find_modparams "$F")$F"
50 } || {
51 b=$(stat -c '%a' $F)
52 eval "$STRIP $F"
53 a=$(stat -c '%a' $F)
54 [ "$a" = "$b" ] || chmod $b $F
55 }
56 done
57 true
58 )
This page took 0.048638 seconds and 5 git commands to generate.