2651
|
1 |
#
|
|
2 |
# $Id$
|
|
3 |
#
|
2744
|
4 |
# patch-scripts.bash - relocate interpreter paths of executable scripts.
|
2651
|
5 |
#
|
|
6 |
|
|
7 |
## find binaries
|
|
8 |
|
|
9 |
function findbin()
|
|
10 |
{
|
|
11 |
local DEFAULT="$1"
|
3052
|
12 |
local BASE=$(basename "$DEFAULT")
|
2651
|
13 |
local BINARY=""
|
|
14 |
|
3052
|
15 |
BINARY=$(type -path "$BASE")
|
|
16 |
|
|
17 |
if [ -n "$BINARY" ]; then
|
|
18 |
echo "using $BINARY" >&2
|
|
19 |
echo "$BINARY"
|
|
20 |
return
|
|
21 |
elif [ -f "$DEFAULT" ]; then
|
2760
|
22 |
echo "using $DEFAULT" >&2
|
2651
|
23 |
echo "$DEFAULT"
|
|
24 |
return
|
3052
|
25 |
else
|
4508
|
26 |
echo "ERROR: $BASE not found!" >&2
|
3052
|
27 |
echo "$DEFAULT"
|
|
28 |
return
|
2651
|
29 |
fi
|
|
30 |
}
|
|
31 |
|
|
32 |
|
|
33 |
## main
|
|
34 |
|
|
35 |
BASH=$(findbin /bin/bash)
|
|
36 |
PERL=$(findbin /usr/bin/perl)
|
|
37 |
|
|
38 |
for FILE in $(find . -type f -print)
|
|
39 |
do
|
|
40 |
if [ -x "$FILE" ]; then
|
6082
|
41 |
sed -e "s:^#!.*/bash:#!$BASH:" -e "s:^#!.*/perl:#!$PERL:" \
|
6105
|
42 |
-e "s:^AUTO_BASH=.*bash:AUTO_BASH=$BASH:" \
|
|
43 |
-e "s:^AUTO_PERL=.*perl:AUTO_PERL=$PERL:" $FILE >$FILE~~
|
2651
|
44 |
if cmp -s $FILE $FILE~~; then
|
|
45 |
rm $FILE~~
|
|
46 |
else
|
|
47 |
rm -f $FILE
|
|
48 |
mv $FILE~~ $FILE
|
|
49 |
chmod +x $FILE
|
|
50 |
echo fixed $FILE
|
|
51 |
fi
|
|
52 |
fi
|
|
53 |
done
|