9f94d35
#!/bin/sh
9f94d35
9f94d35
VERSION=$1
9f94d35
9f94d35
if [ -z "$VERSION" ]; then
9f94d35
   echo "Usage: $0 X.Y.Z"
9f94d35
   exit 1
9f94d35
fi
9f94d35
70e0f07
#set +x
70e0f07
9f94d35
#FIXME lib
9f94d35
LIBDIR=/usr/lib64/ghc-$VERSION
9f94d35
if [ ! -d "$LIBDIR" ]; then
70e0f07
   echo "$0: $LIBDIR does not exist: please install ghcX.Y first"
9f94d35
   exit 1
9f94d35
fi
9f94d35
9f94d35
# FIXME arch
9f94d35
STACK_PROGRAMS=$HOME/.stack/programs/$(arch)-linux
9f94d35
9f94d35
STACK_GHCDIR=${STACK_PROGRAMS}/ghc-tinfo6-$VERSION
9f94d35
9f94d35
if [ -e "$STACK_GHCDIR" ]; then
70e0f07
   echo "$0: $STACK_GHCDIR exists: to replace, please remove first"
70e0f07
   exit 0
9f94d35
fi
9f94d35
9f94d35
mkdir -p $STACK_GHCDIR/bin
9f94d35
9f94d35
for i in ghc ghc-pkg ghci hp2ps hpc hsc2hs runghc runhaskell; do
9f94d35
    if [ -x /usr/bin/$i-$VERSION ]; then
9f94d35
        ln -s /usr/bin/$i-$VERSION $STACK_GHCDIR/bin/$i
ff63639
    elif [ -x /usr/bin/$i-ghc-$VERSION ]; then
ff63639
        ln -s /usr/bin/$i-ghc-$VERSION $STACK_GHCDIR/bin/$i
9f94d35
    else
9f94d35
        ln -s /usr/bin/$i $STACK_GHCDIR/bin/$i
9f94d35
    fi
9f94d35
done
9f94d35
9f94d35
ln -s /usr/bin/haddock-ghc-$VERSION $STACK_GHCDIR/bin/haddock
9f94d35
9f94d35
if [ ! -f "${STACK_GHCDIR}.installed" ]; then
9f94d35
    echo "installed" > $STACK_GHCDIR.installed
9f94d35
fi