mirror of
https://github.com/actions/runner-images.git
synced 2025-12-13 12:48:18 +00:00
Use ghcup to install GHC on linux and remove docs and profiling libs (#4043)
This commit is contained in:
@@ -275,8 +275,7 @@ function Build-PHPSection {
|
|||||||
function Get-GHCVersion {
|
function Get-GHCVersion {
|
||||||
$(ghc --version) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
$(ghc --version) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||||
$ghcVersion = $Matches.version
|
$ghcVersion = $Matches.version
|
||||||
$aptSourceRepo = Get-AptSourceRepository -PackageName "ghc"
|
return "GHC $ghcVersion"
|
||||||
return "GHC $ghcVersion (apt source repository: $aptSourceRepo)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-GHCupVersion {
|
function Get-GHCupVersion {
|
||||||
|
|||||||
@@ -14,29 +14,29 @@ export BOOTSTRAP_HASKELL_GHC_VERSION=0
|
|||||||
ghcup_bin=$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin
|
ghcup_bin=$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin
|
||||||
setEtcEnvironmentVariable "BOOTSTRAP_HASKELL_NONINTERACTIVE" $BOOTSTRAP_HASKELL_NONINTERACTIVE
|
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
|
# Install GHCup
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh > /dev/null 2>&1 || true
|
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh > /dev/null 2>&1 || true
|
||||||
export PATH="$ghcup_bin:$PATH"
|
export PATH="$ghcup_bin:$PATH"
|
||||||
prependEtcEnvironmentPath $ghcup_bin
|
prependEtcEnvironmentPath $ghcup_bin
|
||||||
|
|
||||||
# Get 2 latest Haskell Major.Minor versions
|
availableVersions=$(ghcup list -t ghc -r | grep -v "prerelease" | awk '{print $2}')
|
||||||
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,
|
# Get 2 latest Haskell Major.Minor versions
|
||||||
# because ghc installed through ghcup takes up too much disk space (2GB versus 1GB through apt-get)
|
minorMajorVersions=$(echo "$availableVersions" | cut -d"." -f 1,2 | uniq | tail -n2)
|
||||||
for version in $ghcMajorMinorVersions; do
|
for majorMinorVersion in $minorMajorVersions; do
|
||||||
# Get latest patch version for given Major.Minor one (ex. 8.6.5 for 8.6) and install it
|
fullVersion=$(echo "$availableVersions" | grep "$majorMinorVersion." | tail -n1)
|
||||||
exactVersion=$(echo "$allGhcVersions" | grep $version | sort --unique --version-sort | tail -1)
|
echo "install ghc version $fullVersion..."
|
||||||
apt-get install -y ghc-$exactVersion
|
ghcup install ghc $fullVersion
|
||||||
ghcInstalledVersions+=("$exactVersion")
|
ghcup set ghc $fullVersion
|
||||||
defaultGHCVersion=$exactVersion
|
|
||||||
|
# remove docs and profiling libs
|
||||||
|
ghc_bin_dir="$(ghcup whereis --directory ghc $fullVersion)"
|
||||||
|
[ -e "${ghc_bin_dir}" ] || exit 1
|
||||||
|
ghc_dir="$(realpath "${ghc_bin_dir}"/..)"
|
||||||
|
[ -e "${ghc_dir}" ] || exit 1
|
||||||
|
find "${ghc_dir}" \( -name "*_p.a" -o -name "*.p_hi" \) -type f -delete
|
||||||
|
rm -r "${ghc_dir}"/share/*
|
||||||
|
unset ghc_bin_dir ghc_dir
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "install cabal..."
|
echo "install cabal..."
|
||||||
@@ -49,8 +49,4 @@ 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
|
||||||
|
|
||||||
# remove PPA repo
|
|
||||||
echo "ghc ppa:hvr/ghc" >> $HELPER_SCRIPTS/apt-sources.txt
|
|
||||||
add-apt-repository --remove ppa:hvr/ghc
|
|
||||||
|
|
||||||
invoke_tests "Haskell"
|
invoke_tests "Haskell"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
Describe "Haskell" {
|
Describe "Haskell" {
|
||||||
|
$GHCCommonPath = "/usr/local/.ghcup/ghc"
|
||||||
$GHCCommonPath = "/opt/ghc"
|
|
||||||
$GHCVersions = Get-ChildItem -Path $GHCCommonPath | Where-Object { $_.Name -match "\d+\.\d+" }
|
$GHCVersions = Get-ChildItem -Path $GHCCommonPath | Where-Object { $_.Name -match "\d+\.\d+" }
|
||||||
|
|
||||||
$testCase = @{ GHCVersions = $GHCVersions }
|
$testCase = @{ GHCVersions = $GHCVersions }
|
||||||
|
|||||||
Reference in New Issue
Block a user