Repairing apt-get database

From MEPIS Documentation Wiki

Jump to: navigation, search

Contents

First Things to Try

Run as root:

dpkg --configure -a 
apt-get -f install

Overwrite Problems

Example:

dpkg: error processing /var/cache/apt/archives/libcupsys2-dev_1.1.23-3_i386.deb(--unpack):
 trying to overwrite `/usr/share/man/fr/man1/cups-config.1.gz', which is also in package cupsys
Errors were encountered while processing:
 /var/cache/apt/archives/libcupsys2-dev_1.1.23-3_i386.deb

Solution: Force the installation of that specific package:

dpkg -i --force-overwrite /var/cache/apt/archives/libcupsys2-dev_1.1.23-3_i386.deb

If it Hangs

Scenario: apt-get hangs during a configuration stage, you get tired of waiting, Ctrl-c to abort the execution of the program, and then you get an error specifying package(s) that had problems.

You should be able to reproduce the error/hang with

  apt-get install some-unrelated-already-installed-package
  

E.g, I use this command:

apt-get install emacs21

There are some recently-added apt-get commands -- autoclean and autoremove -- that may be helpful. So you can try playing with these. (You can get the newest apt with apt-get install apt.)

Another thing I have found helpful is

 apt-get --purge remove package

or, if that didn't work, proceed as in " Removing Badly Broken Package" section below.

After every package purge, try

  apt-get install some-unrelated-already-installed-package

as above, and when you stop getting errors from this, you should be ok.

I use the following as a template for a script to help me back out of this type of situation

 #!/bin/bash
 find /var/cache/apt/archives/ | grep -i gtk | xargs rm -f
 dpkg --configure -a
 
 # probably don't need this usually, just my environment has low ram; the y flag is to automaticlally answer yes
 APTGET_FLAGS='-y -o APT::Cache-Limit=25165824' 
 
 apt-get $APTGET_FLAGS --purge remove libghc6-gtk-dev
 dpkg --purge --force-remove-reinstreq libghc6-gtk-dev
 
 apt-get $APTGET_FLAGS autoclean # remove if can't be downloaded from repo clean
 apt-get $APTGET_FLAGS autoremove # clean up unused dependencies
 apt-get $APTGET_FLAGS install emacs21 # already installed, should now produce no errors

Removing Badly Broken Package

1) To be aplied if other methods fail:

dpkg --purge --force-remove-reinstreq <package name>

2) the following procedure if 1) above does not work.
a. dpkg --listfiles <package name>

Find every file that was installed, then do a search and destroy.

b. Edit the file /var/lib/dpkg/status

Remove the section for your badly broken package (Make a backup before you edit the file)

c. Edit the file /var/lib/dpkg/available

Remove the section for your badly broken package (Make a backup before you edit the file)
Personal tools
In other languages