-
Notifications
You must be signed in to change notification settings - Fork 0
/
autonomizer.sh
30 lines (30 loc) · 882 Bytes
/
autonomizer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
shopt -s globstar
for file in ./**/* ; do
if file $file | grep ELF > /dev/null; then
sl="${file//[^\/]}"
c="${#sl}"
c=$(expr $c - 1)
str="\$ORIGIN"
if [ "$c" -gt "0" ]; then
for ((i=1; i<=$c; i++)); do
str="${str}/.."
done
fi
str="${str}/lib"
#echo $str
echo $file
patchelf --remove-rpath $file
#ldd $file |awk '{if(substr($3,0,1)=="/") print $1,$3}' | cut -d\ -f2 | \
ldd $file | grep "=> /" | awk '{print $1, $3}' | cut -d\ -f2 | \
xargs -d '\n' -I{} cp --copy-contents {} ./lib
patchelf --set-rpath $str $file
fi
done
for file in ./lib/* ; do
if file $file | grep ELF > /dev/null; then
echo $file
patchelf --remove-rpath $file
patchelf --set-rpath "\$ORIGIN" $file
fi
done