mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 13:17:54 +00:00
[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:
@@ -219,6 +219,12 @@ function Get-GHCVersion {
|
|||||||
return "GHC $ghcVersion"
|
return "GHC $ghcVersion"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Get-GHCupVersion {
|
||||||
|
$(ghcup --version) -match "version v(?<version>\d+(\.\d+){2,})" | Out-Null
|
||||||
|
$ghcVersion = $Matches.version
|
||||||
|
return "GHCup $ghcVersion"
|
||||||
|
}
|
||||||
|
|
||||||
function Get-CabalVersion {
|
function Get-CabalVersion {
|
||||||
$(cabal --version | Out-String) -match "cabal-install version (?<version>\d+\.\d+\.\d+\.\d+)" | Out-Null
|
$(cabal --version | Out-String) -match "cabal-install version (?<version>\d+\.\d+\.\d+\.\d+)" | Out-Null
|
||||||
$cabalVersion = $Matches.version
|
$cabalVersion = $Matches.version
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ $markdown += New-MDNewLine
|
|||||||
$markdown += New-MDHeader "Haskell" -Level 3
|
$markdown += New-MDHeader "Haskell" -Level 3
|
||||||
$markdown += New-MDList -Style Unordered -Lines (@(
|
$markdown += New-MDList -Style Unordered -Lines (@(
|
||||||
(Get-GHCVersion),
|
(Get-GHCVersion),
|
||||||
|
(Get-GHCupVersion),
|
||||||
(Get-CabalVersion),
|
(Get-CabalVersion),
|
||||||
(Get-StackVersion)
|
(Get-StackVersion)
|
||||||
) | Sort-Object
|
) | Sort-Object
|
||||||
|
|||||||
@@ -7,16 +7,30 @@
|
|||||||
# Source the helpers for use with the script
|
# Source the helpers for use with the script
|
||||||
source $HELPER_SCRIPTS/etc-environment.sh
|
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.
|
# 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
|
||||||
apt-get install -y software-properties-common
|
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 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
|
# Get 2 latest Haskell Major.Minor versions
|
||||||
allGhcVersions=$(apt-cache search "^ghc-" | grep -Po '(\d*\.){2}\d*' | sort --unique --version-sort)
|
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)
|
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
|
for version in $ghcMajorMinorVersions; do
|
||||||
# Get latest patch version for given Major.Minor one (ex. 8.6.5 for 8.6) and install it
|
# 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)
|
exactVersion=$(echo "$allGhcVersions" | grep $version | sort --unique --version-sort | tail -1)
|
||||||
@@ -25,16 +39,14 @@ for version in $ghcMajorMinorVersions; do
|
|||||||
defaultGHCVersion=$exactVersion
|
defaultGHCVersion=$exactVersion
|
||||||
done
|
done
|
||||||
|
|
||||||
# Get latest cabal version
|
echo "install cabal..."
|
||||||
cabalVersion=$(apt-cache search cabal-install-[0-9] | grep -Po '\d*\.\d*' | sort --unique --version-sort | tail -1)
|
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
|
# Install the latest stable release of haskell stack
|
||||||
curl -sSL https://get.haskellstack.org/ | sh
|
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"
|
invoke_tests "Haskell"
|
||||||
@@ -17,6 +17,10 @@ Describe "Haskell" {
|
|||||||
"$GHCPath --version" | Should -ReturnZeroExitCode
|
"$GHCPath --version" | Should -ReturnZeroExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It "GHCup" {
|
||||||
|
"ghcup --version" | Should -ReturnZeroExitCode
|
||||||
|
}
|
||||||
|
|
||||||
It "Default GHC" {
|
It "Default GHC" {
|
||||||
"ghc --version" | Should -ReturnZeroExitCode
|
"ghc --version" | Should -ReturnZeroExitCode
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user