2013-03-02 23:00:38 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-10-12 09:16:48 +02:00
|
|
|
usage () {
|
|
|
|
cat <<EOF>&2
|
2016-10-14 06:17:18 +02:00
|
|
|
Usage: ${0##*/} [-m] [-e] [-q] FILES...
|
2013-03-02 23:00:38 +01:00
|
|
|
|
2016-10-14 06:17:18 +02:00
|
|
|
Display packages listed in FILES but not installed.
|
2013-03-02 23:00:38 +01:00
|
|
|
|
|
|
|
-e: Compare FILE to explicitly installed packages.
|
|
|
|
-h: Display this help.
|
|
|
|
-m: Compare FILE to foreign installed packages.
|
|
|
|
-q: Display installed packages not included in FILE.
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
OPTION_EXPLICIT=""
|
|
|
|
OPTION_FOREIGN=""
|
|
|
|
OPTION_LOCAL="-1"
|
|
|
|
|
|
|
|
while getopts ":hmqe" opt; do
|
2014-11-12 16:15:39 +01:00
|
|
|
case $opt in
|
|
|
|
e)
|
|
|
|
OPTION_EXPLICIT="e" ;;
|
|
|
|
h)
|
2016-10-12 09:16:48 +02:00
|
|
|
usage
|
2014-11-12 16:15:39 +01:00
|
|
|
exit 1 ;;
|
|
|
|
m)
|
|
|
|
OPTION_FOREIGN="m" ;;
|
|
|
|
q)
|
|
|
|
OPTION_LOCAL="-2" ;;
|
|
|
|
\?)
|
2016-10-12 09:16:48 +02:00
|
|
|
usage
|
2014-11-12 16:15:39 +01:00
|
|
|
exit 1 ;;
|
|
|
|
esac
|
2013-03-02 23:00:38 +01:00
|
|
|
done
|
|
|
|
|
2016-06-23 23:18:36 +02:00
|
|
|
shift $((OPTIND - 1))
|
2013-03-02 23:00:38 +01:00
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
2014-11-12 16:15:39 +01:00
|
|
|
echo "Missing argument."
|
2016-10-12 09:16:48 +02:00
|
|
|
usage
|
2014-11-12 16:15:39 +01:00
|
|
|
exit 1
|
2013-03-02 23:00:38 +01:00
|
|
|
fi
|
|
|
|
|
2014-01-03 19:13:07 +01:00
|
|
|
if ! command -v pacman >/dev/null 2>&1; then
|
2016-10-12 09:16:48 +02:00
|
|
|
echo >&2 "'pacman' not found"
|
2014-11-12 16:15:39 +01:00
|
|
|
exit 1
|
2014-01-03 19:13:07 +01:00
|
|
|
fi
|
2013-10-23 11:24:32 +02:00
|
|
|
|
2013-03-02 23:00:38 +01:00
|
|
|
PKGLIST="$(mktemp)"
|
|
|
|
FILE="$(mktemp)"
|
2016-10-14 06:17:18 +02:00
|
|
|
pacman -Qq${OPTION_FOREIGN}${OPTION_EXPLICIT} | LC_ALL=C sort > "$PKGLIST"
|
|
|
|
LC_ALL=C sort "$@" > "$FILE"
|
|
|
|
LC_ALL=C comm -3 ${OPTION_LOCAL} "$PKGLIST" "$FILE"
|
2013-03-02 23:00:38 +01:00
|
|
|
rm -f "$PKGLIST" "$FILE"
|