5

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.

dbourcet
  • 151
  • 3
  • related: https://superuser.com/questions/106794/how-to-tell-from-what-ubuntu-or-debian-repository-a-package-comes – mcalex Jan 24 '18 at 11:32
  • Most of this post talks about packages not yet installed, and I want to know for package already installed. I tried nevertheless to get infos with a command found (apt-cache showpkg) in the topic and edit my post to provide the output. It just adds confusion (see remark after the output). – dbourcet Jan 24 '18 at 12:33
  • I don't know that the data next to the version number matters. According to gotgenes answer on that link, the `File:` line contains the repo. If you scroll horizontally to the end of gotgenes' output, you'll see there's two versions of the reponame, then the '...dpkg/status' bit like on your output. I suggest [`man apt-cache`](https://linux.die.net/man/8/apt-cache) – mcalex Jan 24 '18 at 12:45
  • Of course, both the [Ask Ubuntu](https://askubuntu.com/questions/8560/how-do-i-find-out-which-repository-a-package-comes-from) people and the [Unix&Linux](https://unix.stackexchange.com/questions/177620/find-source-of-all-installed-packages-on-debian-based-systems) crowd have already dealt with this. – mcalex Jan 24 '18 at 12:53
  • I already read those topics before posting, they don't answer the two first questions: when you finally conclude that the package was installed from /var/lib/dpkg/status, how can it be interpreted ? What does that means ? The package was installed from a particular repo, then the repo was removed from the sources.list? Some other explanation ? – dbourcet Jan 24 '18 at 13:30
  • 1
    But i still don't think any of that info matters. The line that starts 'File:' has the repo. Ignore the line with the version number. I'm pretty sure `/var/lib/dpkg/status` is just a local dir. – mcalex Jan 24 '18 at 14:04
  • Ok, I will do with that. – dbourcet Jan 24 '18 at 14:08

0 Answers0