OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
1 | #!/usr/bin/env bash |
1 | #!/usr/bin/env bash |
|
2 | # |
2 | # |
|
3 | # Copyright (C) 2006 OpenWrt.org |
3 | # Copyright (C) 2006 OpenWrt.org |
|
4 | # |
4 | # |
|
5 | # This is free software, licensed under the GNU General Public License v2. |
5 | # This is free software, licensed under the GNU General Public License v2. |
|
6 | # See /LICENSE for more information. |
6 | # See /LICENSE for more information. |
|
7 | # |
7 | # |
|
8 | SELF=${0##*/} |
8 | SELF=${0##*/} |
|
9 | |
9 | |
|
10 | [ -z "$STRIP" ] && { |
10 | [ -z "$STRIP" ] && { |
|
11 | echo "$SELF: strip command not defined (STRIP variable not set)" |
11 | echo "$SELF: strip command not defined (STRIP variable not set)" |
|
12 | exit 1 |
12 | exit 1 |
|
13 | } |
13 | } |
|
14 | |
14 | |
|
15 | TARGETS=$* |
15 | TARGETS=$* |
|
16 | |
16 | |
|
17 | [ -z "$TARGETS" ] && { |
17 | [ -z "$TARGETS" ] && { |
|
18 | echo "$SELF: no directories / files specified" |
18 | echo "$SELF: no directories / files specified" |
|
19 | echo "usage: $SELF [PATH...]" |
19 | echo "usage: $SELF [PATH...]" |
|
20 | exit 1 |
20 | exit 1 |
|
21 | } |
21 | } |
|
22 | |
22 | |
|
23 | find $TARGETS -type f -a -exec file {} \; | \ |
23 | find $TARGETS -type f -a -exec file {} \; | \ |
|
24 | sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.*/\1:\2/p' | \ |
24 | sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.*/\1:\2/p' | \ |
|
25 | ( |
25 | ( |
|
26 | IFS=":" |
26 | IFS=":" |
|
27 | while read F S; do |
27 | while read F S; do |
|
28 | echo "$SELF: $F: $S" |
28 | echo "$SELF: $F: $S" |
|
29 | [ "${S}" = "relocatable" ] && { |
29 | [ "${S}" = "relocatable" ] && { |
|
30 | eval "$STRIP_KMOD $F" |
30 | eval "$STRIP_KMOD $F" |
|
31 | } || { |
31 | } || { |
|
32 | b=$(stat -c '%a' $F) |
32 | b=$(stat -c '%a' $F) |
|
33 | [ -z "$PATCHELF" ] || [ -z "$TOPDIR" ] || { |
33 | [ -z "$PATCHELF" ] || [ -z "$TOPDIR" ] || { |
|
34 | old_rpath="$($PATCHELF --print-rpath $F)"; new_rpath="" |
34 | old_rpath="$($PATCHELF --print-rpath $F)"; new_rpath="" |
|
35 | for path in $old_rpath; do |
35 | for path in $old_rpath; do |
|
36 | case "$path" in |
36 | case "$path" in |
|
37 | /lib/[^/]*|/usr/lib/[^/]*|\$ORIGIN/*|\$ORIGIN) new_rpath="${new_rpath:+$new_rpath:}$path" ;; |
37 | /lib/[^/]*|/usr/lib/[^/]*|\$ORIGIN/*) new_rpath="${new_rpath:+$new_rpath:}$path" ;; |
|
38 | *) echo "$SELF: $F: removing rpath $path" ;; |
38 | *) echo "$SELF: $F: removing rpath $path" ;; |
|
39 | esac |
39 | esac |
|
40 | done |
40 | done |
|
41 | [ "$new_rpath" = "$old_rpath" ] || $PATCHELF --set-rpath "$new_rpath" $F |
41 | [ "$new_rpath" = "$old_rpath" ] || $PATCHELF --set-rpath "$new_rpath" $F |
|
42 | } |
42 | } |
|
43 | eval "$STRIP $F" |
43 | eval "$STRIP $F" |
|
44 | a=$(stat -c '%a' $F) |
44 | a=$(stat -c '%a' $F) |
|
45 | [ "$a" = "$b" ] || chmod $b $F |
45 | [ "$a" = "$b" ] || chmod $b $F |
|
46 | } |
46 | } |
|
47 | done |
47 | done |
|
48 | true |
48 | true |
|
49 | ) |
49 | ) |
|
50 | |
50 | |