#!/bin/bash #################### # Copyright (C) 2008 by Raphael Geissert # # # This file is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this file. If not, see . #################### set -e case "$1" in --help) echo "$(basename $0) [--version] [--help] [-s/var/lib/dpkg/status]"\ " [-aptf/path/to/aptavail/equiv/file]"\ " [-aptx'apt-cache dumpavail']"\ " [-ipackagename]" echo "List packages which are installed on the system" \ " but are not known by apt." echo "Options: " printf "\t-s Path to file to use when grepping for installed packages\n" printf "\t-aptf Path to file to use when grepping for the apt-able packages\n" printf "\t-aptx Same as above but instead of being a file the specified command is executed\n" printf "\t-i Exclude a package that would otherwise be listed\n" echo "When not overriden by an option the default files/data is up to grep-dctrl's defaults" echo "This script is said to report packages that were removed from the archive" echo "(except those listed in $HOME/.listNotAptable.ignore)" printf "\nCopyright 2008 by Raphael Geissert \n" exit ;; --version) echo "$(basename "$0") v0.1.1, formerly known as listNotAptable-ng" exit ;; esac status= aptavail= aptavailType= grep-status() { if [ -z "$status" ]; then $(which grep-status) "$@" else grep-dctrl "$@" "$status" fi } grep-aptavail() { if [ -z "$aptavail" ]; then $(which grep-aptavail) "$@" elif [ "$aptavailType" = "C" ]; then local file="$(mktemp)" eval "$aptavail" > "$file" grep-dctrl "$@" "$file" elif [ "$aptavailType" = "F" ]; then grep-dctrl "$@" "$aptavail" fi } ignore= c=$# while [ $c -gt 0 ]; do case "$1" in -s*) status="$(cut -b3- <<< "$1")" ;; -aptf*) aptavail="$(cut -b6- <<< "$1")" aptavailType=F ;; -aptx*) aptavail="$(cut -b6- <<< "$1")" aptavailType=C ;; -i*) ignore+="$(cut -b3- <<< "$1")|" ;; esac shift c=$(($c - 1)) done statusList="$(mktemp)" aptavailList="$(mktemp)" [ ! -f "$HOME/.listNotAptable.ignore" ] || \ ignore+="$(sed 's/\./\\\./g' < $HOME/.listNotAptable.ignore | xargs printf '%s|')" [ ! -z "$ignore" ] || ignore=$$$$$$$$ ignore="$(sed 's/|$//' <<< "$ignore")" grep-status -n -FStatus 'install ok installed' -sPackage | sort -u > "$statusList" grep-aptavail -n -rP '.*' -sPackage | sort -u > "$aptavailList" diff "$aptavailList" "$statusList" | egrep '^>' | sed 's/^> //g' | egrep -v "^($ignore)$" rm "$statusList" "$aptavailList"