Debian – How to List Installed Packages with Source URI, Distribution, and Section

aptdebiansoftware installation

I have a set of (source) URIs, distributions and sections enabled in my Debian Wheezy apt configuration. Now I want a list of all installed packages, and for each of those, the source URI, "distribution" and "section" that the currently installed version of each respective package has been installed from.

I'm basically looking for something like the output of dpkg -l but instead of the description it would show the source URI, distribution and section. Something like:

||/ Name       Version           Arch  InstalledFrom
+++-==========-=================-=====-===================
ii  package1   1:4.14-1.1+deb7u1 amd64 ftp://ftp.se.debian.org/debian wheezy main
ii  package2   1.7-1             all   ftp://ftp.se.debian.org/debian wheezy/updates main
ii  package3   1.0.25+3~deb7u1   all   ftp://ftp.se.debian.org/debian wheezy non-free
ii  package4   0.9.8~3           amd64 local
ii  package5   7.2.107           i386  local

How can I obtain such a list of packages?

Nicely formatted would be a bonus, but mostly anything that I can grep for interesting line substrings (or even just browse through) will likely do.

Best Answer

As well as apt-cache policy, described in Braiam's answer, you can use apt-show-versions and apt-forktracer.

apt-show-versions by default will list all installed packages with the suite they come from, their version and whether they can be upgraded; for example

afl:amd64/experimental *manually* upgradeable from 1.28b-1 to 1.36b-1
agedu:amd64/testing 9723-1 uptodate
devio:armhf 1.2-1 installed: No available version in archive

With the -a option it lists the installed version and all available versions in all the repositories you have configured:

afl:amd64 1.28b-1 install ok installed
No stable version
No testing version
No unstable version
afl:amd64 1.36b-1 experimental ftp.fr.debian.org
afl:amd64/experimental *manually* upgradeable from 1.28b-1 to 1.36b-1
agedu:amd64 9723-1 install ok installed
No stable version
agedu:amd64 9723-1 testing  ftp.fr.debian.org
agedu:amd64 9723-1 unstable ftp.fr.debian.org
No experimental version
agedu:amd64/testing 9723-1 uptodate

apt-forktracer lists the packages which don't come from the standard repositories or whose installed version doesn't match those available in the standard repositories:

afl (1.28b-1) [Debian: 1.36b-1]
bb (1.3rc1-8.2) [Debian: 1.3rc1-8.1+b1 1.3rc1-8.1+b1]
biew (5.7.3.1-0.1) [SK2: 5.7.3.1-0.1]
Related Question