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
|
|
|
################################################################################
|
|
|
|
|
|
2020-04-21 11:58:27 +03:00
|
|
|
$CondaDestination = "C:\Miniconda"
|
|
|
|
|
|
2020-09-14 17:50:46 +12:00
|
|
|
# Install the latest Miniconda
|
|
|
|
|
$InstallerName = "Miniconda3-latest-Windows-x86_64.exe"
|
2023-08-06 10:57:38 +02:00
|
|
|
$InstallerUrl = "https://repo.anaconda.com/miniconda/${InstallerName}"
|
2020-04-21 11:58:27 +03:00
|
|
|
$ArgumentList = ("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestination")
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2020-04-21 11:58:27 +03:00
|
|
|
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
|
2023-11-17 13:52:52 +01:00
|
|
|
[System.Environment]::SetEnvironmentVariable("CONDA", $CondaDestination, "Machine")
|
2020-07-17 15:29:03 +07:00
|
|
|
|
2023-10-11 11:01:06 +02:00
|
|
|
#region Supply chain security
|
|
|
|
|
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA256).Hash
|
|
|
|
|
$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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
Invoke-PesterTests -TestFile "Miniconda"
|