-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheckpackages.sh
executable file
·34 lines (27 loc) · 963 Bytes
/
checkpackages.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
#!/bin/bash
file="arch-packages"
# Check that all packages specified in `arch-packages` are installed
incomplete_group_installs() {
# list groups that are not entirely installed
comm -23 <(pacman -Sgg|sort) <(pacman -Qg|sort)|cut -d' ' -f1|uniq
}
full_group_installs() {
# list groups that are entirely installed
comm -23 <(pacman -Sg|sort) <(incomplete_group_installs|sort)
}
# query all packages specified in `arch-packages`
# - then substract all packages installed
# - then substract all groups installed
list_missing_packages() {
grep -vE '^(#|$)' < "$file" | sort \
| pacman -T \
| sort \
| comm -23 - <(full_group_installs|sort)
}
readarray -t not_installed < <(list_missing_packages)
if [ "${#not_installed[@]}" -eq 0 ] ; then
echo "Everything from $file is installed"
else
echo "The following ${#not_installed[@]} packages in $file are missing:"
printf " %s\n" "${not_installed[@]}"
fi