Difference between revisions of "Haskell package guidelines"

From ArchWiki
Jump to: navigation, search
m
Line 2: Line 2:
 
'''Haskell on Arch Linux'''
 
'''Haskell on Arch Linux'''
  
Haskell is well supported on Arch Linux, with GHC and other key tools available via pacman, and 87% percent of [http://hackage.haskell.org hackage.haskell.org] library database [http://aur.archlinux.org/packages.php?O=0&L=0&C=0&K=arch-haskell&SeB=m&SB=n&SO=a&PP=100&do_Search=Go available via AUR].  
+
Haskell is well supported on Arch Linux, with GHC and other key tools available via pacman, and 87% percent of [http://hackage.haskell.org hackage.haskell.org] library database [http://aur.archlinux.org/packages.php?O=0&L=0&C=0&K=arch-haskell&SeB=m&SB=n&SO=a&PP=100&do_Search=Go available via AUR].
 +
Not all the haskell packages work all the time, though. Try installing haskell-platform and see it fail.
  
 
'''[http://code.haskell.org/arch/arch-haskell-status.html The status of all Haskell packages in Arch Linux]'''
 
'''[http://code.haskell.org/arch/arch-haskell-status.html The status of all Haskell packages in Arch Linux]'''

Revision as of 14:25, 23 November 2010

Haskell on Arch Linux

Haskell is well supported on Arch Linux, with GHC and other key tools available via pacman, and 87% percent of hackage.haskell.org library database available via AUR. Not all the haskell packages work all the time, though. Try installing haskell-platform and see it fail.

The status of all Haskell packages in Arch Linux

The community around Haskell on Arch is also active and well organized.

Community

The main resources for the Arch/Haskell community to interact and discuss are:

Haskell Packages

The core Haskell tools are available in the core system (extra):

[Extra]

Our policy is for [extra] to provide the Haskell platform, and popular Haskell applications.

AUR

A huge number (almost 2000) packages built from http://hackage.haskell.org

These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed as, for example:

   sudo paktahn -S haskell-csv

Anything not found here can be installed via cabal-install direct from Hackage.

Direction and strategy

The strategy for Haskell on Arch Linux is to support the Haskell platform suite in [extra], and to track Hackage via AUR. This has been adopted as an official policy document.

Guidelines

In almost all cases cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool.

It is strongly recommended that you use this tool, as it implements the packaging policy for Haskell packages. These packages are primarily managed by Don Stewart.

Development version:

Or:

  • cabal install cabal2arch

Most things on http://hackage.haskell.org that are packageable, are already in AUR.

If not, download and build cabal2arch, as below, and use that to create the package. This will ensure it follows standard naming, dependency and installation conventions. Drop by #arch-haskell to let us know what is going on.

cabal2arch: an example

This example illustrates how to create a new package with cabal2arch. We'll make a new package for the delimited continuations library, CC-delcont:

First, find the hackage page for CC-delcont, then identify the link to the .cabal file. Use this link as an argument to cabal2arch:

$ cd /tmp
$ cabal2arch http://hackage.haskell.org/packages/archive/CC-delcont/0.2/CC-delcont.cabal
Using /tmp/tmp.Ig0H8jCOyO/CC-delcont.cabal
Fetching http://hackage.haskell.org/packages/archive/CC-delcont/0.2/CC-delcont-0.2.tar.gz
Created /tmp/haskell-cc-delcont.tar.gz

Checking what was created:

$ ls
haskell-cc-delcont  haskell-cc-delcont.tar.gz

The .tar.gz is a zipped PKGBUILD ready to upload to AUR. You can now inspect the PKGBUILD and install script for the library:

   # Contributor: Arch Haskell Team <arch-haskell@haskell.org>
   # Package generated by cabal2arch 0.6.1
   pkgname=haskell-cc-delcont
   pkgrel=1
   pkgver=0.2
   pkgdesc="Delimited continuations and dynamically scoped variables"
   url="http://hackage.haskell.org/package/CC-delcont"
   license=('custom:OtherLicense')
   arch=('i686' 'x86_64')
   makedepends=()
   depends=('ghc' 'haskell-cabal')
   options=('strip')
   source=(http://hackage.haskell.org/packages/archive/CC-delcont/0.2/CC-delcont-0.2.tar.gz)
   install=haskell-cc-delcont.install
   md5sums=('e52149fca9bf76330a7c159917152790')
   build() {
       cd ${srcdir}/CC-delcont-0.2
       runhaskell Setup configure --prefix=/usr --docdir=/usr/share/doc/${pkgname} || return 1
       runhaskell Setup build                   || return 1
       runhaskell Setup haddock || return 1
       runhaskell Setup register   --gen-script || return 1
       runhaskell Setup unregister --gen-script || return 1
       install -D -m744 register.sh   ${pkgdir}/usr/share/haskell/$pkgname/register.sh
       install    -m744 unregister.sh ${pkgdir}/usr/share/haskell/$pkgname/unregister.sh
       install -d -m755 $pkgdir/usr/share/doc/ghc/libraries
       ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/libraries/CC-delcont
       runhaskell Setup copy --destdir=${pkgdir} || return 1
       install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/$pkgname/LICENSE || return 1
       rm -f ${pkgdir}/usr/share/doc/${pkgname}/LICENSE
   }

It follows the conventions for Haskell packages:

  • Maintainer is by default the Arch Haskell team.
  • Libraries are prefixed with "haskell-"
  • "core" and "extra" Haskell libraries are not included as explicit dependencies, since ghc provides them
  • It uses cabal to generate a post-install register/unregister script, with a standard name.
  • We use haddock to build the documentation.
  • Profiling versions of the library aren't currently installed (TODO)

All Haskell libraries should follow these naming conventions, and using the cabal2arch tool will ensure this is the case.

Inspect the bundle, and confirm you can build and install it:

   $ makepkg -s
   $ makepkg -i

And we're ready to go. Now your .tar.gz is ready to upload to AUR.

"Provides"

See the discussion on the use of "provides" here.

Uploading the the Haskell repository

This section is out of date

The following (ad hoc) script is currently used to upload packages after running cabal2arch to the respository, and keep it in sync:

#!/bin/sh
set -e
makepkg -i
scp *-x86_64.pkg.tar.gz code.haskell.org:/srv/code/arch/x86_64/
repo-add /home/dons/haskell.db.tar.gz *.pkg.tar.gz
rm -rf *.tar.gz pkg src
pwd=`pwd`
dir=`basename $pwd`
cd ..
scp -r $dir code.haskell.org:/srv/code/arch/x86_64/
scp $HOME/haskell.db.tar.gz code.haskell.org:/srv/code/arch/x86_64/

This is to be used by those with arch-haskell repository write permissions.

Guidelines for Libraries

In general, each .cabal file should map to one PKGBUILD. The following conventions hold:

  • libraries have their cabal names prefixed with "haskell-"
  • all haskell dependencies are statically linked, so can go in the makedepends field.
  • all libraries have a dependency on 'ghc'
  • libraries don't need to have explicit dependencies on core Haskell packages -- these come in the 'ghc' package. (e.g. array, base, containers, random, process etc).
  • be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the 'gtk2hs' package, not , e.g. "haskell-cairo"
  • we want to resolve dependencies with a fixed constraint to base>=3.0
  • be careful about dependencies on the libraries provided by the basic 'ghc' package, which include:
ALUT-2.1.0.0        cgi-3001.1.5.1       network-2.1.0.0       regex-base-0.72.0.1
Cabal-1.2.3.0       containers-0.1.0.1   old-locale-1.0.0.0    regex-compat-0.71.0.1
GLUT-2.1.1.1        directory-1.0.0.0    old-time-1.0.0.0      regex-posix-0.72.0.2
HUnit-1.2.0.0       fgl-5.4.1.1          packedstring-0.1.0.0  stm-2.1.1.0
OpenAL-1.3.1.1      filepath-1.1.0.0     parallel-1.0.0.0      template-haskell-2.2.0.0
OpenGL-2.2.1.1      haskell-src-1.0.1.1  parsec-2.1.0.0        time-1.1.2.0
QuickCheck-1.1.0.0  haskell98-1.0.1.0    pretty-1.0.0.0        unix-2.3.0.0
array-0.1.0.0       hpc-0.5.0.0          process-1.0.0.0       xhtml-3000.0.2.1
base-3.0.1.0        html-1.0.1.1         random-1.0.0.0
bytestring-0.9.0.1  mtl-1.1.0.0          readline-1.0.1.0

These libraries don't need explicit dependencies to be set. cabal2arch solves all these constraints for us.

Registering Haskell libraries is done via a register hook:

build() {
   cd ${srcdir}/cabal2arch-0.1
   runhaskell Setup configure --prefix=/usr || return 1
   runhaskell Setup build                   || return 1
   -- generate register scripts
   runhaskell Setup register   --gen-script || return 1
   runhaskell Setup unregister --gen-script || return 1
   install -D -m744 register.sh    ${pkgdir}/usr/share/haskell/$pkgname/register.sh
   install    -m744 unregister.sh ${pkgdir}/usr/share/haskell/$pkgname/unregister.sh
   runhaskell Setup copy --destdir=${pkgdir} || return 1
   -- usual Haskell BSD3 license isnt' official
   install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/$pkgname/LICENSE || return 1
}
  • Examples:
haskell-zlib, haskell-mersenne-random

Guidelines for Programs

  • Have their normal name. Examples:
hmp3, xmonad, ghc, cabal-install
  • Be careful about dynamically linked runtime dependencies on C. For example, all GHC-produced binaries

have a runtime dependency on 'gmp'. OpenGL or GtT-based binaries will have additional 'depends'. cabal2arch will attempt to work out the C dependencies, but there may be others implied by Haskell dependencies that are missed.

  • Use executable stripping, --enable-executable-stripping. cabal2arch will do this automatically.

Haskell on Arch: current state

* http://www.galois.com/~dons/arch-haskell-status.html

AUR

There's another > 550 Haskell packages in AUR.

Building all of Hackage

The following simple script, with cabal-install and cabal2arch installed, will do a simple run over all the Haskell packages on haskell.org, creating arch packages for them. Before you start it is worthwhile removing all haskell packages, and reinstalling them. And then editing your unpacked haskell package directory to remove base libraries -- you probably don't want to install them.


   #!/bin/sh
   cabal update
   tmpdir=`mktemp -d`
   finaldir=`mktemp -d`
   cd $tmpdir
   tar xzf $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz
   for dir in * ; do 
        if [ ! -d $dir ] ; then
            continue
        fi
        cd $dir
        lib=`ls --color=never -1 | tail -1`
        echo "************** Building package for $dir-$lib"
        cd $lib
        cabal2arch *.cabal > $dir.log 2>&1
        cd `find . -type d -a ! -name '.'`
        if makepkg -sm > ../$dir.log 2>&1 ; then
            echo "OK: " $dir-$lib
            cp *.pkg.tar.gz $finaldir/
            sudo pacman -A *.pkg.tar.gz
            rm *.pkg.tar.gz
            rm -rf pkg src *.tar.gz
            cd ..
            cp -R `find . -type d -a ! -name '.'` $finaldir/
            cp *.tar.gz $finaldir/
        else
            echo "Failed"
        fi
        cd $tmpdir
   done
   echo `ls $finaldir/*pkg* | wc -l` "build packages in $finaldir"
   echo "Now: scp -r $finaldir/* code.haskell.org:/srv/code/arch/$MACHTYPE/"

Automatic local building of Hackage Packages with cabal2arch using Bauerbill

Although there are a number of haskell packages on AUR, there will always be outdated packages on AUR. If this happens and you want to create a fully updated package you would normally use cabal2arch. This however can become painful/time consuming if you have numerous packages with different dependencies (some of which may/may not be updated). Instead you can automatic this process by using Bauerbill which has the --hackage flag, allowing you to create AUR packages from Hackage locally. Below is an example of some common commands

   bauerbill -S --hackage [pkgs] : build [pkgs] directly from Hackage*
   bauerbill -Si --hackage [pkgs] : look up information about [pkgs]
   bauerbill -Ss --hackage [args] : search for [args]
   bauerbill -Qu --hackage : list upgradable Hackage packages

Syncing packages with the --hackage flag will interactively download all dependencies of the package from Hackage, convert them using cabal2arch and then build/install them (while checking dependencies). You can combine this with the --aur flag to give precedence to Hackage packages that are on AUR