For the transfer of a Debian or Ubuntu machine, or to make a mirror of it, it is often needed to reinstall the packages that are installed one one system on an other one. We will explain it in here.
The dpkg way of doing
First of all, we need to grab the list of all installed package and save it in
a text file. Here we will save it in installed_packages.txt
.
# dpkg --get-selections > installed_packages.txt
The installed_packages.txt
file contain a list of package and their installation status:
aalib1 deinstall
abiword-common deinstall
acroread install
acroread-debian-files install
acroread-escript install
acroread-plugins install
adduser install
adept-notifier deinstall
affix install
akode deinstall
akregator install
alsa-base install
alsa-oss install
alsa-tools install
[...]
After transferring the list of packages on the new system we need to load it
inside dpkg
, with the following command:
# dpkg --set-selections < mes_paquets
Then, we need to say to apt-get to grab this selection to set the package to install and remove:
# apt-get dselect-upgrade
Finally a classical upgrade is required:
# apt-get dist-upgrade
The aptitude way of doing
Grabs the only the manually installed packages on the current system in
installed_packages.txt
:
# aptitude search -F%p ~i\!~M > installed_packages.txt
The installed_packages.txt
file contain a list of package, without
status unlike for the dpkg way:
aalib1
abiword-common
acroread
acroread-debian-files
acroread-escript
acroread-plugins
adduser
adept-notifier
affix
akode
akregator
alsa-base
alsa-oss
alsa-tools
[...]
After transferring the list of packages on the new system, we just have to give it to aptitude or apt:
# aptitude install $(cat installed_packages.txt)
or
# apt-get install $(cat installed_packages.txt)
The advantage of this method is that only the manually installed packages will be installed, with corresponding dependency. It will therefore set correctly the database use to detect the manually installed packages, and not with all the packages that were installed on the first system.