'Package not in database' when restoring with dpkg --set-selections
I just reinstalled Ubuntu MATE 15.10 from scratch. I had followed this answer to save a list of installed packages and restore it on the newly installed system.
However, when I do
sudo dpkg --set-selections < packages-backup.list
I get a long list of error messages like these:
dpkg: warning: package not in database at line 1417: sqlite3
dpkg: warning: package not in database at line 1417: sqliteman
dpkg: warning: package not in database at line 1417: sqliteman-doc
and finally
dpkg: warning: found unknown packages; this might mean the available database is outdated, and needs to be updated through a frontend method
So I ran sudo apt-get update
and re-ran dpkg
but I keep getting the same error.
I seem to get this error message for every single package in the list, including rather unspectacular ones such as the default kernel or sqlite. Also, I had not added any additional PPAs on my previous setup, thus packages from non-default repositories can't be the issue here.
As a test, I tried to install one of the "offending" packages with sudo apt-get install
, which worked without any issues.
What's going wrong here?
Solution 1:
The warnings are safe to ignore, as they only concern the dpkg
database. Actual installation is done with APT, which doesn't use this database.
When you are using dpkg
in this manner, you need to use dselect-upgrade
in order to apply the changes marked.
sudo apt-get dselect-upgrade
From man dpkg:
Note that this file is mostly useless if you don't use dselect but an APT-based frontend: APT has its own system to keep track of available packages.
Solution 2:
Try this:
sudo apt-get install dselect && sudo dselect update
After you can execute:
sudo dpkg --set-selections < packages-backup.list
Solution 3:
This method does not require dselect
package
To update dpkg database from apt cache:
apt-get update # can skip this
apt-cache dumpavail > /var/cache/apt/available
dpkg --admindir=/var/lib/dpkg --update-avail /var/cache/apt/available
Or one-liner with root:
dpkg --admindir=/var/lib/dpkg --update-avail <(apt-cache dumpavail)