Last active
January 4, 2016 15:19
-
-
Save zouppen/8640307 to your computer and use it in GitHub Desktop.
Shows manually installed packages on Debian-like operating system, like Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eu | |
# Shows manually installed packages on Debian / Ubuntu system | |
# | |
# Author: Joel Lehtonen <[email protected]> | |
# Public domain. If you found this useful, please donate to | |
# 1FvEggFtNSYS9pcBoYB9wDxH9fa1mrNPW5 | |
MANIFEST= | |
usage() { | |
cat <<EOF | |
Usage: `basename $0` [-c MANIFEST_URL] | |
When run without any option it shows manually installed packages on your system. | |
This includes packages installed by operating system installer, too. | |
To exclude packages provided by the installer and list only the packages you | |
have installed yourself, use -c parameter with URL of manifest file to compare | |
with. For example: | |
-c http://releases.ubuntu.com/releases/saucy/ubuntu-13.10-desktop-amd64.manifest | |
Replace distribution name, architehture, and version in the URL, if needed. | |
EOF | |
exit 2 | |
} | |
while getopts :c: OPT; do | |
case $OPT in | |
c|+c) | |
TMPFILE=`mktemp` | |
MANIFEST=`mktemp` | |
# Avoiding pipelines because we want to catch curl errors | |
curl -f -s -S -o "$TMPFILE" -- "$OPTARG" | |
cut -f 1 <"$TMPFILE" | sort >"$MANIFEST" | |
rm -- "$TMPFILE" | |
;; | |
*) usage ;; | |
esac | |
done | |
test $OPTIND -le $# && usage | |
if test -z "$MANIFEST"; then | |
# Normal operation, no comparison | |
apt-mark showmanual | sort | |
else | |
apt-mark showmanual | sort | comm -1 -3 "$MANIFEST" - | |
rm -- "$MANIFEST" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment