Comment 9 for bug 229489

Revision history for this message
Duncan Coutts (duncan-haskell) wrote :

I happen to be an upstream developer of Gtk2Hs and I ran into this problem while doing the upgrade from 7.10 to 8.04.

What's going on:
--------------------------
Every Haskell library gets registered with the Haskell compiler ghc. The ghc-pkg program is used to do that.
Packages get registered (ghc-pkg register) when they're installed and unregistered (ghc-pkg unregister) when
they get uninstalled or upgraded. To be unregistered they have to be registered in the first pace.

So what's gone wrong is that ghc itself has been upgraded before the other libs (gtk2hs, mtl etc) were unregistered.
When ghc gets upgraded it includes an empty package database. So now when it comes time to upgrade the other
Haskell libs they are of course no longer registered (because they were registered with the older version of the
compiler and not the new one). The uninstall script then fails because ghc-pkg unregister fails, since the package is
not registered.

How to fix it:
----------------------------------
For a proper fix, pester the debian Haskell packagers.

How to workaround it:
----------------------------------
The workaround is to register dummy versions of the packages that the debs are trying to unregister. Then it will be
possible to uninstall the packages and after that, possible to install the new versions that work with ghc-6.8.2.

This assumes you do now have ghc-6.8.2 installed.

You need to register dummy versions of exactly the versions that were previously registered. For example if you are
having a problem with libghc6-gtk-dev-0.9.12, libghc6-glib-dev-0.9.12 and libghc6-cairo-dev-0.9.12 then we need to
register dummy ghc packages gtk-0.9.12, glib-0.9.12, cairo-0.9.12. An easy way to make dummy package registration
files is to copy them from an existing package registration and change the name and version numbers to the ones
we need.

For example:
ghc-pkg describe containers > gtk.pkg
ghc-pkg describe containers > glib.pkg
ghc-pkg describe containers > cairo.pkg

*** It is vitally important that you now edit the content files to change the package name, or you'll overwrite the
registration of the containers package which would screw up your ghc installation! ***

gedit gtk.pkg glib.pkg cairo.pkg

Change the first two lines of each of these package registration files from:
  name: containers
  version: 0.1.0.1
to
  name: gtk
  version: 0.9.12
Obviously using the right package name for the file, so gtk, glib, cairo etc.

Once that's done then as root we register these dummy packages:
sudo ghc-pkg register gtk.pkg
sudo ghc-pkg register glib.pkg
sudo ghc-pkg register cairo.pkg

You can check they're registered with ghc-pkg list

Once you've done this it should be possible to uninstall the problematic deb packages and then install the new
versions. You might just want to check afterwards again with ghc-pkg list that the dummy packages we registered
got unregistered again when you uninstalled the deb packages. If you end up with one left over you can use
ghc-pkg unregister to remove them again (specify the exact package name and version).