-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeps.sh
executable file
·50 lines (42 loc) · 1.21 KB
/
deps.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
DIR="${1:-${HOME}/repos/streamlink-twitch-gui/build/cache/${2:-0.77.0}-${3:-normal}/linux${4:-64}/}"
DEPS=(base gtk3 nss)
# ----
set -eo pipefail
export LC_ALL=C
# get all packages in the dependencies tree and resolve the "provides" data via pacman -Qq
resolved=$(
{ for pkg in "${DEPS[@]}"; do pactree -lu "${pkg}"; done } \
| pacman -Qq - \
| sort -u
)
echo "$(gawk -v ORS=' ' '{print}' <<< "${resolved}")" $'\n'
declare -A pkgs
for pkg in ${resolved}; do
pkgs["${pkg}"]="${pkg}"
done
status=0
# get all libs loaded by NW.js and find their respective packages
while read -r line; do
[[ -z "${line}" ]] && exit 1
read -r lib pkg <<< "${line}"
if [[ "${pkgs["${pkg}"]}" ]]; then
echo "✔ ${lib} (${pkg})"
else
echo "✖ ${lib} (${pkg})"
status=1
fi
done <<< $(
find "${DIR}" -type f -exec file -F '' '{}' ';' \
| gawk '/ELF/ && /dynamically linked/ {print $1}' \
| xargs ldd \
| gawk '/=> \/usr\/lib\// {print $3}' \
| sort -u \
| xargs pacman -Qo \
| gawk '
!/is owned by/{print $0 > "/dev/stderr"; exit 1}
match($0,/^(.+) is owned by (\w+) .+$/,m){print m[1] " " m[2]}
' \
| sort -u
)
exit ${status}