12

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?

5
  • 1
    Did you run sudo apt-get dselect-upgrade?
    – philsf
    Jan 29 '16 at 9:51
  • 1
    Not yet (as In understand the answer, this would be run afterwards). Just found something similar in the dpkg manpage and ran sudo dselect update, then retried. That reduced the warnings to packages that explicitly state a particular version.
    – user149408
    Jan 29 '16 at 9:57
  • 1
    Just executed sudo apt-get dselect-upgrade and it seems to be installing everything that's missing. Looks like all is fine now...
    – user149408
    Jan 29 '16 at 10:00
  • In this case I'll add an answer, then you can close the question.
    – philsf
    Jan 29 '16 at 10:03
  • one note on Ubuntu 16.10 desktop install, I had to 'apt-get install dselect' for this to work. Nov 30 '16 at 15:40
8

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.

2
  • Thanks for the answer. Since I run dselect-upgrade after set-selections, I understand I would still get the warnings – are you saying they're safe to ignore as they refer to a package DB that isn't going to be used anyway?
    – user149408
    Jan 29 '16 at 10:28
  • @user149408, that is correct, you can safely ignore those. Trust whatever APT says, which will be the one that manages existing packages from then on.
    – philsf
    Jan 29 '16 at 10:32
4

Try this:

sudo apt-get install dselect && sudo dselect update

After you can execute:

sudo dpkg --set-selections < packages-backup.list
1

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)
1
  • While other answers provide information that is true, this is the real solution to the problem.
    – Sorpigal
    May 15 at 18:38
0

The following script was a workaround for me. Watch out for linux-images and linux-headers. If you have many of those in your dpkglist.txt then you might want to filter these out with grep -v commands like

 cat dpkglist.txt | grep "$l_mode" | grep -v linux-headers | grep -v linux-image-3 | grep -v linux-image-extra-3 | cut -f1

script to install and uninstall packages from dpkglist.txt via apt-get

#!/bin/bash

#
# get the packages
# 
# param 1: l_mode: install or deinstall
#
packages() {
  local l_mode="$1"
  # get the lines for the given mode
  cat dpkglist.txt | grep "$l_mode" |  cut -f1
}

#
# loop over the packages in the given mode
# param 1: l_mode: install or deinstall
#
loop() {
  local l_mode="$1"
  for package in $(packages $l_mode)
  do
    case "$l_mode" in
      install) apt-get -y install $package;;
      deinstall) apt-get -y remove $package;;
    esac
  done
}

# do two loops
loop deinstall
loop install
0

In recent versions of Debian/Ubuntu/Mint, dpkg needs available packages to be in its "avail" database for dpkg --set-selections to work.

Example sequence:

  1. (On other system) dpkg --get-selections > installed.dselect
  2. sudo apt update
  3. apt-cache dumpavail | sudo dpkg --merge-avail
  4. sudo dpkg --set-selections < installed.dselect
  5. sudo apt-get dselect-upgrade

The third command populates dpkg's "avail" database. It's important to run this before setting the selections of which additional packages to install.

This reqires dpkg v1.17.7 and later. See Q: Why does ''dpkg --set-selections'' not record selections for unknown packages? on the Debian wiki for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.