[Ubuntu] Rework haskell.sh to install Cabal using GHCup (#2636)

* reworked haskell installation

* added comment

* resolved comments and added symlink

* fixed haskell.sh

* update haskell.sh

* update installation

* added error suppressing

* reverted ghc intallation

* added comments

Co-authored-by: Nikita Bykov <v-nibyko@microsoft.com>
This commit is contained in:
Nikita Bykov
2021-02-19 10:20:15 +03:00
committed by GitHub
parent c881c3cab7
commit 2c96d280ed
4 changed files with 30 additions and 7 deletions

View File

@@ -7,16 +7,30 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
# 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
# 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
# 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
# Get 2 latest Haskell Major.Minor versions
allGhcVersions=$(apt-cache search "^ghc-" | grep -Po '(\d*\.){2}\d*' | sort --unique --version-sort)
ghcMajorMinorVersions=$(echo "$allGhcVersions" | cut -d "." -f 1,2 | sort --unique --version-sort | tail -2)
# 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)
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)
@@ -25,16 +39,14 @@ for version in $ghcMajorMinorVersions; do
defaultGHCVersion=$exactVersion
done
# Get latest cabal version
cabalVersion=$(apt-cache search cabal-install-[0-9] | grep -Po '\d*\.\d*' | sort --unique --version-sort | tail -1)
echo "install cabal..."
ghcup install cabal
apt-get install -y cabal-install-$cabalVersion
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"
# Install the latest stable release of haskell stack
curl -sSL https://get.haskellstack.org/ | sh
# Create symlink for ghc and cabal in /usr/bin
ln -s "/opt/ghc/$defaultGHCVersion/bin/ghc" "/usr/bin/ghc"
ln -s "/opt/cabal/$cabalVersion/bin/cabal" "/usr/bin/cabal"
invoke_tests "Haskell"