Duplicate package selection in Debian

  Last modified on Monday 06 July 2015

I am happy with the selection of packages installed on my primary Debian box and discovered an easy method [1] to duplicate the setup on a secondary machine.

Generate a list of installed packages on the original:

$ dpkg --get-selections | grep -v deinstall > pkg-list.txt

Move the generated list to the target machine. Configure the package manager [2] to duplicate the selection:

$ PKGS=$(mktemp)
$ sudo apt-cache dumpavail > "$PKGS" && sudo dpkg --merge-avail "$PKGS" && sudo rm "$PKGS"
$ sudo dpkg --clear-selections && sudo dpkg --set-selections < pkg-list.txt
$ sudo apt-get dselect-upgrade

Happy hacking!

Notes

[1]Source: Debian Administrator's Handbook
[2]Added an option to supply [PACKAGE_LIST] to my debian-post-install script

More • debianlinuxshell