dpkg has a parameter
--get-selections that allow you to export a list of the installed packages. On the old system run
dpkg --get-selections > packages.lst
and transfer the resulting file (
packages.lst) to the new system where you import it using the complementary parameter
dpkg --set-selections < packages.lst
This may produce the below warning:
dpkg: warning: found unknown packages; this might mean the available database
is outdated, and needs to be updated through a frontend method;
please see the FAQ https://wiki.debian.org/Teams/Dpkg/FAQ
which can mean any of the following two things:
- the package database needs to be updated (as the message claims), or
- some packages are not available for this OS release.
The former is easily addressed by one of the commands listed in the FAQ, e.g.
apt-cache dumpavail | dpkg --merge-avail
The latter can be ignored if the packages in question aren't relevant anymore (like the packages
upstart-sysv when going from Ubuntu Xenial to a more recent version). If there are packages you still need, even though they're not provided by the distro anymore, you need to find a different source for them. I do not recommend copying packages over from an older distro version, as that tends to lead to dependency conflicts.
Import the package list again if you had to update the database, then apply the selections by running the following command: