param()
$ErrorActionPreference = 'Stop'
$taskRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../..'))
$manifest = Get-Content -Raw -Encoding UTF8 -LiteralPath (Join-Path $PSScriptRoot 'BflatToolchain.json') | ConvertFrom-Json
$downloadRoot = Join-Path $taskRoot '.tools/downloads'
[void][IO.Directory]::CreateDirectory($downloadRoot)
$archive = Join-Path $downloadRoot $manifest.ArchiveName
if (!(Test-Path -LiteralPath $archive)) {
$temporary = $archive + '.' + [Guid]::NewGuid().ToString('N') + '.part'
Invoke-WebRequest -Uri $manifest.DownloadUrl -OutFile $temporary -UseBasicParsing
if ((Get-FileHash -LiteralPath $temporary -Algorithm SHA256).Hash.ToLowerInvariant() -cne $manifest.ArchiveSha256) {
throw ('The compiler download failed its pinned digest check; retained at ' + $temporary)
}
Move-Item -LiteralPath $temporary -Destination $archive
}
if ((Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLowerInvariant() -cne $manifest.ArchiveSha256) {
throw 'The cached compiler archive failed its pinned digest check.'
}
$destination = Join-Path $taskRoot ('.tools/' + $manifest.Directory)
if (Test-Path -LiteralPath $destination) { throw 'The compiler directory already exists; inspect it instead of replacing it automatically.' }
Expand-Archive -LiteralPath $archive -DestinationPath $destination
foreach ($entry in $manifest.ToolSha256.PSObject.Properties) {
if ((Get-FileHash -LiteralPath (Join-Path $destination $entry.Name) -Algorithm SHA256).Hash.ToLowerInvariant() -cne $entry.Value) {
throw ('The extracted compiler tool failed its pinned digest check: ' + $entry.Name)
}
}
Write-Host ('Verified bflat 8.0.2 installed at ' + $destination)
param()
$ErrorActionPreference = 'Stop'
$taskRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../..'))
$manifest = Get-Content -Raw -Encoding UTF8 -LiteralPath (Join-Path $PSScriptRoot 'BflatToolchain.json') | ConvertFrom-Json
$downloadRoot = Join-Path $taskRoot '.tools/downloads'
[void][IO.Directory]::CreateDirectory($downloadRoot)
$archive = Join-Path $downloadRoot $manifest.ArchiveName
if (!(Test-Path -LiteralPath $archive)) {
$temporary = $archive + '.' + [Guid]::NewGuid().ToString('N') + '.part'
Invoke-WebRequest -Uri $manifest.DownloadUrl -OutFile $temporary -UseBasicParsing
if ((Get-FileHash -LiteralPath $temporary -Algorithm SHA256).Hash.ToLowerInvariant() -cne $manifest.ArchiveSha256) {
throw ('The compiler download failed its pinned digest check; retained at ' + $temporary)
}
Move-Item -LiteralPath $temporary -Destination $archive
}
if ((Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLowerInvariant() -cne $manifest.ArchiveSha256) {
throw 'The cached compiler archive failed its pinned digest check.'
}
$destination = Join-Path $taskRoot ('.tools/' + $manifest.Directory)
if (Test-Path -LiteralPath $destination) { throw 'The compiler directory already exists; inspect it instead of replacing it automatically.' }
Expand-Archive -LiteralPath $archive -DestinationPath $destination
foreach ($entry in $manifest.ToolSha256.PSObject.Properties) {
if ((Get-FileHash -LiteralPath (Join-Path $destination $entry.Name) -Algorithm SHA256).Hash.ToLowerInvariant() -cne $entry.Value) {
throw ('The extracted compiler tool failed its pinned digest check: ' + $entry.Name)
}
}
Write-Host ('Verified bflat 8.0.2 installed at ' + $destination)