What does "selecting previously deselected package" mean?

Whenever I install software from the command-line using apt-get or aptitude, I see messages like this:

Selecting previously deselected package foobar-cil-dev.

I understand "downloading" and "setting up", but what does "selecting" mean? And what does it mean that the package was "previously deselected"?


Solution 1:

Ubuntu comes with a default set of packages installed and the package manager track those packages. If you remove a package that is installed by default, it becomes marked as "deselected". This means it was installed previously, but has been removed. In fact any package that you install and then remove becomes marked as "deselected".

This is useful for example to replicate the same packages you have on another machine or after a clean install. You can generate a list of "selected" and "deselected" packages on your system using the package manager and then load this list on another machine, which will make the package manager on it to install all "selected" and uninstall the ones marked as "deselected".

To replicate your packages selection on another machine (or restore it if re-installing), you can run this:

dpkg --get-selections > ~/my-packages

Then move the file "my-packages" to the other machine, and there run:

sudo dpkg --set-selections < my-packages && sudo apt-get dselect-upgrade

When you run the command above, all packages that were marked as "selected" will be installed in a batch and all packages marked as "deselected" will be removed, if present. This is a very handy feature.

Solution 2:

It's a grammatical error. It should say "unselected". There is a subtle distinction in English here which the programmer may have been unaware of: "deselected" means it was selected at some previous time, but isn't now. "Unselected" simply means it wasn't ever selected before (or at least, not relevantly). Using "deselected" here is confusing, and should be corrected.