diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index c5abd8ed8..b1fb23e98 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -275,8 +275,7 @@ function Build-PHPSection { function Get-GHCVersion { $(ghc --version) -match "version (?\d+\.\d+\.\d+)" | Out-Null $ghcVersion = $Matches.version - $aptSourceRepo = Get-AptSourceRepository -PackageName "ghc" - return "GHC $ghcVersion (apt source repository: $aptSourceRepo)" + return "GHC $ghcVersion" } function Get-GHCupVersion { diff --git a/images/linux/scripts/installers/haskell.sh b/images/linux/scripts/installers/haskell.sh index 2ab93c78a..08c016cbd 100644 --- a/images/linux/scripts/installers/haskell.sh +++ b/images/linux/scripts/installers/haskell.sh @@ -14,29 +14,29 @@ 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) +availableVersions=$(ghcup list -t ghc -r | grep -v "prerelease" | awk '{print $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) - apt-get install -y ghc-$exactVersion - ghcInstalledVersions+=("$exactVersion") - defaultGHCVersion=$exactVersion +# Get 2 latest Haskell Major.Minor versions +minorMajorVersions=$(echo "$availableVersions" | cut -d"." -f 1,2 | uniq | tail -n2) +for majorMinorVersion in $minorMajorVersions; do + fullVersion=$(echo "$availableVersions" | grep "$majorMinorVersion." | tail -n1) + echo "install ghc version $fullVersion..." + ghcup install ghc $fullVersion + ghcup set ghc $fullVersion + + # 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 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 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" diff --git a/images/linux/scripts/tests/Haskell.Tests.ps1 b/images/linux/scripts/tests/Haskell.Tests.ps1 index b271cf726..21706bd86 100644 --- a/images/linux/scripts/tests/Haskell.Tests.ps1 +++ b/images/linux/scripts/tests/Haskell.Tests.ps1 @@ -1,8 +1,7 @@ Describe "Haskell" { - - $GHCCommonPath = "/opt/ghc" + $GHCCommonPath = "/usr/local/.ghcup/ghc" $GHCVersions = Get-ChildItem -Path $GHCCommonPath | Where-Object { $_.Name -match "\d+\.\d+" } - + $testCase = @{ GHCVersions = $GHCVersions } It "GHC directory contains two version of GHC" -TestCases $testCase { @@ -32,4 +31,4 @@ Describe "Haskell" { It "Stack" { "stack --version" | Should -ReturnZeroExitCode } -} \ No newline at end of file +}