summaryrefslogtreecommitdiff
path: root/packages.sh
blob: d6851498babfe0ab9c8403377e1b6291d8915e8f (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
#!/bin/bash
all=($(< packages.txt sed 's/#.*//' | xargs printf -- '%s\n' | sort -u))
grps=($(printf -- '%s\n' "${all[@]}" | sed -n 's/^g://p'))
pkgs=($(printf -- '%s\n' "${all[@]}" | sed -n 's/^p://p'))
excl=($(printf -- '%s\n' "${all[@]}" | sed -n 's/^x://p'))
bads=($(printf -- '%s\n' "${all[@]}" | grep -v '^[gpx]:'))
if [[ ${#bads[@]} -gt 0 ]]; then
	echo ' => Invalid entries in packages.txt'
	printf '  -> %s\n' "${bads[@]}"
	exit 1
fi

packages_txt() {
	{
		if [[ ${#grps[@]} -gt 0 ]]; then
			pacman -Sgq -- "${grps[@]}"|grep -vFx -f <(printf '%s\n' "${excl[@]}")
		fi
		if [[ ${#pkgs[@]} -gt 0 ]]; then
			printf '%s\n' "${pkgs[@]}"
		fi
	} | sort -u
}

echo ' => In packages.txt, but not installed'
comm -13 \
    <(pacman -Qq|sort -u) \
    <(packages_txt) |
sed 's|^|  -> |'

echo ' => Installed explicitly and not depended on, but not in packages.txt'
comm -23 \
    <(pacman -Qetq |sort -u) \
    <(packages_txt) |
sed 's|^|  -> |'

echo ' => Installed explicitly and only optionally depended on, but not in packages.txt'
comm -23 \
    <(comm -23 \
           <(pacman -Qettq|sort -u) \
	   <(pacman -Qetq |sort -u)) \
    <(packages_txt) |
sed 's|^|  -> |'

echo ' => Installed as dependencies, but only optionally depended on'
comm -23 \
     <(pacman -Qdttq|sort -u) \
     <(pacman -Qdtq |sort -u) |
sed 's|^|  -> |'

echo ' => Installed as dependencies, but not depended on'
pacman -Qdtq|sort -u |sed 's|^|  -> |'