blob: f0ae5f91e57157bda9addad402c255d20372a3f7 (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/sh
SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /usr/libexec"
TMPFILE=$(mktemp)
if [ -d /etc/revdep.d ] && [ "$(ls -1 /etc/revdep.d)" ]; then
for line in $(cat /etc/revdep.d/*); do
LD_LIBRARY_PATH="$line:$LD_LIBRARY_PATH"
done
export LD_LIBRARY_PATH
fi
trap 'rm -f $TMPFILE; printf "\033[0K"; exit 1' 1 2 3 15
while [ "$1" ]; do
case $1 in
-v) verbose=1;;
-h) help=1;;
esac
shift
done
find $SEARCH_DIRS -type f \( -perm /+u+x -o -name '*.so' -o -name '*.so.*' \) -print 2> /dev/null | sort -u > $TMPFILE
total=$(wc -l $TMPFILE | awk '{print $1}')
count=0
while read -r line; do
count=$(( count + 1 ))
libname=${line##*/}
if [ "$verbose" ]; then
printf " $(( 100*count/total ))%% $libname\033[0K\r"
fi
case "$(file -bi "$line")" in
*application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
if [ -e /lib/ld-musl-x86_64.so.1 ] || [ -e /usr/lib/ld-musl-x86_64.so.1 ]; then
# musl system
missinglib=$(ldd /$line 2>&1 | grep "Error loading shared library" | awk '{print $5}' | sed 's/://' | sort | uniq)
else
# glibc system
missinglib=$(ldd /$line 2>&1 | grep "not found" | awk '{print $1}' | sort | uniq)
fi
if [ "$missinglib" ]; then
for i in $missinglib; do
objdump -p /$line | grep NEEDED | awk '{print $2}' | grep -qx $i && {
ownby=$(spm -o $line | head -n1 | awk '{print $1}')
[ "$ownby" ] || continue
if [ "$verbose" ]; then
echo " $ownby: $line (requires $i)"
else
echo "$p" | tr ' ' '\n' | grep -xq $ownby || {
echo $ownby
p="$p $ownby"
}
fi
}
done
fi;;
esac
done < $TMPFILE
printf "\033[0K"
rm -f $TMPFILE
exit 0
|