registering packages in ghc using a directory of package files

All, Yet again I've got annoyed by the difficulties with the way ghc registers packages. It's hard to get right. This time I had someone testing hdbc-odbc for me on ppc64. He uninstalled ghc and reinstalled it (to pick up a fix I had made) then he found that building hdbc-odbc failed because the hdbc package was not registered. However portage (the Gentoo package management facility) knew that it was installed. Of course what happened is that when ghc was reinstalled all the ghc packages that were already installed were not re-registered. Actually that is my fault because our ghc ebuild is supposed to do this. (Technically to do this correctly we should re-register the packages in dependency order, but we don't and just use --force) The point is that there are several bits that the packaging system has to get right for this to all work. The majority of the code in our ghc-package.eclass is for dealing with this issue. If we could just have ghc use a directory of package files rather than registering via modifying one central file then this would all become much simpler and more robust. One concern is that it would remove a point where the package database can be checked for consistency. I don't think this is necessarily so. The place that this QA check is really important is when users are manually installing packages. If an package management system finds a QA problem at registration time then it's already an unrecoverable bug. So the ghc-pkg could continue to be used in the way it is now, it will do it's carious checks and then install a file into a global package.conf.d directory rather than modifying a global package.conf file. For distro packaging systems we could use "ghc-pkg --check" or something, and then the package system would take responsibility for actually installing the file (and removing it when the package is uninstalled/upgraded). I'm somewhat tempted to patch our current ghc to do this, it might be easier to get that working than to get our current hacks to work properly. Duncan

On Sun, 2006-03-12 at 21:41 +0000, Duncan Coutts wrote:
I'm somewhat tempted to patch our current ghc to do this, it might be easier to get that working than to get our current hacks to work properly.
Attached is the current patch I'm testing. It's pretty minimal. It doesn't convert everything over to use a directory of .conf files. It just makes ghc and ghc-pkg look for package.conf.d/*.conf in addition to the normal package.conf. So in fact ghc-pkg still registers by modifying the global package.conf file. It's just that this allows us to register without using ghc-pkg at all and directly dropping a file into the right directory. In fact in Gentoo we already have such a directory. We keep a .conf file per package anyway since we need these to be able to re-register packages if ghc is reinstalled. So I've tested it by just symlinking: /usr/lib/ghc-6.4.1/package.conf.d -> /usr/lib/ghc-6.4.1/gentoo/ So far this seems to work. ghc-pkg reports all the installed packages and ghci can still load them up. Duncan

Duncan Coutts
On Sun, 2006-03-12 at 21:41 +0000, Duncan Coutts wrote:
I'm somewhat tempted to patch our current ghc to do this, it might be easier to get that working than to get our current hacks to work properly.
Attached is the current patch I'm testing.
It's pretty minimal. It doesn't convert everything over to use a directory of .conf files. It just makes ghc and ghc-pkg look for package.conf.d/*.conf in addition to the normal package.conf.
So in fact ghc-pkg still registers by modifying the global package.conf file. It's just that this allows us to register without using ghc-pkg at all and directly dropping a file into the right directory.
I really like this idea. I've had a variety of package registration difficulties in the past, sometimes requiring hand editing of the ghc-pkg data. A directory holding per-package .conf files would be much easier to navigate and examine. -- I've tried to teach people autodidactism, | ScannedInAvian.com but it seems they always have to learn it for themselves.| Shae Matijs Erisson

Duncan Coutts wrote:
Attached is the current patch I'm testing.
I think I've said in the past that in principle I like the idea. I'll commit your patch. In terms of making this a feature we advertise in the documentation, I think we could tweak the details a bit. I had in mind allowing -package-conf to specify either a directory or a file, with the obvious interpretation. Also, with your patch, each file in package.conf.d contains a list of packages. Having just a single package per file seems cleaner, unless you have a good reason to want the possibility for multiples. I realise this means wider-ranging changes. Cheers, Simon

On Mon, 2006-03-13 at 13:17 +0000, Simon Marlow wrote:
Duncan Coutts wrote:
Attached is the current patch I'm testing.
I think I've said in the past that in principle I like the idea. I'll commit your patch.
Great.
In terms of making this a feature we advertise in the documentation, I think we could tweak the details a bit.
Sure.
I had in mind allowing -package-conf to specify either a directory or a file, with the obvious interpretation.
I think that's how I did a version of this patch a year or so ago.
Also, with your patch, each file in package.conf.d contains a list of packages.
Yes.
Having just a single package per file seems cleaner,
Yes it does.
unless you have a good reason to want the possibility for multiples. I realise this means wider-ranging changes.
It was just that this was the simplest change that reused as much code as possible. Coincidentally it is also how we keep the per-package .conf files in gentoo, ie they're installed package.conf databases rather than indivdual package files. There are reasons we did that in gentoo but they're not essential. For ghc I'd recommend a dir of individual package files. The other problem with my patch is that each .conf file that is loaded up is it's own package db so ghc-pkg reports: /usr/lib64/ghc-6.4.1/package.conf.d/hsql-postgresql-1.7.conf: hsql-postgresql-1.7 /usr/lib64/ghc-6.4.1/package.conf.d/hsql-sqlite-1.7.conf: hsql-sqlite3-1.1 /usr/lib64/ghc-6.4.1/package.conf: rts-1.0, base-1.0, haskell98-1.0, template-haskell-1.0, unix-1.0, parsec-1.0, haskell-src-1.0, network-1.0, QuickCheck-1.0, HUnit-1.1, mtl-1.0, fgl-5.2, stm-1.0, readline-1.0, (lang-1.0), (concurrent-1.0), (posix-1.0), (util-1.0), (data-1.0), (text-1.0), (net-1.0), (hssource-1.0) But this is just because I was taking a very simple approach in my patch. It would obviously be better to consider a single directory of individual package files to be one package database. That will of course need more code changes. Then to do this fully there would need to be further changes to use a dir as ghc's main package db rather than the current file, and to get ghc-pkg to understand directory package dbs so it could register packages in them. Duncan

Duncan Coutts wrote:
On Mon, 2006-03-13 at 13:17 +0000, Simon Marlow wrote:
Duncan Coutts wrote:
I had in mind allowing -package-conf to specify either a directory or a file, with the obvious interpretation.
I think that's how I did a version of this patch a year or so ago.
My apologies, I dropped the ball on that one. It came around the time we were making other large changes to the package code, I think. I've made a ticket for this task now: http://hackage.haskell.org/trac/ghc/ticket/723 Cheers, Simon
participants (3)
-
Duncan Coutts
-
Shae Matijs Erisson
-
Simon Marlow