diff options
author | Bryan McLellan <btm@loftninjas.org> | 2020-04-05 14:32:18 -0400 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2020-04-05 15:55:58 -0400 |
commit | 0556ec543e8687aa843b0d792f1b6294b6ea5ca9 (patch) | |
tree | 1eb6f5dadd553e3624835d0009bd5b0d98a816a3 | |
parent | 2f546b50bd67314251b0f62554fc71cbf6a7a29a (diff) | |
download | chef-btm/perms.tar.gz |
DO NOT MERGEbtm/perms
Signed-off-by: Bryan McLellan <btm@loftninjas.org>
-rw-r--r-- | scripts/bk_tests/bk_win_functional.ps1 | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/scripts/bk_tests/bk_win_functional.ps1 b/scripts/bk_tests/bk_win_functional.ps1 index 6033812388..fd5049e8f9 100644 --- a/scripts/bk_tests/bk_win_functional.ps1 +++ b/scripts/bk_tests/bk_win_functional.ps1 @@ -1,3 +1,21 @@ +$RubyFilename = "rubyinstaller-devkit-2.6.5-1-x64.exe" +$RubySHA256 = "BD2050496A149C7258ED4E2E44103756CA3A05C7328A939F0FDC97AE9616A96D" +$RubyPath = "$env:temp\$RubyFilename" + +Function DownloadRuby +{ + echo "Downloading Ruby + DevKit" + aws s3 cp s3://public-cd-buildkite-cache/$RubyFilename $RubyPath | Out-Null # Out-Null is a hack to wait for the process to complete + + if ($LASTEXITCODE -ne 0) + { + echo "aws s3 download failed: $LASTEXITCODE" + exit $LASTEXITCODE + } + $DownloadedHash = (Get-FileHash $RubyPath -Algorithm SHA256).Hash + echo "Downloaded SHA256: $DownloadedHash" +} + echo "--- system details" $Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture' Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize @@ -8,14 +26,30 @@ Remove-Item -Path C:\ProgramData\chocolatey\bin\choco.exe -ErrorAction SilentlyC echo "--- install ruby + devkit" $ErrorActionPreference = 'Stop' -echo "Downloading Ruby + DevKit" -aws s3 cp s3://public-cd-buildkite-cache/rubyinstaller-devkit-2.6.5-1-x64.exe $env:temp/rubyinstaller-devkit-2.6.5-1-x64.exe +If (Test-Path $RubyPath) { + echo "$RubyPath already exists" + + $ExistingRubyHash = (Get-FileHash $RubyPath -Algorithm SHA256).Hash + + echo "Verifying file SHA256 hash $ExistingRubyHash to desired hash $RubySHA256" + + If ($ExistingRubyHash -ne $RubySHA256) { + echo "SHA256 hash mismatch, attempting to remove and re-download" + Remove-Item $RubyPath -Force + DownloadRuby + } Else { + echo "Found matching Ruby + DevKit on disk" + } +} Else { + echo "No Ruby found at $RubyPath, downloading" + DownloadRuby +} echo "Installing Ruby + DevKit" -Start-Process $env:temp\rubyinstaller-devkit-2.6.5-1-x64.exe -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait +Start-Process $RubyPath -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait echo "Cleaning up installation" -Remove-Item $env:temp\rubyinstaller-devkit-2.6.5-1-x64.exe -Force -ErrorAction SilentlyContinue +Remove-Item $RubyPath -Force -ErrorAction SilentlyContinue echo "Closing out the layer (this can take awhile)" # Set-Item -Path Env:Path -Value to include ruby26 |