summaryrefslogtreecommitdiff
path: root/packages-by-component
blob: b4ab6005d2c9f3226930fcfdbb8eb0b56b03af1c (plain) (blame)
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
#!/bin/bash

set -e

print_help() {
  cat <<EOF
Usage: $(basename "$0") COMPONENT

COMPONENT - name of component (ex.: contrib, non-free)
EOF
  exit 1
}

list_installed() {
    dpkg -l | grep '^ii' | cut -d ' ' -f 3 | cut -d ':' -f 1 | sort -u
}

list_packages() {
  component="$1"
  grep '^Package:' /var/lib/apt/lists/*_"${component}"_*Packages | cut -d ' ' -f 2 | sort -u

}

if [ $# -lt 1 ] ; then
  print_help
fi

comm -12 <(list_installed) <(list_packages "$1")