2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
|
|
|
|
## File: Install-Miniconda.ps1
|
|
|
|
|
## Desc: Install the latest version of Miniconda and set $env:CONDA
|
2023-10-11 11:01:06 +02:00
|
|
|
## Supply chain security: checksum validation
|
2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
|
|
|
|
|
2023-12-11 22:23:36 +01:00
|
|
|
$condaDestination = "C:\Miniconda"
|
|
|
|
|
$installerName = "Miniconda3-latest-Windows-x86_64.exe"
|
2020-07-17 15:29:03 +07:00
|
|
|
|
2023-10-11 11:01:06 +02:00
|
|
|
#region Supply chain security
|
|
|
|
|
$distributorFileHash = $null
|
2023-12-14 11:05:36 +01:00
|
|
|
$checksums = (ConvertFrom-HTML -Uri 'https://repo.anaconda.com/miniconda/').SelectNodes('//html/body/table/tr')
|
2023-10-11 11:01:06 +02:00
|
|
|
|
2023-11-22 15:14:08 +01:00
|
|
|
foreach ($node in $checksums) {
|
2023-12-11 22:23:36 +01:00
|
|
|
if ($node.ChildNodes[1].InnerText -eq $installerName) {
|
2023-10-11 11:01:06 +02:00
|
|
|
$distributorFileHash = $node.ChildNodes[7].InnerText
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-22 15:14:08 +01:00
|
|
|
if ($null -eq $distributorFileHash) {
|
2023-12-11 22:23:36 +01:00
|
|
|
throw "Unable to find checksum for $installerName in https://repo.anaconda.com/miniconda/"
|
2023-11-22 15:14:08 +01:00
|
|
|
}
|
2023-10-11 11:01:06 +02:00
|
|
|
#endregion
|
|
|
|
|
|
2023-11-22 15:14:08 +01:00
|
|
|
Install-Binary `
|
2023-12-11 22:23:36 +01:00
|
|
|
-Url "https://repo.anaconda.com/miniconda/${installerName}" `
|
|
|
|
|
-InstallArgs @("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$condaDestination") `
|
2023-11-22 15:14:08 +01:00
|
|
|
-ExpectedSHA256Sum $distributorFileHash
|
|
|
|
|
|
2023-12-11 22:23:36 +01:00
|
|
|
[Environment]::SetEnvironmentVariable("CONDA", $condaDestination, "Machine")
|
2023-11-22 15:14:08 +01:00
|
|
|
|
2023-10-11 11:01:06 +02:00
|
|
|
Invoke-PesterTests -TestFile "Miniconda"
|