Welcome to the Linux Foundation Forum!

Where Are Application Details Saved

teachernightowlteachernightowl Posts: 3
edited June 25 in Cloud Engineer Boot Camp

Where is package details stored if the package is not listed in /var/lib/dpkg/available?

The Context

On this DPKG module page, it says to use dpkg -p wget to show the information about an installed package.

Here is the output on a newly installed Ubuntu 18.04...

[email protected]:~$ dpkg -l | grep wget
ii  wget                                       1.19.4-1ubuntu2.2                                amd64        retrieves files from the web
[email protected]:~$ dpkg -L wget
[email protected]:~$ dpkg -p wget
dpkg-query: package 'wget' is not available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
[email protected]:~$ apt-cache show wget
Package: wget
Architecture: amd64
Version: 1.19.4-1ubuntu2.2
Multi-Arch: foreign
Priority: standard
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Noël Köthe <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 932
...(I trimmed off the rest of the output details to save space)...

When I look in man dpkg, I find this...

-p, --print-avail package-name...
      Display details about package-name, as found in
      /var/lib/dpkg/available. Users of APT-based frontends
      should use apt-cache show package-name instead.

When I search /var/lib/dpkg/available, there is nothing listed for wget. If I run dpkg -p <package> against a package listed in /var/lib/dpkg/available is does return details.

So since the package is obviously installed, I ran apt-cache show wget to find the details and it returned details. So obviously, apt-cache show is pulling from somewhere else.

As a result, I decided to read the manual at man apt-cache. It has this...

show pkg...
   show performs a function similar to dpkg --print-avail; it displays the package records for
   the named packages.

While the action is obviously similar, it is not exactly the same. And I am back at to where I started.


  • luisviveropenaluisviveropena Posts: 544
    edited June 26

    Hi @teachernightowl ,

    I was able to reproduce the behaviour. For some reason, there are many packages on /var/lib/status that are installed, and that are not present in /var/lib/available (and they should). You can confirm that by doing the following:

    grep "Package: " available > /tmp/packages_available

    grep "Package: " status > /tmp/packages_status

    Then compare these files; you will find that there are a lot of packages in /tmp/packages_status that are not in /tmp/packages_available . Why the OS has failed in mantain an updated /var/lib/dpkg/available file? No idea.

    Can this be fixed? Yes, totally! I haven't had the need to do this before, this is the first time I see this issue.

    So, this can be reconciliated by merging the apt-cache database for available packages with dpkg. This is how it's done:

    apt-cache dumpavail | dpkg --merge-avail

    So, if you dump the output of apt-cache dumpavail to a file, you will see that "wget" is there (apt-cache dumpavail > apt_packages). Then the output of the first command is passed to dpkg--merge-avail through a pipe.

    Then next time you do "dpkg -p wget" it will work (I confirmed it on my Ubuntu LTS 18.04 image).

    Note: I found useful information here: https://wiki.debian.org/Teams/Dpkg/FAQ

    I hope this helps.

    Many regards,

Sign In or Register to comment.