2

For example, if I run the following command dpkg -l ‘*compiz*’ the output is as follows:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
pi  compiz         1:0.9.12.2+1 all          OpenGL window and compositing man
ii  compiz-core    1:0.9.12.2+1 amd64        OpenGL window and compositing man
un  compiz-core-ab <none>       <none>       (no description available)
[more output deleted]

The output is a little cryptic. There are several detailed explanations on askubuntu, of which, example, is one. Likewise, man dpkg and man dpkg-query give similar explanations.

The first character in the first field, ‘p’, in our example output above, indicates the desired status of the package. Which is the status that the packaging system thinks the package should be in.

What is the underlying meaning of the desired status? I.e. Why does the packaging managing system have an idea of what status a package should be in? I could see that an intelligent system would recommend (or desire) a package to be purged if it was only ever used as a dependency to an already removed parent package. However, this is not the case in our example.

In our example, the package ‘compiz’ is installed, however dpkg believes it should be purged, or at least that it is desirable that the package is purged, why is this? Moreover, how does this particular field work in general? I.e. how does the system decide on a ‘desired status’ for a package and what are the underlying reasons for this functionality?

1 Answers1

4

I don't know if you ever used tools like aptitude or synaptic, even lower levels commands like: dpkg, dpkg-purge etc.

Using tools like aptitude, I can mark a lot of packages for removal, some to purge and some others for install, downgrade, etc, then I can run a single command to do all necessary stuff to get what I want (trigger pending actions).

The desired field is used to determine what should I do with a package.

Lets install axel:

sudo apt install -y axel

Now lets see its status:

$ dpkg -l axel
ii  axel               2.5-2

I can mark it for purge:

$ echo axel purge | sudo dpkg --set-selections

Now the desired action is:

$ dpkg -l axel
pi  axel               2.5-2  

I could mark the package for "purge" using other tools too:

sudo dpkg-purge axel

Now if I run:

sudo aptitude install 

or

sudo apt-get dselect-upgrade

it asks me that if I want to remove axel or not...

Where this data come from:

/var/lib/dpkg/status
Ravexina
  • 55,668
  • 25
  • 164
  • 183
  • I'm sure there is a good reason(s) why you might want to mark a package for installation rather than simply installing it, but I can't think of any use cases. Is it for dependency issues? – Display name Feb 12 '21 at 10:22
  • There are different use cases. Essentially, you use it to install multiple packages at the same time. Someone might use dpkg --get-selections to get the status of all packages and subsequently utilizes it to bring another systems in the same state of the first one. PS: your question can be posted as an standalone question. – Ravexina Feb 12 '21 at 10:58