How to remove damaged/corrupted Debian Package
************************************************************************
I d like to bring you my contribution to this problem just because i had
it once and it wasn't so evident to find [for me at least :)]
This help file is quickly done and with a lot of "fautes d'anglais" but
maybe it will be helpfull for some you.
Any comments: adl@hert.org
************************************************************************
Suppose you have a nasty package installed, a package with missing
or modified files... normally you sould have this type of stupid message
when tying to remove it:
loom# dpkg -r time
dpkg: error processing time (--remove):
Package is in a very bad inconsistent state - you should
reinstall it before attempting a removal.
Errors were encountered while processing:
In this example i want to remove the "time" package because he's well
damaged but ... i can't :)
First,
find your problematic deb file (in this exemple "time"), if the file
hasn't been delete after download it should be at:
/var/cache/apt/archives/
copy the problematic package to your home directory
cp /var/cache/apt/archives/time_1.7-7_i386.deb ~/
[note: if the was deleted by dselect download it again, even manualy]
then do
cd ~
mkdir tmp [if you don't have already tmp directory :)]
dpkg-deb --extract time_1.7-7_i386.deb tmp
now if you have a look in ~/tmp you should notices the files of the
package in the directories where they should be if they were normaly
installed.
[I hope i'm clear enough :)]
copy each files where they should be normally installed by the Package Manager
ls tmp/usr/bin/time
cp tmp/usr/bin/time /usr/bin
...
At this point you should be able to excute this command:
dpkg -r --force-remove-reinstreq time
Normaly you'll get something like this:
dpkg - warning, overriding problem because --force enabled:
Package is in a very bad inconsistent state - you should
reinstall it before attempting a removal.
(Reading database ... 59134 files and directories currently installed.)
Removing time ...
[If it's not removing at this point check that you didn't forget any files
to be copied]
Now that the files are removed you can purge:
dpkg --purge time [Purge time ! ! !]
loom# dpkg --purge time
(Reading database ... 59128 files and directories currently installed.)
Removing time ...
Purging configuration files for time ...
loom# dselect
Reading Package Lists... Done
Building Dependency Tree... Done
Good, now you can if you want reinstall the package without problems.
Reply to: