mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
[Ubuntu] Install 3 latest Haskell version and latest Cabal version (#939)
* Remove deprecated versions * add regexp for the latest versions * refactor some checks * change cabal version * change version retrieval to awk * minor comments improvment
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
# Source the helpers for use with the script
|
# Source the helpers for use with the script
|
||||||
source $HELPER_SCRIPTS/document.sh
|
source $HELPER_SCRIPTS/document.sh
|
||||||
source $HELPER_SCRIPTS/os.sh
|
|
||||||
|
|
||||||
# Install Herbert V. Riedel's PPA for managing multiple version of ghc on ubuntu.
|
# Install Herbert V. Riedel's PPA for managing multiple version of ghc on ubuntu.
|
||||||
# https://launchpad.net/~hvr/+archive/ubuntu/ghc
|
# https://launchpad.net/~hvr/+archive/ubuntu/ghc
|
||||||
@@ -14,25 +13,15 @@ apt-get install -y software-properties-common
|
|||||||
add-apt-repository -y ppa:hvr/ghc
|
add-apt-repository -y ppa:hvr/ghc
|
||||||
apt-get update
|
apt-get update
|
||||||
|
|
||||||
# Install various versions of ghc and cabal
|
# Get 3 latest Haskell versions and latest Cabal version
|
||||||
if isUbuntu20 ; then
|
ghcVersions=$(apt-cache search "^ghc-" | grep -Po '(\d*\.){2}\d*' | awk 'BEGIN {FS=OFS=SUBSEP="."}{if (arr[$1,$2] < $3) arr[$1,$2] = $3} END {for (i in arr) print i,arr[i]}' | sort --version-sort | tail -3)
|
||||||
ghcVersions="8.6.5 8.8.3 8.10.1"
|
cabalVersion=$(apt-cache search cabal-install-[0-9] | grep -Po '\d*\.\d*' | sort --unique --version-sort | tail -1)
|
||||||
cabalVersions="3.2"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isUbuntu16 || isUbuntu18 ; then
|
|
||||||
# Install various versions of ghc and cabal
|
|
||||||
ghcVersions="8.0.2 8.2.2 8.4.4 8.6.2 8.6.3 8.6.4 8.6.5 8.8.1 8.8.2 8.8.3 8.10.1"
|
|
||||||
cabalVersions="2.0 2.2 2.4 3.0 3.2"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for version in $ghcVersions; do
|
for version in $ghcVersions; do
|
||||||
apt-get install -y ghc-$version
|
apt-get install -y ghc-$version
|
||||||
done
|
done
|
||||||
|
|
||||||
for version in $cabalVersions; do
|
apt-get install -y cabal-install-$cabalVersion
|
||||||
apt-get install -y cabal-install-$version
|
|
||||||
done
|
|
||||||
|
|
||||||
# Install the latest stable release of haskell stack
|
# Install the latest stable release of haskell stack
|
||||||
curl -sSL https://get.haskellstack.org/ | sh
|
curl -sSL https://get.haskellstack.org/ | sh
|
||||||
@@ -46,13 +35,13 @@ for version in $ghcVersions; do
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# Check all cabal versions
|
|
||||||
for version in $cabalVersions; do
|
# Check cabal
|
||||||
if ! command -v /opt/cabal/$version/bin/cabal; then
|
if ! command -v /opt/cabal/$cabalVersion/bin/cabal; then
|
||||||
echo "cabal $version was not installed"
|
echo "cabal $cabalVersion was not installed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
# Check stack
|
# Check stack
|
||||||
if ! command -v stack; then
|
if ! command -v stack; then
|
||||||
exit 1
|
exit 1
|
||||||
@@ -60,9 +49,7 @@ fi
|
|||||||
|
|
||||||
# Document what was added to the image
|
# Document what was added to the image
|
||||||
echo "Lastly, documenting what we added to the metadata file"
|
echo "Lastly, documenting what we added to the metadata file"
|
||||||
for version in $cabalVersions; do
|
DocumentInstalledItem "Haskell Cabal ($(/opt/cabal/$cabalVersion/bin/cabal --version))"
|
||||||
DocumentInstalledItem "Haskell Cabal ($(/opt/cabal/$version/bin/cabal --version))"
|
|
||||||
done
|
|
||||||
for version in $ghcVersions; do
|
for version in $ghcVersions; do
|
||||||
DocumentInstalledItem "GHC ($(/opt/ghc/$version/bin/ghc --version))"
|
DocumentInstalledItem "GHC ($(/opt/ghc/$version/bin/ghc --version))"
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user