Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I killed by mistake a dpkg process running in the background and I would like to reinstall all packages to be sure everything is allright.

First, I tried to get a list of all packages and reinstall them

dpkg --get-selections | grep -v deinstall | awk '{print $1}' > list.log
apt-get install --reinstall $(cat list.log)

But there are messages like :

E: Couldn't configure pre-depend debconf:i386 for console-setup:i386, probably a dependency cycle.

I tried apt-get -f install, without success.

As a last resort, I reinstalled all programs which failed the checksums :

dpkg -l | grep ^ii | awk '{ print $2 }' | xargs debsums -s -a

What should I do to reinstall everything ?

Edit : Problem solved. The issue was something else (see the comments). I understand it's something to avoid with Debian though.

share|improve this question
1  
I recently had a crash while trying to install a package. When I rebooted and tried to reinstall that package, I received the message, "E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.". Running that command removed said package and it configuration files. I was then able to install the package from scratch. Try giving that command a go. –  embedded.kyle Jun 12 '13 at 12:32
    
It didn't do anything, so I guess nothing is broken. I will try later to check if my driver issues are solved. –  alex_reader Jun 12 '13 at 13:01

4 Answers 4

up vote 5 down vote accepted

Try this, remembering that I do not tested it and prepending sudo whn needed:

dpkg --get-selections > selections
dpkg --clear-selections
dpkg --set-selections < selections
apt-get --reinstall dselect-upgrade

Sources:

share|improve this answer
    
My problem was completely different : I was not booting the correct kernel (!). I will accept your answer as it seems to do what I wanted (but untested also). –  alex_reader Jun 12 '13 at 17:44
    
This won't work, and will completely break the system. Line 3 will uninstall apt, so it won't be possible to reinstall everything, afterwards. –  rkjnsn Nov 4 '13 at 17:41
    
@rkjnsn: I updated the answer, check if it works. –  Marco Sulla Nov 6 '13 at 9:17
1  
Trying to do this nothing is being reinstalled, although the selections file is populated: pi@prodpi ~ $ sudo apt-get --reinstall dselect-upgrade Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. any idea? –  andig Jun 9 '14 at 8:42
    
One reason I think your code won't work is because the command dpkg --get-selections list also deinstall packages. –  Ortomala Lokni Feb 5 at 23:20

In one of the ressouce cited by Lucas Malor, I found a script called populator which seem to be near the solution. If you set the packages selection variable to the list of all your packages

PKGLIST=$(dpkg --get-selections | grep -v deinstall| cut -f1)

you can then run the script and reinstall all packages but the system will probablaby have some problems. It would be better to test it in a virtual machine.

Here is a variant of the script from the link above:

#!/bin/bash
#
# Script to pre-populate apt-get proxy for faster later downloads.
# It uses apt-get and wget to pull all the specified packages.
#

# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
   echo "You're not root, are you?" 1>&2
   exit 1
fi

# Specify wanted packages
PKGLIST="exaile" 

# Clears out the local repository of retrieved package files
apt-get clean

# Resynchronize the package index files from their sources
apt-get update

# Re-install specified packages at the newest version. 
apt-get install --reinstall $PKGLIST
share|improve this answer

When using RPM, in the event you cause a corruption in the package database, there is an option to rebuild this database, thus preventing you from having to go through basically a reinstall. As one user here pointed out this is done in Debian by dpkg --configure -a.

share|improve this answer
    
The role of dpkg --configure -a is to configure all unpacked and unconfigured packages. See man pages of dpkg and dpkg-reconfigureand also debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html –  Ortomala Lokni Feb 5 at 22:42

Just in case, try to reinstall each package:

for i in $(cat list.log); do apt-get install --reinstall "$i"; done

You may wish to add answer yes to all questions option too.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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