Lazyness and Cabal Packages

Often times, when i'm working on random Haskell things, i find i'm doing the same actions over and over again. I've also found i've done the same groups of commands repeatedly, and alot of work could be automated. Last winter, Luke Macken and i had a bit of a chat about some ways we could work out a bit of a solution to the problem. He already had some code put together to make a quick developer shell for doing common Fedora related tasks.

My goal was to create something that can handle a workflow to automate most of the steps in making RPMs for basic Cabal packages. Cabal is the package manager for Haskell, similar to Python Eggs, or Ruby Gems. Since it's so well developed, 95% of the steps required to make an RPM can be automated to a few brief statements. Yesterday, i spent the better part of the day hacking together a module in fedora-devshell that can be used to download Cabal packages from Hackage, the Haskell source package repository, compile them, and install them either to root or to home. The user can also do it step by step, and intervene where necessary.

If you would like to follow along, you can get the source below. (GPL v2+);a=summary

In this example, i'm assuming that all the source packages will go in ~/haskell, where i normally work. fedora-devshell does a bunch of things half baked, because i'm still working on them. The only modules and concepts you will need though are Package and Cabal. Package refers to any generic Linux/Unix package, and cabal refers specifically to a Cabal package. Essentially, ~/haskell will have a bunch of Packages, and each Package will have one or more Cabal package, although only one active package. And that's it for theoretical stuff. Just remember, a Package can have a different name than the Cabal package will.

To take a random tarball, and make a regular Package out of it, run:
~/haskell $ cabal xmonad-test copy_in /some/location/xmonad.darcs.tar.bz2

This will create a directory ~/haskell/xmonad-test, which will have a tarball, and two expanded trees of the tarball, one is the modifiable one, and one is a copy of the original. In the future, fedora-devshell will make it easy to modify the source, compile and test it, and then make diff files to use in RPMs or to send upstream.

to compile the Cabal package, you need the following steps:
~/haskell $ cabal xmonad-test configure
~/haskell $ cabal xmonad-test build
~/haskell $ cabal xmonad-test install

This will install it to $HOME.

You can also use the shortcut
~/haskell $ cabal xmonad-test install_source

If you want to do it all in one, with a tarball, you can just do this
~/haskell $ cabal xmonad-test install_sourceball /some/location/xmonad.darcs.tar.bz2

Let's say you want to get some version from Hackage
~/haskell $ cabal xmonad-test get_from_hackage xmonad 0.8

Or, if you want to download the latest
~/haskell $ cabal xmonad-test get_latest xmonad

You could install from hackage:
~/haskell $ cabal xmonad-test install_from_hackage xmonad 0.8

Or even just
~/haskell $ cabal xmonad-test install_latest xmonad

Essentially, it's yet another package installer for Cabal. If you're a regular haskell wondering why you need this, then it's probably not for you, because there are other tools that can do this better. If you're a packager though, it's a sneak preview of one of many tools that will be integrated together in fedora-devshell that will make your life alot easier.