Here is the script.
#!/bin/sh
# mkhslib
# This function should unroll a hackageDB tarball,
# configure it, build it, install it (in a relocatable way)
# and then clean up after itself.
# Assumption1: run in 'msys' environment on windows machine
# Assumption2: User installed GHC with Haskell Platform installer
# Warning: This script assumes there are no spaces in the paths
# used. If there are spaces, then this may break. Space-safe
# mods are welcome. <jfoell@gmail.com>
# Point this variable to the 'lib' directory of your
# Haskell Platform installation
HASKELL_LIB_DIR=$DEVROOT/Haskell_Platform/2011.2.0.0/lib
function print_usage
{
echo USAGE: mkhslib [path/to/]package.tar.gz
echo EXAMPLE: mkhslib ~/downloads/atom-1.0.4.tar.gz
}
# Handle wrong arguments
case $# in
0)
print_usage
exit
esac
# Handle standard help args
if [ $1 = "-h" -o $1 = "--help" ]; then
print_usage
exit
fi
# Unpack, configure, build, install, clean up
PKG_ID=`basename $1 .tar.gz`
STARTDIR=`pwd`
cd `dirname $1`
tar -xzf `basename $1` &&
cd $PKG_ID &&
runhaskell Setup configure --prefix=$HASKELL_LIB_DIR/extralibs &&
runhaskell Setup build &&
runhaskell Setup install &&
cd .. &&
rm -rf $PKG_ID
# Building libraries bakes the absolute path into the conf file,
# which makes the library non-relocatable. This doesn't work with
# our goal to make this repo relocatable. So... we must replace
# the absolute path with the haskell-compiler variable '$topdir'.
SED_SEARCH=`echo $HASKELL_LIB_DIR | sed -e 's%/c/%c:/%'`
sed -i -e "s%$SED_SEARCH%\$topdir%" $HASKELL_LIB_DIR/package.conf.d/$PKG_ID*.conf
ghc-pkg recache
cd "$STARTDIR"
Dear haskell rascals,
In an attempt to create a relocatable repository of development tools, I created this simple script to configure/build/install packages from hackageDB. This script is meant to be used in an 'msys' environment on a windows machine.
To quote the Cabal User's Guide (sec 4.1.2.3)A library cannot (currently) be prefix-independent, because it will be linked into an executable whose file system location bears no relation to the library package
So far, this attempt has been successful for me. Improvements, criticism, and other solutions are welcome. Thanks.
jake