On a legacy Debian machine with plenty of differents sources repositories in /etc/apt/sources.list.d/, I want to find, for every installed package, from which repo it has been installed. I want to script the output of apt-cache policy, but before I have to understand more clearly this output.
I found things I don't know how to interpret:
# apt-cache policy apache2
apache2:
Installed: 2.2.22-13+deb7u8
Candidate: 2.2.22-13+deb7u12
Version table:
2.2.22-13+deb7u12 0
500 http://security.debian.org/ wheezy/updates/main amd64 Packages
*** 2.2.22-13+deb7u8 0
100 /var/lib/dpkg/status
2.2.22-13+deb7u6 0
500 http://cloudfront.debian.net/debian/ wheezy/main amd64 Packages
Does it mean that the current installed version (the one with the ***) has been installed from /var/lib/dpkg/status? Does it even mean something to be installed from /var/lib/dpkg/status?
On examples I can find in similar topics, if the section marked with *** has a line with /var/lib/dpkg/status priority 100, it also has another line with an http repo and priority 500, and I suppose that means that the package was installed from this priority 500 repo.
But in my case, from which repo has the apache2 package been installed? Since we can see there are a new version proposed (repo security.debian.org), does it means that the package was installed from this repo, but since there is an available update, the line was removed from the *** section and that's why there is only one line with /var/lib/dpkg/status?
Or maybe this single line with the /var/lib/dpkg/status repo means that it was installed from a repo which has been removed from the sources.list.d files?
Edit (for the first comment of this post):
# apt-cache showpkg apache2
Package: apache2
Versions:
2.2.22-13+deb7u12 (/var/lib/apt/lists/security.debian.org_dists_wheezy_updates_main_binary-amd64_Packages)
Description Language:
File: /var/lib/apt/lists/cloudfront.debian.net_debian_dists_wheezy_main_binary-amd64_Packages
MD5: d24f049cd70ccfc178dd8974e4b1ed01
Description Language: en
File: /var/lib/apt/lists/cloudfront.debian.net_debian_dists_wheezy_main_i18n_Translation-en
MD5: d24f049cd70ccfc178dd8974e4b1ed01
2.2.22-13+deb7u8 (/var/lib/dpkg/status)
Description Language:
File: /var/lib/apt/lists/cloudfront.debian.net_debian_dists_wheezy_main_binary-amd64_Packages
MD5: d24f049cd70ccfc178dd8974e4b1ed01
Description Language: en
File: /var/lib/apt/lists/cloudfront.debian.net_debian_dists_wheezy_main_i18n_Translation-en
MD5: d24f049cd70ccfc178dd8974e4b1ed01
2.2.22-13+deb7u6 (/var/lib/apt/lists/cloudfront.debian.net_debian_dists_wheezy_main_binary-amd64_Packages)
Description Language:
File: /var/lib/apt/lists/cloudfront.debian.net_debian_dists_wheezy_main_binary-amd64_Packages
MD5: d24f049cd70ccfc178dd8974e4b1ed01
Description Language: en
File: /var/lib/apt/lists/cloudfront.debian.net_debian_dists_wheezy_main_i18n_Translation-en
MD5: d24f049cd70ccfc178dd8974e4b1ed01
This output just confuses me: the repo name alongside the version doesn't match the repo name in the File section.