How to reinstall a set of Debian packages with dpkg

Recently, after upgrading my laptop to Debian Squeeze, a prompt appeared at each security upgrades asking for a purge of some packages which were  no longer needed by the system.

As requested to gain more space, I issued the command “apt-get autoremove” and a large bunch of packages was removed. But the operation brought me some trouble while running Debian the day after. Looking at the state of the packages through dpkg, I noticed that many packages status were set to deinstall.

How to install them again without having a precise list of packages to deal with?

Here is the operation I realized successfully.

First, save the current state of the packages :

root@localhost:~#dpkg –get-selections > /tmp/list_current_packages.log

Then, reinitialize the status of all the packages. By default, it will be set to “deinstall”.

root@localhost:~#dpkg –clear-selections

Modify the file /tmp/list_current_packages.log by replacing “deinstall” by “install”. Finally, to reinstall the packages you want :

root@localhost:~# dpkg –set-selections < /tmp/list_current_packages.log

 

Advertisements

One thought on “How to reinstall a set of Debian packages with dpkg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s