summaryrefslogtreecommitdiff
path: root/packages-by-component
diff options
context:
space:
mode:
authorAnton Bobov <anton@bobov.name>2022-01-30 21:03:14 +0500
committerAnton Bobov <anton@bobov.name>2022-01-30 21:03:14 +0500
commitb25a5b794be7093dbcd556fcab2ebc50bb33e8b2 (patch)
tree282659aa4c647c87e004273efd4d02599afbcec2 /packages-by-component
parentc83690911af9326784d81e49e2b55de9688c1e9b (diff)
Updates.
Diffstat (limited to 'packages-by-component')
-rwxr-xr-xpackages-by-component28
1 files changed, 28 insertions, 0 deletions
diff --git a/packages-by-component b/packages-by-component
new file mode 100755
index 0000000..b4ab600
--- /dev/null
+++ b/packages-by-component
@@ -0,0 +1,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")