dpkg-divert: mismatch on package

After upgrading Ubuntu 10.04 to 10.10 I encountered the following error, which prevented me from removing the fglrx package: “dpkg-divert: mismatch on package”. Read on for a solution.

Dpkg maintains a list of diverted files. To see it, enter the following:

dpkg-divert --list

In my case, fglrx wanted to remove files from xorg-driver-fglrx called /usr/lib/libGL.so.1.2 and /usr/lib32/libGL.so.1.2. So what I had to do was:

dpkg-divert --remove /usr/lib/libGL.so.1.2
dpkg-divert --remove /usr/lib32/libGL.so.1.2

Than remove both packages with:

dpkg --purge fglrx
dpkg --purge xorg-driver-fglrx

And restore the newer driver with:

apt-get install fglrx

Or if you encounter this with another package, try your package name or:

apt-get -f install