Wednesday, March 14, 2012

Force removal of broken packages

If you try to install a package and are missing dependencies, apt-get will not let you remove it because it is an an inconsistent state.

tward $ sudo apt-get remove tinyos-2.1.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 avr-libc-tinyos : Depends: avr-gcc-tinyos but it is not going to be installed
 avr-tinyos : Depends: avr-binutils-tinyos but it is not going to be installed
              Depends: avr-gcc-tinyos but it is not going to be installed
              Depends: avrdude-tinyos but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Apt-get -f install does not fix the problem.
A solution is to remove the package with dpkg, then do the repair.

tward $ sudo dpkg --force-depends --purge tinyos-2.1.1 

tward $ sudo apt-get -f install