Difference between revisions of "Haskell package guidelines"

From ArchWiki
Jump to: navigation, search
m
m (AUR: remove AUR helper instructions)
(40 intermediate revisions by 17 users not shown)
Line 1: Line 1:
[[Category:Guidelines (English)]][[Category:Package development (English)]]
+
[[Category:Package development]]
'''Haskell on Arch Linux'''
+
[[it:Haskell Package Guidelines]]
 +
{{Package Guidelines}}
  
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].  
+
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux, with GHC and other key tools available via the [[Official Repositories|official repositories]], a growing number of packages made available by the ArchHaskell group, and a large part of [http://hackage.haskell.org hackage.haskell.org]'s library database [https://aur.archlinux.org/packages.php?O=0&K=haskell- available in the AUR].
 +
The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.
  
'''[http://code.haskell.org/arch/arch-haskell-status.html The status of all Haskell packages in Arch Linux]'''
+
The community around Haskell on Arch is dying but in the process of revival, so your help is especially welcome!
 
+
The community around Haskell on Arch is also active and well organized.
+
  
 
== Community ==
 
== Community ==
 
+
All the details on the [[ArchHaskell]] group is available on its own page.
The main resources for the Arch/Haskell community to interact and discuss are:
+
 
+
* [http://www.gogloom.com/FreeNode/arch-haskell <nowiki>#arch-haskell</nowiki>] irc channel @ freenode.org
+
** Good for quick discussion and planning
+
* [http://haskell.org/mailman/listinfo/arch-haskell arch-haskell@haskell.org] mailing list
+
** Broader announcements, and automated updates
+
* [http://archhaskell.wordpress.com/ Arch Haskell Weekly News]
+
** A blog announcing our progress to the outside world.
+
  
 
== Haskell Packages ==
 
== Haskell Packages ==
 
 
The core Haskell tools are available in the core system (extra):
 
The core Haskell tools are available in the core system (extra):
  
==== <nowiki>[Extra]</nowiki> ====
+
=== [extra] ===
* [http://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 Haskell packages in the core system]
+
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 Haskell packages in the core system]
  
Our [http://haskell.org/haskellwiki/Arch_Linux/Policy policy] is for [extra] to provide the Haskell platform, and popular Haskell applications.
+
Our policy for [extra] is to provide the Haskell platform, and popular Haskell applications.
  
==== <nowiki>AUR</nowiki> ====
+
=== [community] ===
 +
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 other popular Haskell packages]
  
* [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 Haskell packages in AUR]
+
[community] provides additional packages that are popular and not part of the Haskell platform, such as [[xmonad]].
 +
These packages are also provided by the [haskell] repo below.
 +
So, if you just want to use a few popular packages, you can just use what is provided by the official Arch repos.
 +
But if you want to use Haskell more seriously, read on.
  
A huge number (almost 2000) packages built from http://hackage.haskell.org
+
=== [haskell] ===
 +
The [haskell] repository is the official repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}}:
  
These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed as, for example:
+
[haskell]
 +
Server = http://xsounds.org/~haskell/$arch
  
    sudo paktahn -S haskell-csv
+
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].
  
Anything not found here can be installed via [http://aur.archlinux.org/packages.php?ID=17411 cabal-install] direct from Hackage.
+
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.
  
== Direction and strategy ==
+
=== [haskell-extra] and [haskell-web] ===
 +
We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository.
 +
The first test towards this is [https://github.com/EffeErre/habs-extra habs-extra], which is also provided as a repository to be added to {{ic|/etc/pacman.conf}}:
  
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 [http://haskell.org/haskellwiki/Arch_Linux/Policy official policy document].
+
[haskell-extra]
 +
Server = http://archhaskell.mynerdside.com/$repo/$arch
  
== Guidelines ==
+
This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell].
 +
More details are available in this [http://www.haskell.org/pipermail/arch-haskell/2012-September/002147.html message], and in the README on github.
  
In almost all cases cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool.
+
There is also [haskell-web], as mentioned [http://www.haskell.org/pipermail/arch-haskell/2012-October/002214.html here].
  
* [http://aur.archlinux.org/packages.php?ID=17471 Get the latest cabal2arch]
+
=== AUR ===
 +
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]
  
It is strongly recommended that you use this tool, as it implements the packaging policy for Haskell packages.
+
A huge number (almost 2000) packages built from http://hackage.haskell.org.
These packages are primarily managed by Don Stewart.  
+
  
Development version:
+
These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed like regular [[Arch User Repository|AUR]] packages.
  
* darcs get http://code.haskell.org/~dons/code/cabal2arch
+
Anything not found here can be installed via {{pkg|cabal-install}} directly from Hackage.
  
Or:
+
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.
 +
In practice, one could use the cabal2arch program to create [[PKGBUILD]]s directly from Hackage.
 +
But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.
  
* cabal install cabal2arch
+
== Guidelines ==
 +
 
 +
{{out of date|this and remaining sections may be out of date given the move to distributed repositories}}
  
Most things on http://hackage.haskell.org that are packageable, are already in AUR.
+
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 the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:
  
If not, download and build cabal2arch, as below, and use that to create
+
* Add the [haskell] repository to {{ic|/etc/pacman.conf}} and use [[pacman]] to install the latest release.
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.
+
* Download and build the {{AUR|cabal2arch}} package from the [[Arch User Repository|AUR]].
 +
* Install directly from Hackage using {{ic|cabal install cabal2arch}}.
  
 
===cabal2arch: an example===
 
===cabal2arch: an example===
 +
This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:
  
This example illustrates how to create a new package with cabal2arch. We'll make a
+
First, set the name and email address to be used in the generated PKGBUILD:
new package for the delimited continuations library, CC-delcont:
+
  
First, find [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CC-delcont the hackage page for CC-delcont], then identify the link to the .cabal file. Use this link
+
export ARCH_HASKELL='My Name <my.name@domain.org>'
as an argument to cabal2arch:
+
  
$ cd /tmp
+
Second, find [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc the hackage page for Pandoc], then identify the link to the .cabal file. Use this link as an argument to cabal2arch:
$ cabal2arch http://hackage.haskell.org/packages/archive/CC-delcont/0.2/CC-delcont.cabal
+
 
Using /tmp/tmp.Ig0H8jCOyO/CC-delcont.cabal
+
{{bc|<nowiki>
  Fetching http://hackage.haskell.org/packages/archive/CC-delcont/0.2/CC-delcont-0.2.tar.gz
+
% cd /tmp
  Created /tmp/haskell-cc-delcont.tar.gz
+
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc.cabal
 +
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal
 +
Feeding the PKGBUILD to `makepkg -g`...
 +
==> Retrieving Sources...
 +
  -> Downloading pandoc-1.6.0.1.tar.gz...
 +
--2011-05-14 07:25:39-- http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz
 +
Resolving hackage.haskell.org... 69.30.63.204
 +
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.
 +
HTTP request sent, awaiting response... 200 OK
 +
Length: 355477 (347K) [application/x-tar]
 +
Saving to: “pandoc-1.6.0.1.tar.gz.part”
 +
 
 +
    0K .......... .......... .......... .......... .......... 14% 210K 1s
 +
    50K .......... .......... .......... .......... .......... 28%  393K 1s
 +
  100K .......... .......... .......... .......... .......... 43%  338K 1s
 +
  150K .......... .......... .......... .......... .......... 57%  419K 0s
 +
  200K .......... .......... .......... .......... .......... 72%  404K 0s
 +
  250K .......... .......... .......... .......... .......... 86%  554K 0s
 +
  300K .......... .......... .......... .......... .......  100%  506K=0.9s
 +
 
 +
2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]
 +
 
 +
==> Generating checksums for source files...
 +
</nowiki>}}
  
 
Checking what was created:
 
Checking what was created:
  
  $ ls
+
  % ls
  haskell-cc-delcont haskell-cc-delcont.tar.gz
+
  haskell-pandoc
 +
% cd haskell-pandoc
 +
% ls
 +
  haskell-pandoc.install PKGBUILD
  
The .tar.gz is a zipped PKGBUILD ready to upload to AUR.
 
 
You can now inspect the PKGBUILD and install script for the library:
 
You can now inspect the PKGBUILD and install script for the library:
  
    # Contributor: Arch Haskell Team <arch-haskell@haskell.org>
+
{{bc|<nowiki>
    # Package generated by cabal2arch 0.6.1
+
# Maintainer:
    pkgname=haskell-cc-delcont
+
_hkgname=pandoc
    pkgrel=1
+
pkgname=haskell-pandoc
    pkgver=0.2
+
pkgver=1.6.0.1
    pkgdesc="Delimited continuations and dynamically scoped variables"
+
pkgrel=1
    url="http://hackage.haskell.org/package/CC-delcont"
+
pkgdesc="Conversion between markup formats"
    license=('custom:OtherLicense')
+
url="http://hackage.haskell.org/package/${_hkgname}"
    arch=('i686' 'x86_64')
+
license=('GPL')
    makedepends=()
+
arch=('i686' 'x86_64')
    depends=('ghc' 'haskell-cabal')
+
makedepends=()
    options=('strip')
+
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')
    source=(http://hackage.haskell.org/packages/archive/CC-delcont/0.2/CC-delcont-0.2.tar.gz)
+
options=('strip')
    install=haskell-cc-delcont.install
+
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
    md5sums=('e52149fca9bf76330a7c159917152790')
+
install=${pkgname}.install
    build() {
+
md5sums=('d19a630462595941b3100dff6f839aa3')
        cd ${srcdir}/CC-delcont-0.2
+
build() {
        runhaskell Setup configure --prefix=/usr --docdir=/usr/share/doc/${pkgname} || return 1
+
    cd ${srcdir}/${_hkgname}-${pkgver}
        runhaskell Setup build                   || return 1
+
    runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --enable-split-objs --enable-shared \
        runhaskell Setup haddock || return 1
+
      --prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid
        runhaskell Setup register  --gen-script || return 1
+
    runhaskell Setup build
        runhaskell Setup unregister --gen-script || return 1
+
    runhaskell Setup haddock
        install -D -m744 register.sh  ${pkgdir}/usr/share/haskell/$pkgname/register.sh
+
    runhaskell Setup register  --gen-script
        install    -m744 unregister.sh ${pkgdir}/usr/share/haskell/$pkgname/unregister.sh
+
    runhaskell Setup unregister --gen-script
        install -d -m755 $pkgdir/usr/share/doc/ghc/libraries
+
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
        ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/libraries/CC-delcont
+
}
        runhaskell Setup copy --destdir=${pkgdir} || return 1
+
package() {
        install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/$pkgname/LICENSE || return 1
+
    cd ${srcdir}/${_hkgname}-${pkgver}
        rm -f ${pkgdir}/usr/share/doc/${pkgname}/LICENSE
+
    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/html/libraries
 +
    ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}
 +
    runhaskell Setup copy --destdir=${pkgdir}
 +
}
 +
</nowiki>}}
  
 
It follows the conventions for Haskell packages:
 
It follows the conventions for Haskell packages:
  
* Maintainer is by default the Arch Haskell team.
+
* Libraries are prefixed with {{ic|haskell-}}
* Libraries are prefixed with "haskell-"
+
* All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the {{pkg|ghc}} package provide them)
* "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.
 
* It uses cabal to generate a post-install register/unregister script, with a standard name.
 
* We use haddock to build the documentation.
 
* 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
+
All Haskell libraries should follow these naming conventions, and using the latest release of cabal2arch will ensure this is the case.
will ensure this is the case.
+
  
Inspect the bundle, and confirm you can build and install it:
+
{{Note|Beginning with {{AUR|cabal2arch}} 1.1-2, a new environment variable, {{ic|PKGBUILD_HASKELL_ENABLE_PROFILING}}, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as {{ic|~/.bashrc}} or {{ic|~/.zshrc}}.}}
 
+
    $ makepkg -s
+
    $ makepkg -i
+
 
+
And we're ready to go. Now your .tar.gz is ready to upload to AUR.
+
 
+
=== "Provides" ===
+
 
+
[http://haskell.org/haskellwiki/Arch_Linux/Preferred_Package_Tools 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===
 
===Guidelines for Libraries===
 
 
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:
 
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:
  
* libraries have their cabal names prefixed with "haskell-"
+
* libraries have their cabal names prefixed with {{ic|haskell-}}
* all haskell dependencies are statically linked, so can go in the makedepends field.
+
* all libraries have a dependency on {{pkg|ghc}}
* all libraries have a dependency on 'ghc'
+
* all libraries that are depended on must be listed in the {{ic|depends}} array in the PKGBUILD
* 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 {{pkg|gtk2hs}} package, not , e.g. "haskell-cairo"
* 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
+
Registering Haskell libraries is done via a register hook, see above.
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 ===
 
===Guidelines for Programs ===
 +
* Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install
  
* Have their normal name. Examples:
+
* Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time 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.
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 [http://aur.archlinux.org/packages.php?O=0&L=0&C=0&K=haskell&SB=v&SO=d&PP=100&SeB=nd&do_Orphans= > 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*
+
* Use executable stripping, {{ic|--enable-executable-stripping}}. cabal2arch will do this automatically.
    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
+
== Haskell Build Order ==
 +
* haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib

Revision as of 20:44, 25 October 2012

Template:Package Guidelines

Haskell is well supported on Arch Linux, with GHC and other key tools available via the official repositories, a growing number of packages made available by the ArchHaskell group, and a large part of hackage.haskell.org's library database available in the AUR. The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.

The community around Haskell on Arch is dying but in the process of revival, so your help is especially welcome!

Community

All the details on the ArchHaskell group is available on its own page.

Haskell Packages

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

[extra]

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

[community]

[community] provides additional packages that are popular and not part of the Haskell platform, such as xmonad. These packages are also provided by the [haskell] repo below. So, if you just want to use a few popular packages, you can just use what is provided by the official Arch repos. But if you want to use Haskell more seriously, read on.

[haskell]

The [haskell] repository is the official repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to /etc/pacman.conf:

[haskell]
Server = http://xsounds.org/~haskell/$arch

The set of packages in the [haskell] repository is derived from the habs tree officially located here. A tool called cblrepo is used to keep the habs tree synchronized with the official Haskell packages from Hackage.

Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.

[haskell-extra] and [haskell-web]

We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository. The first test towards this is habs-extra, which is also provided as a repository to be added to /etc/pacman.conf:

[haskell-extra]
Server = http://archhaskell.mynerdside.com/$repo/$arch

This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell]. More details are available in this message, and in the README on github.

There is also [haskell-web], as mentioned here.

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 like regular AUR packages.

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

Unfortunately, many of the packages in the AUR are outdated due to a lack of resources. In practice, one could use the cabal2arch program to create PKGBUILDs directly from Hackage. But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.

Guidelines

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: this and remaining sections may be out of date given the move to distributed repositories (Discuss in Talk:Haskell package 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 the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:

  • Add the [haskell] repository to /etc/pacman.conf and use pacman to install the latest release.
  • Download and build the cabal2archAUR package from the AUR.
  • Install directly from Hackage using cabal install cabal2arch.

cabal2arch: an example

This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:

First, set the name and email address to be used in the generated PKGBUILD:

export ARCH_HASKELL='My Name <my.name@domain.org>'

Second, find the hackage page for Pandoc, 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/pandoc/1.6.0.1/pandoc.cabal
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal
Feeding the PKGBUILD to `makepkg -g`...
==> Retrieving Sources...
  -> Downloading pandoc-1.6.0.1.tar.gz...
--2011-05-14 07:25:39--  http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz
Resolving hackage.haskell.org... 69.30.63.204
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 355477 (347K) [application/x-tar]
Saving to: “pandoc-1.6.0.1.tar.gz.part”

     0K .......... .......... .......... .......... .......... 14%  210K 1s
    50K .......... .......... .......... .......... .......... 28%  393K 1s
   100K .......... .......... .......... .......... .......... 43%  338K 1s
   150K .......... .......... .......... .......... .......... 57%  419K 0s
   200K .......... .......... .......... .......... .......... 72%  404K 0s
   250K .......... .......... .......... .......... .......... 86%  554K 0s
   300K .......... .......... .......... .......... .......   100%  506K=0.9s

2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]

==> Generating checksums for source files...

Checking what was created:

% ls
haskell-pandoc
% cd haskell-pandoc
% ls
haskell-pandoc.install	PKGBUILD

You can now inspect the PKGBUILD and install script for the library:

# Maintainer: 
_hkgname=pandoc
pkgname=haskell-pandoc
pkgver=1.6.0.1
pkgrel=1
pkgdesc="Conversion between markup formats"
url="http://hackage.haskell.org/package/${_hkgname}"
license=('GPL')
arch=('i686' 'x86_64')
makedepends=()
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')
options=('strip')
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
install=${pkgname}.install
md5sums=('d19a630462595941b3100dff6f839aa3')
build() {
    cd ${srcdir}/${_hkgname}-${pkgver}
    runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --enable-split-objs --enable-shared \
       --prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid
    runhaskell Setup build
    runhaskell Setup haddock
    runhaskell Setup register   --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}
package() {
    cd ${srcdir}/${_hkgname}-${pkgver}
    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/html/libraries
    ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}
    runhaskell Setup copy --destdir=${pkgdir}
}

It follows the conventions for Haskell packages:

  • Libraries are prefixed with haskell-
  • All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the ghc package provide them)
  • It uses cabal to generate a post-install register/unregister script, with a standard name.
  • We use haddock to build the documentation.

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

Note: Beginning with cabal2archAUR 1.1-2, a new environment variable, PKGBUILD_HASKELL_ENABLE_PROFILING, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as ~/.bashrc or ~/.zshrc.

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 libraries have a dependency on ghc
  • all libraries that are depended on must be listed in the depends array in the PKGBUILD
  • be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the gtk2hs package, not , e.g. "haskell-cairo"

Registering Haskell libraries is done via a register hook, see above.

Guidelines for Programs

  • Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install
  • Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time 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 Build Order

  • haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib