[Haskell-cafe] Creating binary distributions with Cabal

Duncan Coutts duncan.coutts at googlemail.com
Fri Aug 20 05:43:50 EDT 2010


On 20 August 2010 10:18, Christopher Done <chrisdone at googlemail.com> wrote:
> Does Cabal have a way to produce binary distributions from a package?

No but it's not too hard to do.

If you actually want an RPM or a DEB etc, then look into the cabal2rpm
etc tools, they help automate the process.

If you want a generic binary then:

You first prepare an image, but using:

cabal copy --destdir=./tmp/image/

Now you tar up the image directory, unpack it on the target.

Note that the prefix/paths you specified at configure time need to be
the same on the target machine. There is no support yet on unix for
relocatable / prefix independent binaries. In particular it needs the
paths to be correct to be able to find data files.

> I need to create a binary distribution of my project which does not
> depend on GHC or any development tools. The package should include all
> required data files and configuration files. I've got the latter
> covered with Data-Files and getDataFileName, but not sure about what
> to do regarding configuration files -- read/write to
> $HOME/.myproject/config or $HOME/.myprojectrc, etc., or what?

Right, config files you should just look in a per-user or global
location. You can use a data file to store a default so that the
program can work with no config file.

> I'm specifically targeting Redhat because that's the production
> server, but I'm wondering if there is or will be a way to agnostically
> access data files and configuration files without having to think
> about what OS it will be running on, in the same way I can use sockets
> or file access without worrying about the particular OS.
>
> Something like cabal sdist --binary --rpm/deb/arch/win/etc?

We might eventually add something for generic binaries but we will
leave specific distros and packaging systems to specialised tools.

> How does everyone else package up their Haskell programs for binary
> distribution?

As I mentioned there are also tools like cabal2rpm that help build
binary packages for specific distros.

Duncan


More information about the Haskell-Cafe mailing list