diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2018-02-14 07:46:11 +0100 |
---|---|---|
committer | Tony Sarajärvi <tony.sarajarvi@qt.io> | 2018-04-20 06:15:53 +0000 |
commit | 73621de8916b5d6d17a1dbd24c134d14c1c726a8 (patch) | |
tree | 8d1e21a4de97070e65183112fccc566a731788b2 /coin/provisioning/common/windows/openssl.ps1 | |
parent | a37f4a2485d30710d743cecdaf1775b43792ed83 (diff) |
Unify Windows provisioning scripts & improve error handling
While Coin should also see exit codes != 0 as error, we should
stick to one way of handling script errors. As Power Shell cmdlets
signal an error by throwing an exception we should do the same
(and that approach also works in Coin).
Additionally extracting 7zip files was unified across scripts by
using the existing helper function instead of reinventing the wheel
again and again.
A similar helper function was introduced for starting an external
application (and handling its errors).
Also echo and other "cmd" commands were replaced by their PowerShell
equivalents to have a unified approach across our Windows provisioning
scripts.
Change-Id: I70129ce38692f1396c33c13b33a2918485fa5271
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
(cherry picked from commit cb6709ce5c48a31ba1170c71494c1a3869ffa5bb)
Reviewed-by: Simo Fält <simo.falt@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'coin/provisioning/common/windows/openssl.ps1')
-rw-r--r-- | coin/provisioning/common/windows/openssl.ps1 | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/coin/provisioning/common/windows/openssl.ps1 b/coin/provisioning/common/windows/openssl.ps1 index f8268492..c884dd94 100644 --- a/coin/provisioning/common/windows/openssl.ps1 +++ b/coin/provisioning/common/windows/openssl.ps1 @@ -40,7 +40,7 @@ $version = "1_0_2j" $packagex64 = "C:\Windows\Temp\Win64OpenSSL-$version.exe" $packagex86 = "C:\Windows\Temp\Win32OpenSSL-$version.exe" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { # Install x64 bit version $architecture = "x64" @@ -49,25 +49,24 @@ if( (is64bitWinHost) -eq 1 ) { $internalUrl = "\\ci-files01-hki.intra.qt.io\provisioning\openssl\Win64OpenSSL-$version.exe" $sha1 = "b1660dbdcc77e1b3d81d780c7167be1c75384d44" - echo "Fetching from URL ..." + Write-Host "Fetching from URL ..." Download $externalUrl $internalUrl $packagex64 Verify-Checksum $packagex64 $sha1 - echo "Installing $packagex64 ..." - cmd /c "$packagex64 /SP- /SILENT /LOG /SUPPRESSMSGBOXES /NORESTART /DIR=$installFolder" + Write-Host "Installing $packagex64 ..." + Run-Executable "$packagex64" "/SP- /SILENT /LOG /SUPPRESSMSGBOXES /NORESTART /DIR=$installFolder" - echo "Remove downloaded $packagex64 ..." - Remove-Item $packagex64 + Write-Host "Remove downloaded $packagex64 ..." + Remove-Item -Path $packagex64 - echo "Set $architecture environment variables ..." - [Environment]::SetEnvironmentVariable("OPENSSL_CONF_x64", "$installFolder\bin\openssl.cfg", "Machine") - [Environment]::SetEnvironmentVariable("OPENSSL_INCLUDE_x64", "$installFolder\include", "Machine") - [Environment]::SetEnvironmentVariable("OPENSSL_LIB_x64", "$installFolder\lib", "Machine") + Set-EnvironmentVariable "OPENSSL_CONF_x64" "$installFolder\bin\openssl.cfg" + Set-EnvironmentVariable "OPENSSL_INCLUDE_x64" "$installFolder\include" + Set-EnvironmentVariable "OPENSSL_LIB_x64" "$installFolder\lib" } # Install x86 bit version $architecture = "x86" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $installFolder = "C:\openssl$architecture" } else { $installFolder = "C:\openssl" @@ -77,19 +76,18 @@ $externalUrl = "https://slproweb.com/download/Win32OpenSSL-$version.exe" $internalUrl = "\\ci-files01-hki.intra.qt.io\provisioning\openssl\Win32OpenSSL-$version.exe" $sha1 = "29b31d20545214ab4e4c57afb20be2338c317cc3" -echo "Fetching from URL ..." +Write-Host "Fetching from URL ..." Download $externalUrl $internalUrl $packagex86 Verify-Checksum $packagex86 $sha1 -echo "Installing $packagex86 ..." -cmd /c "$packagex86 /SP- /SILENT /LOG /SUPPRESSMSGBOXES /NORESTART /DIR=$installFolder" +Write-Host "Installing $packagex86 ..." +Run-Executable "$packagex86" "/SP- /SILENT /LOG /SUPPRESSMSGBOXES /NORESTART /DIR=$installFolder" -echo "Remove downloaded $packagex86 ..." -Remove-Item $packagex86 +Write-Host "Remove downloaded $packagex86 ..." +Remove-Item -Path $packagex86 -echo "Set $architecture environment variables ..." -[Environment]::SetEnvironmentVariable("OPENSSL_CONF_x86", "$installFolder\bin\openssl.cfg", "Machine") -[Environment]::SetEnvironmentVariable("OPENSSL_INCLUDE_x86", "$installFolder\include", "Machine") -[Environment]::SetEnvironmentVariable("OPENSSL_LIB_x86", "$installFolder\lib", "Machine") +Set-EnvironmentVariable "OPENSSL_CONF_x86" "$installFolder\bin\openssl.cfg" +Set-EnvironmentVariable "OPENSSL_INCLUDE_x86" "$installFolder\include" +Set-EnvironmentVariable "OPENSSL_LIB_x86" "$installFolder\lib" # Store version information to ~/versions.txt, which is used to print version information to provision log. -echo "OpenSSL = $version" >> ~/versions.txt +Write-Output "OpenSSL = $version" >> ~/versions.txt |