Skip to content

Instantly share code, notes, and snippets.

@aboettger
Created September 8, 2015 10:46
Show Gist options
  • Save aboettger/f5cee42308c48cad5aef to your computer and use it in GitHub Desktop.
Save aboettger/f5cee42308c48cad5aef to your computer and use it in GitHub Desktop.
get origin of an installed packages
LC_ALL=C dpkg-query --showformat='${Package}:${Status}\n' -W '*' \
| fgrep ':install ok installed' \
| cut -d: -f1 \
| (while read pkg; do
inst_version=$(apt-cache policy $pkg \
| fgrep Installed: \
| awk '{ print $2 }');
origin=$(apt-cache policy "$pkg" \
| fgrep " *** ${inst_version}" -C1 \
| tail -n 1 \
| cut -c12-);
echo $pkg $origin;
done)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment