How to remove package in bad state, software center freezes, no synaptic

When 'Update Manager' starts running, it tells me that I need to do a 'Partial Upgrade', when I start doing the upgrade, it tells me

Remove package in bad state 

The package 'linux-headers-3.0.0-19' is in an inconsistent state 
and needs to be reinstalled, but no archive can be found for it. 
Do you want to remove this package now to continue?"

When I click 'Yes' the program just closes. I have tried to go into the software center and reinstall the linux-headers-3.0.0-19 ubuntu software center just freezes.

Right now I cannot run 'Synaptic', or remove any software.


Try this, I hope it works:

  1. Make a backup of /var/lib/dpkg/status:

    sudo cp /var/lib/dpkg/status /var/lib/dpkg/status.bkup
    
  2. Open /var/lib/dpkg/status:

    sudo nano /var/lib/dpkg/status
    
  3. Search through the file for any reference to that package name (i.e. linux-headers-3.0.0-19) and CAREFULLY delete that entry. Don't delete anything else. Save the file and quit.

  4. Do sudo apt-get update.

This should probably solve the problem.


  • If you get nowhere with any of the other offerings I've used this in the past

    dpkg --remove --force-remove-reinstreq
    

    From the dpkg manual

    remove-reinstreq: Remove a package, even if it's broken

  • So run:

    sudo dpkg --remove --force-remove-reinstreq  linux-headers-3.0.0-19