2020-10-07 13:49:40 +05:00
|
|
|
#!/bin/bash -e
|
2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
|
|
|
|
## File: haskell.sh
|
|
|
|
|
## Desc: Installs Haskell
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
# Source the helpers for use with the script
|
2020-07-31 11:16:12 +00:00
|
|
|
source $HELPER_SCRIPTS/etc-environment.sh
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2021-02-19 10:20:15 +03:00
|
|
|
# Any nonzero value for noninteractive installation
|
|
|
|
|
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
|
|
|
|
|
export GHCUP_INSTALL_BASE_PREFIX=/usr/local
|
|
|
|
|
export BOOTSTRAP_HASKELL_GHC_VERSION=0
|
|
|
|
|
ghcup_bin=$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin
|
|
|
|
|
setEtcEnvironmentVariable "BOOTSTRAP_HASKELL_NONINTERACTIVE" $BOOTSTRAP_HASKELL_NONINTERACTIVE
|
|
|
|
|
|
2019-12-13 09:48:00 -05:00
|
|
|
# Install Herbert V. Riedel's PPA for managing multiple version of ghc on ubuntu.
|
|
|
|
|
# https://launchpad.net/~hvr/+archive/ubuntu/ghc
|
|
|
|
|
apt-get install -y software-properties-common
|
|
|
|
|
add-apt-repository -y ppa:hvr/ghc
|
|
|
|
|
apt-get update
|
|
|
|
|
|
2021-02-19 10:20:15 +03:00
|
|
|
# Install GHCup
|
|
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh > /dev/null 2>&1 || true
|
|
|
|
|
export PATH="$ghcup_bin:$PATH"
|
|
|
|
|
prependEtcEnvironmentPath $ghcup_bin
|
|
|
|
|
|
2021-02-13 09:22:36 +03:00
|
|
|
# Get 2 latest Haskell Major.Minor versions
|
2020-05-29 14:38:59 +03:00
|
|
|
allGhcVersions=$(apt-cache search "^ghc-" | grep -Po '(\d*\.){2}\d*' | sort --unique --version-sort)
|
2021-02-13 09:22:36 +03:00
|
|
|
ghcMajorMinorVersions=$(echo "$allGhcVersions" | cut -d "." -f 1,2 | sort --unique --version-sort | tail -2)
|
2020-05-29 14:38:59 +03:00
|
|
|
|
2021-02-19 10:20:15 +03:00
|
|
|
# We are using apt-get to install ghc, not ghcup,
|
|
|
|
|
# because ghc installed through ghcup takes up too much disk space (2GB versus 1GB through apt-get)
|
2020-05-29 14:38:59 +03:00
|
|
|
for version in $ghcMajorMinorVersions; do
|
|
|
|
|
# Get latest patch version for given Major.Minor one (ex. 8.6.5 for 8.6) and install it
|
|
|
|
|
exactVersion=$(echo "$allGhcVersions" | grep $version | sort --unique --version-sort | tail -1)
|
|
|
|
|
apt-get install -y ghc-$exactVersion
|
|
|
|
|
ghcInstalledVersions+=("$exactVersion")
|
2020-07-31 11:16:12 +00:00
|
|
|
defaultGHCVersion=$exactVersion
|
2020-05-26 18:45:48 +03:00
|
|
|
done
|
|
|
|
|
|
2021-02-19 10:20:15 +03:00
|
|
|
echo "install cabal..."
|
|
|
|
|
ghcup install cabal
|
2020-05-29 14:38:59 +03:00
|
|
|
|
2021-02-19 10:20:15 +03:00
|
|
|
chmod -R 777 $GHCUP_INSTALL_BASE_PREFIX/.ghcup
|
|
|
|
|
ln -s $GHCUP_INSTALL_BASE_PREFIX/.ghcup /etc/skel/.ghcup
|
|
|
|
|
ln -s "/opt/ghc/$defaultGHCVersion/bin/ghc" "/usr/bin/ghc"
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2020-05-12 11:48:39 -04:00
|
|
|
# Install the latest stable release of haskell stack
|
|
|
|
|
curl -sSL https://get.haskellstack.org/ | sh
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2021-04-28 16:51:16 +05:00
|
|
|
# remove PPA repo
|
|
|
|
|
echo "ghc ppa:hvr/ghc" >> $HELPER_SCRIPTS/apt-sources.txt
|
|
|
|
|
add-apt-repository --remove ppa:hvr/ghc
|
|
|
|
|
|
|
|
|
|
invoke_tests "Haskell"
|