Created
May 22, 2015 07:50
-
-
Save kowey/07f595dccba25f6346b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
shopt -s nullglob | |
ARCH=$(uname -m) | |
if [ "$ARCH" != "x86_64" ]; then | |
echo >&2 "Sorry, need a 64 bit system" | |
exit 1 | |
fi | |
GHC_VERSION=7.8.4 | |
WXWIDGETS_VERSION=2.9.5 | |
GHC_DIST=ghc-${GHC_VERSION} | |
HASKELL_PLATFORM_VERSION=2014.2.0.0 | |
HASKELL_PLATFORM_DIST=haskell-platform-${HASKELL_PLATFORM_VERSION} | |
WXWIDGETS_DIST=wxWidgets-${WXWIDGETS_VERSION} | |
GHC_TARBALL=$GHC_DIST-$ARCH-unknown-linux-deb7.tar.bz2 | |
HASKELL_PLATFORM_TARBALL=$HASKELL_PLATFORM_DIST-unknown-linux-$ARCH.tar.gz | |
WXWIDGETS_TARBALL=$WXWIDGETS_DIST.tar.bz2 | |
sleep_until_exists () { | |
echo >&2 "Waiting until we've finished downloading $1..." | |
while [ ! -e "$1" ]; do | |
sleep 1 | |
done | |
} | |
fetch_bg () { | |
LOGDIR=$1 | |
URL=$2 | |
DEST=$3 | |
(wget "$URL" -o "$LOGDIR/fetch-$DEST" -O "$DEST.download" && mv "$DEST.download" "$DEST") & | |
} | |
ghc --version | |
if [ $? -ne 127 ]; then | |
echo >&2 "Hmm, GHC already exists on your system. Cowardly exiting, sorry." | |
echo >&2 "If it's out of date (we want $GHC_VERSION), you'll want to remove it" | |
exit 1 | |
fi | |
geni --version | |
if [ $? -ne 127 ]; then | |
echo >&2 "Hmm, geni already exists on your system. Cowardly exiting, sorry." | |
exit 1 | |
fi | |
wx-config --version | |
if [ $? -ne 127 ]; then | |
echo >&2 "Hmm, wxWidgets already exists on your system. Cowardly exiting, sorry." | |
exit 1 | |
fi | |
wxdirect --version | |
if [ $? -ne 127 ]; then | |
echo >&2 "Hmm, wxdirect already exists on your system. Cowardly exiting, sorry." | |
exit 1 | |
fi | |
# Neat sudo keep-alive trick from | |
# https://gist.github.com/cowboy/3118588 | |
# Might as well ask for password up-front, right? | |
sudo -v | |
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing. | |
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & | |
set -e | |
# I'm not sure if the version of the Haskell Platform (2012.1.0.0) is | |
# recent enough for GenI 0.24.x, so I'm going to assume you need to get | |
# a later version | |
sudo apt-get install stow wget git | |
sudo apt-get install libgmp3-dev libgmp10 # needed for GHC | |
sudo apt-get install freeglut3 freeglut3-dev zlib1g-dev | |
sudo apt-get install libssl-dev # needed for http-stream (used by geni-util) | |
sudo apt-get install gtk+2.0 # needed for wxWidgets (used by geni-gui) | |
sudo apt-get install graphviz | |
T=/tmp/geni-install-$(date +%Y-%m-%d) | |
mkdir -p "$T" | |
mkdir -p "$T/log" | |
cd "$T" | |
# fork off a bunch of downloads | |
fetch_bg "$T/log"\ | |
"http://www.haskell.org/ghc/dist/$GHC_VERSION/$GHC_TARBALL"\ | |
"$GHC_TARBALL" | |
fetch_bg "$T/log"\ | |
"https://www.haskell.org/platform/download/$HASKELL_PLATFORM_VERSION/$HASKELL_PLATFORM_TARBALL"\ | |
"$HASKELL_PLATFORM_TARBALL" | |
fetch_bg "$T/log"\ | |
"https://sourceforge.net/projects/wxwindows/files/$WXWIDGETS_VERSION/$WXWIDGETS_TARBALL/download"\ | |
"$WXWIDGETS_TARBALL" | |
echo >&2 '**************************************************' | |
echo >&2 'Installing GHC' | |
echo >&2 '**************************************************' | |
sleep_until_exists $GHC_TARBALL | |
tar xjvf $GHC_TARBALL | |
pushd $GHC_DIST | |
./configure --prefix /usr/local/stow/$GHC_DIST | |
sudo make install | |
cd /usr/local/stow | |
sudo stow $GHC_DIST | |
popd | |
echo >&2 '**************************************************' | |
echo >&2 'Installing the Haskell Platform' | |
echo >&2 '**************************************************' | |
sleep_until_exists $HASKELL_PLATFORM_TARBALL | |
tar xzvf $HASKELL_PLATFORM_TARBALL | |
pushd / | |
sudo tar xvf $T/$HASKELL_PLATFORM_TARBALL | |
sudo /usr/local/haskell/ghc-7.8.3-x86-64/bin/activate-hs | |
popd | |
export PATH=$PATH:$HOME/.cabal/bin | |
cabal update | |
echo >&2 '**************************************************' | |
echo >&2 'Installing core GenI' | |
echo >&2 '**************************************************' | |
cabal install GenI | |
echo >&2 '**************************************************' | |
echo >&2 'Installing GenI helper tools' | |
echo >&2 '**************************************************' | |
cabal install geniserver geni-util | |
echo >&2 '*****************************************************************************' | |
echo >&2 'HOORAY! Core GenI some basic utilities installed' | |
echo >&2 'Now the hard part (the GUI). Gulp...' | |
echo >&2 '*****************************************************************************' | |
echo >&2 '**************************************************' | |
echo >&2 'Installing wxWidgets' | |
echo >&2 '**************************************************' | |
sleep_until_exists $WXWIDGETS_TARBALL | |
tar xjvf $WXWIDGETS_TARBALL | |
pushd $WXWIDGETS_DIST | |
./configure --prefix=/usr/local/stow/$WXWIDGETS_DIST | |
make | |
sudo make install | |
cd /usr/local/stow | |
sudo stow $WXWIDGETS_DIST | |
popd | |
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/stow/$WXWIDGETS_DIST/lib | |
echo >&2 '**************************************************' | |
echo >&2 'Installing wxHaskell' | |
echo >&2 '**************************************************' | |
## NB 2012-10-23: the reason we are fetching the git repo is that | |
## my vague belief that 0.90.1.0 doesn't work with the GHC or | |
## Haskell Platform version we want (I may be wrong). | |
## | |
## If a newer release comes out, we should replace this with just | |
## plain old 'cabal install wx' | |
#git clone https://github.com/wxHaskell/wxHaskell.git | |
#pushd wxHaskell | |
##git checkout 2f065e5348343ab95ad3f1465af2619d31bcdf37 # known working version | |
#cabal install ./wxdirect | |
#cabal install ./wxc | |
#cabal install ./wxcore ./wx | |
#popd | |
cabal install wx | |
echo >&2 '**************************************************' | |
echo >&2 'Installing geni-gui' | |
echo >&2 '**************************************************' | |
cabal install geni-gui | |
echo >&2 '*****************************************************************************' | |
echo >&2 'Success! (hopefully)' | |
echo >&2 '' | |
echo >&2 'Now make sure the following is in your .bashrc (or was it .bash_profile?)' | |
echo >&2 '' | |
echo >&2 'export PATH=${PATH}:${HOME}/.cabal/bin' | |
echo >&2 'export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/stow/'$WXWIDGETS_DIST'/lib' | |
echo >&2 '*****************************************************************************' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment