cabal-heroku-buildpack/bin/compile
2012-04-13 14:38:07 +02:00

62 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# bin/compile BUILD_DIR CACHE_DIR
set -e
source $(dirname $0)/../scripts/functions
BUILD_DIR=$1
loginfo "BUILD_DIR=$BUILD_DIR"
CACHE_DIR=$2
loginfo "CACHE_DIR=$CACHE_DIR"
## CHECK BUILDPACK_GHC_BASE_URL is set
setIfUnset BUILDPACK_GHC_BASE_URL "http://www.haskell.org/ghc/dist"
setIfUnset GHC_BOOTSTRAP_VERSION "7.0.4"
setIfUnset HASKELL_PLATFORM_BASE_URL "http://lambda.haskell.org/platform/download"
setIfUnset HASKELL_PLATFORM_VERSION "2011.4.0.0"
arch=$(uname -m)
ghcver=$GHC_BOOTSTRAP_VERSION
bsdir=$CACHE_DIR/bootstrap
ghcurl="$BUILDPACK_GHC_BASE_URL/$ghcver/ghc-$ghcver-$arch-unknown-linux.tar.bz2"
platformver="$HASKELL_PLATFORM_VERSION"
platformurl="$HASKELL_PLATFORM_BASE_URL/$platformver/haskell-platform-$platformver.tar.gz"
loginfo "bootstrap directory: ${bsdir}";
loginfo "bootstrap URL: $ghcurl";
if [ -f "$bsdir.ghc.downloaded" ]; then
loginfo "already downloaded GHC bootstrap version ${ghcver}";
else
loginfo "downloading GHC $ghcver from $ghcurl";
$(downloadAndExtract $bsdir $ghcurl) && \
touch $bsdir.ghc.downloaded;
fi
# GHC source is downloaded
if [ -f "$bsdir.ghc.compiled" ]; then
loginfo "already compiled GHC bootstrap version ${ghcver}";
else
$(configureMakeInstall $bsdir/ghc-$ghcver $BUILD_DIR/bootstrap/ghc-$ghcver) && \
touch $bsdir.ghc.compiled;
fi
# GHC is compiled
if [ -f "$bsdir.platform.downloaded" ]; then
loginfo "already downloaded GHC bootstrap version ${platformver}";
else
loginfo "downloading Haskell Platform $platformver from $platformurl";
$(downloadAndExtract $bsdir $platformurl) && \
touch $bsdir.platform.downloaded;
fi
# Haskell Platform source is downloaded
if [ -f "$bsdir.platform.compiled" ]; then
loginfo "already compiled GHC bootstrap version ${platformver}";
else
$(configureMakeInstall $bsdir/haskell-platform-$platformver $BUILD_DIR/bootstrap/haskell-platform-$platformver) && \
touch $bsdir.platform.compiled;
fi
# Haskell platform is compiled is compiled