-
Notifications
You must be signed in to change notification settings - Fork 6
/
pypi2pkgbuild-compare.sh
executable file
·37 lines (35 loc) · 1.34 KB
/
pypi2pkgbuild-compare.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
#!/bin/bash
# Compare dependencies between installed and automatic packages.
# First run e.g.
# pypi2pkgbuild.py $(pacman -Qm | grep python- | grep -v 00 | grep -v git | cut -d' ' -f1 | cut -d- -f2-)
# and run this script from the packages-containing directory.
for pkgname in *; do
echo "$(tput bold)$pkgname$(tput sgr0)"
found="$(
grep '\bdepends' "$pkgname/.SRCINFO" |
cut -d' ' -f3 | grep -v '^python$' | sort)"
info="$(pacman -Qi "$pkgname")"
depends="$(
grep -Po '(?<=Depends On).*' <<<"$info" |
cut -d: -f2 | tr ' ' '\n' | grep -v '^python$')"
optdepends="$(
grep -Pzo '(?<=Optional Deps)(.|\n)*?\n(?=\S)' <<<"$info" |
tr -d '\0' | sed 's/^[ :]*//' | grep -av '^None$')"
fulldepends="$(grep -o '^[[:alnum:]-]\+' <<<$"$depends\n$optdepends" | sort)"
c1="$(comm -23 <(echo "$found") <(echo "$fulldepends"))"
c2="$(comm -13 <(echo "$found") <(echo "$fulldepends"))"
c3="$(comm -12 <(echo "$found") <(echo "$fulldepends"))"
if [[ "$c3" ]]; then
echo "$(tput smul)Common$(tput sgr0)"
echo "$c3"
fi
if [[ "$c2" ]]; then
echo "$(tput smul)Only in installed package$(tput sgr0)"
echo "$c2"
fi
if [[ "$c1" ]]; then
echo "$(tput smul)Only in automatic package$(tput sgr0)"
echo "$c1"
fi
printf '\n------\n'
done