forked from venomlinux/scratchpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkgdepends
executable file
·72 lines (69 loc) · 2 KB
/
pkgdepends
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
64
65
66
67
68
69
70
71
72
#!/bin/sh
#
# scratchpkg
#
# Copyright (c) 2018 by Emmett1 ([email protected])
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#
# script to check shared libraries dependencies
#
get_libpath() {
ldd $1 2>/dev/null | grep $2 | awk '{print $3}'
}
scratch files $1 | while read -r line; do
case $line in
usr/share/gir-1.0/*.gir) extra_dep="$extra_dep gobject-introspection";;
usr/share/vala/vapi/*.vapi) extra_dep="$extra_dep vala";;
esac
case $line in
*/) continue;;
esac
case "$(file -bi /$line)" in
*application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
for NEEDED in $(objdump -x /$line | grep NEEDED | awk '{print $2}'); do
case $NEEDED in
libc.so|libc.so.6) continue;;
esac
[ "$NEEDED" ] || continue
[ -f /"$line" ] || continue
libs=$(get_libpath /$line $NEEDED)
[ "$libs" ] || continue
if ! echo $all_libs | grep -qw $libs; then
pkg=$(scratch provide $libs$ | awk '{print $1}' | head -n1)
case $pkg in
$1|gcc|glibc|musl) continue;;
esac
[ "$pkg" ] || continue
if ! echo $all_pkgs | grep -qw $pkg; then
echo $pkg
all_pkgs="$all_pkgs $pkg"
unset pkg
fi
all_libs="$all_libs $libs"
unset libs
fi
done ;;
esac
[ "$extra_dep" ] && {
for e in $extra_dep; do
if ! echo $all_pkgs | grep -qw $e; then
echo $e
all_pkgs="$all_pkgs $e"
fi
done
}
done
exit 0