Source

builders / haskell

Full commit
#!/usr/bin/env python

import os
import os.path
from build import *

apt_get(['libglut3-dev', 'libeditline-dev', 'libedit-dev', 'libgmp3-dev'])

# Installing GHC from source requires a working GHC (unless you go
# through an awful bootstrapping process meant for porting to new
# platforms), so instead we just grab a binary distribution. This
# means we need to figure out the correct binary distribution first.
if machine.os_name == 'linux':
    if machine.bits == 32:
        tarball = 'ghc-6.12.1-i386-unknown-linux-n.tar.bz2'
    else:
        tarball = 'ghc-6.12.1-x86_64-unknown-linux-n.tar.bz2'
else:
    error('OS not supported by the haskell builder: ' + machine.os_name)

# Destroy old GHC/Cabal information, if any
rmtree(clean('~/.ghc'))
rmtree(clean('~/.cabal'))

# Install GHC
dir = init('http://haskell.org/ghc/dist/6.12.1/' + tarball, 'ghc-6.12.1.tar.bz2')
call([join(dir, 'configure'), '--prefix=' + INSTALL_DIR], cwd=dir)
call(['make', 'install'], cwd=dir)

# Configure cabal to install things to the local prefix.
mkdir(clean('~/.cabal'))
config = open(clean('~/.cabal/config'), 'w').write('''
remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: %s
build-summary: %s
remote-build-reporting: anonymous
library-vanilla: True
library-profiling: True
documentation: True

install-dirs user
  prefix: %s

install-dirs global
  prefix: %s
''' % (clean('~/.cabal/packages'),
       clean('~/.cabal/logs/build.log'),
       INSTALL_DIR,
       INSTALL_DIR))

dir = configure_make_install('http://hackage.haskell.org/platform/2010.1.0.0/'
                             'haskell-platform-2010.1.0.0.tar.gz')

# Update the package list to finalize the platform installation process.
call([join(INSTALL_DIR, 'bin/cabal'), 'update'], cwd='/')