Files
runner-images/images/windows/scripts/build/Install-Miniconda.ps1
Vasilii Polikarpov 5ed2615017 [Windows] Cleanup various scripts (#8942)
* Use Resolve-GithubReleaseAssetUrl more widely

* Add the Get-ChecksumFromUrl function

* Sort exported functions and add docs

* Remove alias and fix typo

* Fix kind checksum url and syntax

* Fix checksums url for gh cli and msys2

* [Windows] Cleanup various scripts

* Add spaces after type specifications

* Rename the Take-Part function
2023-12-04 10:50:53 +01:00

33 lines
1.2 KiB
PowerShell

################################################################################
## File: Install-Miniconda.ps1
## Desc: Install the latest version of Miniconda and set $env:CONDA
## Supply chain security: checksum validation
################################################################################
$CondaDestination = "C:\Miniconda"
$InstallerName = "Miniconda3-latest-Windows-x86_64.exe"
#region Supply chain security
$distributorFileHash = $null
$checksums = (Invoke-RestMethod -Uri 'https://repo.anaconda.com/miniconda/' | ConvertFrom-HTML).SelectNodes('//html/body/table/tr')
foreach ($node in $checksums) {
if ($node.ChildNodes[1].InnerText -eq $InstallerName) {
$distributorFileHash = $node.ChildNodes[7].InnerText
}
}
if ($null -eq $distributorFileHash) {
throw "Unable to find checksum for $InstallerName in https://repo.anaconda.com/miniconda/"
}
#endregion
Install-Binary `
-Url "https://repo.anaconda.com/miniconda/${InstallerName}" `
-InstallArgs @("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestination") `
-ExpectedSHA256Sum $distributorFileHash
[Environment]::SetEnvironmentVariable("CONDA", $CondaDestination, "Machine")
Invoke-PesterTests -TestFile "Miniconda"