Maintaining a large set of Haskell packages for a Linux distribution is quite a chore. Especially if one wants to track Hackage as far as possible. Several distributions have tools to automatically convert Cabal-based packages into distribution packages, e.g. cabal2arch for ArchLinux and cabal-rpm. They are just conversion tools though, and the most time-consuming activity in maintaining Haskell packages is resolving and verifying dependencies.
At least that was my experience when I was actively involved in ArchHaskell. I only saw two options when adding or upgrading a package, either I worked out dependencies manually, or I simply tried it out. Neither of them was very appealing, and both were very time-consuming. It seemed obvious that I needed some tool to help out.
It allows me to maintain a database of specific versions of packages, and when I want to upgrade a package, or add a new one, it’ll verify that all dependencies can be satisfied. In other words, it helps me maintain a buildable set of packages at all times.
The tool also has some functionality that helps in tracking Hackage as packages are updated there.
Something about how it works
At the moment I maintain a small repository of Arch packages, mostly just to
cblrepo and convince myself that it works. The work environment
contains a database and a directory of patches:
% ls cblrepo.db patches/ %
The database is a cleartext file containing the information on the packages.
It’s basically just a dump of the related Haskell datatype, encoded in JSON.
patches directory holds patches for Cabal files and PKGBUILD files.
They must be named
patch.cabal.<hackage name> or
name> in order to be picked up by
There’s also an application directory (
~/.cblrepo) for caching info about
the packages available on Hackage:
% ls ~/.cblrepo 00-index.tar.gz %
How to use it
A session with
cblrepo looks something like this. First we update the
information about what packages are available on Hackage:
% cblrepo idxsync %
After that it’s possible to see what packages are out-of-date:
% cblrepo updates cmdargs: 0.6.8 (0.6.9) test-framework-th: 0.1.3 (0.2.0) xml: 1.3.7 (1.3.8) language-haskell-extract: 0.1.2 (0.2.0) blaze-builder: 0.2.1.4 (0.3.0.0) %
Let’s check whether
cmdargs can be updated:
% cblrepo add -n cmdargs,0.6.9 %
It generates no output, so that means it’s possible to update. When attempting to add all the packages we run into a problem:
% cblrepo add -n cmdargs,0.6.9 \ > test-framework-th,0.2.0 \ > xml,1.3.7 \ > language-haskell-extract,0.2.0 \ > blaze-builder,0.3.0.0 Adding blaze-builder 0.3.0.0 would break: haxr : blaze-builder ==0.2.*
blaze-builder at the current version for now:
% cblrepo add cmdargs,0.6.9 \ > test-framework-th,0.2.0 \ > xml,1.3.7 \ > language-haskell-extract,0.2.0 %
After these updates we also need to make sure that all packages that depend on these ones are re-built, that is we need to bump their release version:
% cblrepo bump -n cmdargs \ > test-framework-th \ > xml \ > language-haskell-extract Would bump: test-framework test-framework-hunit test-framework-quickcheck2 %
Just re-run that without the
-n to actually perform the bump. Now that all
this is done we need to generate the files necessary to build the Arch
packages. We can easily check what packages need re-building, and get a good
order for building them:
% cblrepo build cmdargs \ > test-framework-th \ > xml \ > language-haskell-extract cmdargs xml test-framework test-framework-quickcheck2 test-framework-hunit language-haskell-extract test-framework-th %
And generating the required files is also easy:
% cblrepo pkgbuild $(!!) % tree . |-- cblrepo.db |-- haskell-cmdargs | |-- haskell-cmdargs.install | `-- PKGBUILD |-- haskell-language-haskell-extract | |-- haskell-language-haskell-extract.install | `-- PKGBUILD |-- haskell-test-framework | |-- haskell-test-framework.install | `-- PKGBUILD |-- haskell-test-framework-hunit | |-- haskell-test-framework-hunit.install | `-- PKGBUILD |-- haskell-test-framework-quickcheck2 | |-- haskell-test-framework-quickcheck2.install | `-- PKGBUILD |-- haskell-test-framework-th | |-- haskell-test-framework-th.install | `-- PKGBUILD |-- haskell-xml | |-- haskell-xml.install | `-- PKGBUILD `-- patches 8 directories, 15 files %
Now all that’s left is running
makepkg in each of the directories, in the
order indicated by
cblrepo build above.
Unfortunately they won’t all build—generating the Haddock docs for
test-framework-th fails. That’s however fairly easy to remedy by patching
PKGBUILD to disable the generation of docs.
I’ll get back to that in a later post though.
Your comments, please
Please leave comments and suggestions. I’m planning on uploading the source to github shortly.