From cb6709ce5c48a31ba1170c71494c1a3869ffa5bb Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 14 Feb 2018 07:46:11 +0100 Subject: 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 --- coin/provisioning/common/windows/03-conan.ps1 | 38 +++++------ .../common/windows/3dstudio_3rdparty.ps1 | 4 +- .../common/windows/allow-remote-desktop-access.ps1 | 3 +- .../common/windows/android-openssl.ps1 | 20 +++--- coin/provisioning/common/windows/android.ps1 | 28 ++++---- coin/provisioning/common/windows/cmake.ps1 | 4 +- coin/provisioning/common/windows/disable-ntp.ps1 | 4 +- coin/provisioning/common/windows/disable-sleep.ps1 | 9 +-- coin/provisioning/common/windows/disable-uac.ps1 | 3 +- .../common/windows/disable-windefender.ps1 | 5 +- .../common/windows/disable-windows-updates.ps1 | 2 +- coin/provisioning/common/windows/dxsdk.ps1 | 8 +-- coin/provisioning/common/windows/fbx_windows.ps1 | 12 ++-- coin/provisioning/common/windows/helpers.ps1 | 72 +++++++++++--------- coin/provisioning/common/windows/icu.ps1 | 4 +- .../common/windows/install-dependencywalker.ps1 | 15 ++--- coin/provisioning/common/windows/install-git.ps1 | 15 ++--- coin/provisioning/common/windows/install-jdk.ps1 | 21 +++--- coin/provisioning/common/windows/install-mingw.ps1 | 11 ++-- .../common/windows/install-notepad++.ps1 | 16 ++--- coin/provisioning/common/windows/install-ruby.ps1 | 13 ++-- .../common/windows/install-sevenzip.ps1 | 13 ++-- .../common/windows/install-strawberry-perl.ps1 | 20 +++--- coin/provisioning/common/windows/jom.ps1 | 2 +- coin/provisioning/common/windows/libclang.ps1 | 12 ++-- coin/provisioning/common/windows/libusb.ps1 | 2 +- .../provisioning/common/windows/memorypershell.ps1 | 2 +- coin/provisioning/common/windows/mesa_llvmpipe.ps1 | 13 ++-- coin/provisioning/common/windows/mqtt_broker.ps1 | 9 ++- .../common/windows/msvc_2015_update3_patch.ps1 | 32 +++++---- coin/provisioning/common/windows/mysql.ps1 | 23 +++---- coin/provisioning/common/windows/ninja.ps1 | 2 +- coin/provisioning/common/windows/openssl.ps1 | 40 ++++++------ coin/provisioning/common/windows/postgresql.ps1 | 35 +++++----- coin/provisioning/common/windows/python.ps1 | 27 ++++---- coin/provisioning/common/windows/python3.ps1 | 28 ++++---- coin/provisioning/common/windows/set-proxy.ps1 | 17 ++--- coin/provisioning/common/windows/squishInstall.ps1 | 76 +++++++++------------- coin/provisioning/common/windows/unset-proxy.ps1 | 2 +- coin/provisioning/common/windows/vc_redist.ps1 | 19 +++--- coin/provisioning/common/windows/vulkansdk.ps1 | 8 +-- .../common/windows/win10-enable-devmode.ps1 | 10 ++- coin/provisioning/common/windows/winrtrunner.ps1 | 4 +- coin/provisioning/common/windows/wsearch-off.ps1 | 3 +- 44 files changed, 343 insertions(+), 363 deletions(-) (limited to 'coin/provisioning/common') diff --git a/coin/provisioning/common/windows/03-conan.ps1 b/coin/provisioning/common/windows/03-conan.ps1 index 2c9d9f8d..d900f5a7 100644 --- a/coin/provisioning/common/windows/03-conan.ps1 +++ b/coin/provisioning/common/windows/03-conan.ps1 @@ -2,18 +2,12 @@ $scriptsPath = "C:\Python27\Scripts" -& "$scriptsPath\pip.exe" install --upgrade conan==0.24.0 +Run-Executable "$scriptsPath\pip.exe" "install --upgrade conan==0.24.0" # Use Qt Project repository by default -& "$scriptsPath\conan.exe" remote add qtproject https://api.bintray.com/conan/qtproject/conan --insert +Run-Executable "$scriptsPath\conan.exe" "remote add qtproject https://api.bintray.com/conan/qtproject/conan --insert" -[Environment]::SetEnvironmentVariable("CI_CONAN_BUILDINFO_DIR", "C:\Utils\conanbuildinfos", "Machine") - -function Start-Process-Logged -{ - Write-Host "Start-Process", $args - Start-Process @args -} +Set-EnvironmentVariable "CI_CONAN_BUILDINFO_DIR" "C:\Utils\conanbuildinfos" function Run-Conan-Install { @@ -43,18 +37,20 @@ function Run-Conan-Install $outpwd = "C:\Utils\conanbuildinfos\$($BuildinfoDir)\$($_.BaseName)" New-Item $outpwd -Type directory -Force - $process = Start-Process-Logged ` - "$scriptsPath\conan.exe" ` - -WorkingDirectory $outpwd ` - -ArgumentList "install -f $conanfile --no-imports --verify $manifestsDir", ` - '-s', ('compiler="' + $Compiler + '"'), ` - "-s os=Windows -s arch=$Arch -s compiler.version=$CompilerVersion $extraArgs" ` - -NoNewWindow -Wait -Verbose ` - -PassThru # Return process object - - if ($process.ExitCode -ne 0) { - Write-Host "conan exited with code $($process.ExitCode)" - Exit(1) + for ($i = 1; $i -le 5; $i++) { + try { + Push-Location $outpwd + Run-Executable "$scriptsPath\conan.exe" "install -f $conanfile --no-imports --verify $manifestsDir", ` + '-s', ('compiler="' + $Compiler + '"'), ` + "-s os=Windows -s arch=$Arch -s compiler.version=$CompilerVersion $extraArgs" ` + break; + } catch { + if ($i -eq 5) { + throw "Could not install conan content" + } + } finally { + Pop-Location + } } Copy-Item -Path $conanfile -Destination "$outpwd\conanfile.txt" diff --git a/coin/provisioning/common/windows/3dstudio_3rdparty.ps1 b/coin/provisioning/common/windows/3dstudio_3rdparty.ps1 index b6804a77..924d8606 100644 --- a/coin/provisioning/common/windows/3dstudio_3rdparty.ps1 +++ b/coin/provisioning/common/windows/3dstudio_3rdparty.ps1 @@ -6,6 +6,6 @@ $url = "http://ci-files01-hki.intra.qt.io/input/3rdparty/Qt3DStudio-3rdparty-win Download $url $url $zip Verify-Checksum $zip "08D740D2EFB4CBCDE7D012908B89AA48DE5CD4E1" Extract-Zip $zip C:\Utils\Qt3DStudio3rdparty -Remove-Item $zip +Remove-Item -Path $zip -[Environment]::SetEnvironmentVariable("QT3DSTUDIO_3RDPARTY_DIR", "C:/Utils/Qt3DStudio3rdparty", "Machine") +Set-EnvironmentVariable "QT3DSTUDIO_3RDPARTY_DIR" "C:/Utils/Qt3DStudio3rdparty" diff --git a/coin/provisioning/common/windows/allow-remote-desktop-access.ps1 b/coin/provisioning/common/windows/allow-remote-desktop-access.ps1 index 06ea20a4..cbf514ba 100644 --- a/coin/provisioning/common/windows/allow-remote-desktop-access.ps1 +++ b/coin/provisioning/common/windows/allow-remote-desktop-access.ps1 @@ -30,7 +30,8 @@ ## $QT_END_LICENSE$ ## ############################################################################# +. "$PSScriptRoot\helpers.ps1" # This script allows the Windows Remote Desktop Access -reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f +Run-Executable "reg.exe" "add `"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server`" /v fDenyTSConnections /t REG_DWORD /d 0 /f" diff --git a/coin/provisioning/common/windows/android-openssl.ps1 b/coin/provisioning/common/windows/android-openssl.ps1 index 798b3e45..b0363c4c 100644 --- a/coin/provisioning/common/windows/android-openssl.ps1 +++ b/coin/provisioning/common/windows/android-openssl.ps1 @@ -47,23 +47,23 @@ $destination = "C:\Utils\openssl-android-master" Download https://www.openssl.org/source/openssl-$version.tar.gz \\ci-files01-hki.intra.qt.io\provisioning\openssl\openssl-$version.tar.gz $zip Verify-Checksum $zip $sha1 -C:\Utils\sevenzip\7z.exe x $zip -oC:\Utils -C:\Utils\sevenzip\7z.exe x C:\Utils\openssl-$version.tar -oC:\Utils +Extract-7Zip $zip C:\Utils +Extract-7Zip C:\Utils\openssl-$version.tar C:\Utils Rename-Item C:\Utils\openssl-$version $destination -Remove-Item $zip +Remove-Item -Path $zip Remove-Item C:\Utils\openssl-$version.tar -set CC=C:\utils\android-ndk-r10e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows\bin\arm-linux-androideabi-gcc -set AR=C:\utils\android-ndk-r10e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows\bin\arm-linux-androideabi-ar -set ANDROID_DEV=C:\utils\android-ndk-r10e\platforms\android-18\arch-arm\usr +Set-EnvironmentVariable "CC" "C:\utils\android-ndk-r10e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows\bin\arm-linux-androideabi-gcc" +Set-EnvironmentVariable "AR" "C:\utils\android-ndk-r10e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows\bin\arm-linux-androideabi-ar" +Set-EnvironmentVariable "ANDROID_DEV" "C:\utils\android-ndk-r10e\platforms\android-18\arch-arm\usr" # Make sure configure for openssl has a "make" and "perl" available $env:PATH = $env:PATH + ";C:\msys\1.0\bin;C:\strawberry\perl\bin" -echo "Configuring OpenSSL $version for Android..." -pushd $destination -C:\msys\1.0\bin\bash.exe -c "c:/strawberry/perl/bin/perl Configure shared android" -popd +Write-Host "Configuring OpenSSL $version for Android..." +Push-Location $destination +Run-Executable "C:\msys\1.0\bin\bash.exe" "-c `"c:/strawberry/perl/bin/perl Configure shared android`"" +Pop-Location # Following command is needed when using version 1.1.0. With version 1.1.0 msys is not needed. # C:\mingw530\bin\mingw32-make.exe include\openssl\opensslconf.h diff --git a/coin/provisioning/common/windows/android.ps1 b/coin/provisioning/common/windows/android.ps1 index f5e916e8..881d057e 100644 --- a/coin/provisioning/common/windows/android.ps1 +++ b/coin/provisioning/common/windows/android.ps1 @@ -70,23 +70,19 @@ function Install($1, $2, $3, $4) { } function SdkUpdate ($1, $2) { - echo "Running Android SDK update for $1..." + Write-Host "Running Android SDK update for $1..." cmd /c "echo y |$1\tools\android update sdk --no-ui --all --filter $2" } -echo "Installing Android ndk $nkdVersion" +Write-Host "Installing Android ndk $nkdVersion" Install $ndkCachedUrl $ndkZip $ndkChecksum $ndkOfficialUrl -echo "Set environment variable ANDROID_NDK_HOME=$ndkFolder" -[Environment]::SetEnvironmentVariable("ANDROID_NDK_HOME", $ndkFolder, "Machine") -echo "Set environment variable ANDROID_NDK_ROOT=$ndkFolder" -[Environment]::SetEnvironmentVariable("ANDROID_NDK_ROOT", $ndkFolder, "Machine") +Set-EnvironmentVariable "ANDROID_NDK_HOME" $ndkFolder +Set-EnvironmentVariable "ANDROID_NDK_ROOT" $ndkFolder -#echo "Installing Android sdk $sdkVersion" +#Write-Host "Installing Android sdk $sdkVersion" Install $sdkCachedUrl $sdkZip $sdkChecksum $sdkOfficialUrl -echo "Set environment variable ANDROID_SDK_HOME=$sdkFolder" -[Environment]::SetEnvironmentVariable("ANDROID_SDK_HOME", $sdkFolder, "Machine") -echo "Set environment variable ANDROID_API_VERSION $sdkApiLevel" -[Environment]::SetEnvironmentVariable("ANDROID_API_VERSION", $sdkApiLevel, "Machine") +Set-EnvironmentVariable "ANDROID_SDK_HOME" $sdkFolder +Set-EnvironmentVariable "ANDROID_API_VERSION" $sdkApiLevel # SDK update SdkUpdate $sdkFolder $sdkApiLevel @@ -94,5 +90,11 @@ SdkUpdate $sdkFolder tools SdkUpdate $sdkFolder platform-tools SdkUpdate $sdkFolder build-tools-$sdkBuildToolsVersion -# kill adb. This process prevent's provisioning to continue -taskkill /im adb.exe /f +# kill adb. This process prevents provisioning to continue +$p = Get-Process -Name "adb.exe" -ErrorAction:SilentlyContinue +if ($p -ne $null) { + Write-Host "Stopping adb.exe" + Stop-Process -Force $p +} else { + Write-Host "adb.exe not running" +} diff --git a/coin/provisioning/common/windows/cmake.ps1 b/coin/provisioning/common/windows/cmake.ps1 index d7e26556..c0ead98e 100644 --- a/coin/provisioning/common/windows/cmake.ps1 +++ b/coin/provisioning/common/windows/cmake.ps1 @@ -40,7 +40,7 @@ $zip = "c:\users\qt\downloads\cmake-" + $version + "-win32-x86.zip" $officialurl = "https://cmake.org/files/v" + $majorminorversion + "/cmake-" + $version + "-win32-x86.zip" $cachedurl = "\\ci-files01-hki.intra.qt.io\provisioning\cmake\cmake-" + $version + "-win32-x86.zip" -echo "Removing old cmake" +Write-Host "Removing old cmake" Remove-Item "C:\CMake" -Force -Recurse -ErrorAction SilentlyContinue Download $officialurl $cachedurl $zip @@ -52,5 +52,5 @@ Rename-Item $defaultinstallfolder C:\CMake Add-Path "C:\CMake\bin" -echo "CMake = $version" >> ~\versions.txt +Write-Output "CMake = $version" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/disable-ntp.ps1 b/coin/provisioning/common/windows/disable-ntp.ps1 index 4ec9d1bd..757f0d18 100644 --- a/coin/provisioning/common/windows/disable-ntp.ps1 +++ b/coin/provisioning/common/windows/disable-ntp.ps1 @@ -1,2 +1,4 @@ +. "$PSScriptRoot\helpers.ps1" + # Disable the NTP from syncing -w32tm /config /syncfromflags:NO +Run-Executable "w32tm.exe" "/config /syncfromflags:NO" diff --git a/coin/provisioning/common/windows/disable-sleep.ps1 b/coin/provisioning/common/windows/disable-sleep.ps1 index dda785ac..a3d194b7 100644 --- a/coin/provisioning/common/windows/disable-sleep.ps1 +++ b/coin/provisioning/common/windows/disable-sleep.ps1 @@ -30,10 +30,11 @@ ## $QT_END_LICENSE$ ## ############################################################################# +. "$PSScriptRoot\helpers.ps1" # This script prevents Windows from going to sleep -powercfg -change -monitor-timeout-ac 0 -powercfg -change -standby-timeout-ac 0 -powercfg -change -disk-timeout-ac 0 -powercfg -change -hibernate-timeout-ac 0 +Run-Executable "powercfg.exe" "-change -monitor-timeout-ac 0" +Run-Executable "powercfg.exe" "-change -standby-timeout-ac 0" +Run-Executable "powercfg.exe" "-change -disk-timeout-ac 0" +Run-Executable "powercfg.exe" "-change -hibernate-timeout-ac 0" diff --git a/coin/provisioning/common/windows/disable-uac.ps1 b/coin/provisioning/common/windows/disable-uac.ps1 index 757c4a7e..c57f7e72 100644 --- a/coin/provisioning/common/windows/disable-uac.ps1 +++ b/coin/provisioning/common/windows/disable-uac.ps1 @@ -30,7 +30,8 @@ ## $QT_END_LICENSE$ ## ############################################################################# +. "$PSScriptRoot\helpers.ps1" # This script disables the Windows UAC -C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f +Run-Executable "reg.exe" "ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f" diff --git a/coin/provisioning/common/windows/disable-windefender.ps1 b/coin/provisioning/common/windows/disable-windefender.ps1 index 2d1f0783..e508641e 100644 --- a/coin/provisioning/common/windows/disable-windefender.ps1 +++ b/coin/provisioning/common/windows/disable-windefender.ps1 @@ -2,4 +2,7 @@ # # If disabled manually, windows will automatically enable it after # some period of time. Disabling it speeds up the builds. -REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender" /V DisableAntiSpyware /T REG_dWORD /D 1 /F + +. "$PSScriptRoot\helpers.ps1" + +Run-Executable "reg.exe" "ADD `"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender`" /V DisableAntiSpyware /T REG_dWORD /D 1 /F" diff --git a/coin/provisioning/common/windows/disable-windows-updates.ps1 b/coin/provisioning/common/windows/disable-windows-updates.ps1 index 05215e20..87414f03 100644 --- a/coin/provisioning/common/windows/disable-windows-updates.ps1 +++ b/coin/provisioning/common/windows/disable-windows-updates.ps1 @@ -43,7 +43,7 @@ if ($service.Status -eq "Stopped") { Write-Host "Windows Update service already stopped." } else { Write-Host "Stopping Windows Update service." - stop-service wuauserv + Stop-Service -Name "wuauserv" -Force } $startup = Get-WmiObject Win32_Service | Where-Object {$_.Name -eq "wuauserv"} | Select -ExpandProperty "StartMode" diff --git a/coin/provisioning/common/windows/dxsdk.ps1 b/coin/provisioning/common/windows/dxsdk.ps1 index 629c7ac5..ce2bbeb3 100644 --- a/coin/provisioning/common/windows/dxsdk.ps1 +++ b/coin/provisioning/common/windows/dxsdk.ps1 @@ -11,9 +11,9 @@ $exe = "C:\Windows\Temp\$package" Download $officialUrl $cachedUrl $exe -echo "Installing DirectX SDK" -cmd /c "$exe /u" +Write-Host "Installing DirectX SDK" +Run-Executable $exe "/u" -Remove-Item $exe +Remove-Item -Path $exe -echo "DirectX SDK = 9.29.1962 (Jun 10)" >> ~\versions.txt +Write-Output "DirectX SDK = 9.29.1962 (Jun 10)" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/fbx_windows.ps1 b/coin/provisioning/common/windows/fbx_windows.ps1 index 00de579d..7b7abe43 100644 --- a/coin/provisioning/common/windows/fbx_windows.ps1 +++ b/coin/provisioning/common/windows/fbx_windows.ps1 @@ -51,18 +51,16 @@ $sha1 = "3690400625672bef6369bcf90dcde4d78b493b24" #$targetFile = "C:\Windows\Temp\$packageName" $targetFolder = "C:\Program Files\" -#echo "Downloading '$installerName'" +#Write-Host "Downloading '$installerName'" #Download $officialUrl $cacheUrl $targetFile #Verify-Checksum $targetFile $sha1 -echo "Extracting '$cacheUrl'" -#Extract-7Zip $cacheUrl $targetFolder -Start-Process -FilePath "C:\Utils\sevenzip\7z.exe" -ArgumentList "x -y `"$cacheUrl`" -o`"$targetFolder`"" -Wait +Write-Host "Extracting '$cacheUrl'" +Extract-7Zip $cacheUrl $targetFolder #Remove-Item -Recurse -Force "$packageName" -echo "Adding environment variables." -[Environment]::SetEnvironmentVariable("FBXSDK", "$targetFolder\Autodesk\FBX\FBX SDK\2016.1.2", [EnvironmentVariableTarget]::Machine) +Set-EnvironmentVariable "FBXSDK" "$targetFolder\Autodesk\FBX\FBX SDK\2016.1.2" -echo "FBX SDK = $version" >> ~\versions.txt +Write-Output "FBX SDK = $version" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/helpers.ps1 b/coin/provisioning/common/windows/helpers.ps1 index 9c6706a2..45779c04 100644 --- a/coin/provisioning/common/windows/helpers.ps1 +++ b/coin/provisioning/common/windows/helpers.ps1 @@ -5,13 +5,32 @@ function Verify-Checksum [string]$Expected=$(throw("Checksum required")), [ValidateSet("sha1","md5")][string]$Algorithm="sha1" ) + Write-Host "Verifying checksum of $File" $fs = new-object System.IO.FileStream $File, "Open" $algo = [type]"System.Security.Cryptography.$Algorithm" $crypto = $algo::Create() $hash = [BitConverter]::ToString($crypto.ComputeHash($fs)).Replace("-", "") $fs.Close() if ($hash -ne $Expected) { - Write-Error "Checksum verification failed, got: '$hash' expected: '$Expected'" + throw "Checksum verification failed, got: '$hash' expected: '$Expected'" + } +} + +function Run-Executable +{ + Param ( + [string]$Executable=$(throw("You must specify a program to run.")), + [string[]]$Arguments + ) + if ([string]::IsNullOrEmpty($Arguments)) { + Write-Host "Running `"$Executable`"" + $p = Start-Process -FilePath "$Executable" -Wait -PassThru + } else { + Write-Host "Running `"$Executable`" with arguments `"$Arguments`"" + $p = Start-Process -FilePath "$Executable" -ArgumentList $Arguments -Wait -PassThru + } + if ($p.ExitCode -ne 0) { + throw "Process $($Executable) exited with exit code $($p.ExitCode)" } } @@ -21,24 +40,21 @@ function Extract-7Zip [string]$Source, [string]$Destination ) - echo "Extracting '$Source' to '$Destination'..." + Write-Host "Extracting '$Source' to '$Destination'..." if ((Get-Command "7z.exe" -ErrorAction SilentlyContinue) -eq $null) { - $zipExe = join-path (${env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0] '7-zip\7z.exe' + $zipExe = join-path (${env:ProgramFiles(x86)}, ${env:ProgramFiles}, ${env:ProgramW6432} -ne $null)[0] '7-zip\7z.exe' if (-not (test-path $zipExe)) { - $zipExe = join-path ${env:ProgramW6432} '7-zip\7z.exe' + $zipExe = "C:\Utils\sevenzip\7z.exe" if (-not (test-path $zipExe)) { - $zipExe = "C:\Utils\sevenzip\7z.exe" - if (-not (test-path $zipExe)) { - throw "Could not find 7-zip." - } + throw "Could not find 7-zip." } } } else { $zipExe = "7z.exe" } - & $zipExe x $Source "-o$Destination" -y + Run-Executable "$zipExe" "x -y `"-o$Destination`" `"$Source`"" } function Extract-Zip @@ -47,7 +63,7 @@ function Extract-Zip [string]$Source, [string]$Destination ) - echo "Extracting '$Source' to '$Destination'..." + Write-Host "Extracting '$Source' to '$Destination'..." New-Item -ItemType Directory -Force -Path $Destination $shell = new-object -com shell.application @@ -66,7 +82,7 @@ function Extract-Dev-Folders-From-Zip $shell = new-object -com shell.application - echo "Extracting contents of $package" + Write-Host "Extracting contents of $package" foreach ($subDir in "lib", "include", "bin", "share") { $zip = $shell.Namespace($package + "\" + $zipDir + "\" + $subDir) if ($zip) { @@ -97,12 +113,14 @@ function Download ) $ProgressPreference = 'SilentlyContinue' try { + Write-Host "Downloading from cached location ($CachedUrl) to $Destination" if ($CachedUrl.StartsWith("http")) { Invoke-WebRequest -UseBasicParsing $CachedUrl -OutFile $Destination } else { Copy-Item $CachedUrl $Destination } } catch { + Write-Host "Cached download failed: Downloading from official location: $OfficialUrl" Invoke-WebRequest -UseBasicParsing $OfficialUrl -OutFile $Destination } } @@ -112,37 +130,27 @@ function Add-Path Param ( [string]$Path ) - echo "Adding $Path to Path" + Write-Host "Adding $Path to Path" $oldPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') [Environment]::SetEnvironmentVariable("Path", $oldPath + ";$Path", [EnvironmentVariableTarget]::Machine) $Env:PATH = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') } -function is64bitWinHost +function Set-EnvironmentVariable { - if(($env:PROCESSOR_ARCHITECTURE -eq "AMD64") -or ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64")) { - return 1 - } - else { - return 0 - } + Param ( + [string]$Key = $(BadParam("a key")), + [string]$Value = $(BadParam("a value.")) + ) + Write-Host "Setting environment variable `"$($Key)`" to `"$($Value)`"" + + [Environment]::SetEnvironmentVariable($Key, $Value, [EnvironmentVariableTarget]::Machine) } -Function Execute-Command +function Is64BitWinHost { - Param ( - [string]$command - ) - Try { - echo "Executing command '$command'..." - $process = Start-Process -FilePath "cmd" -ArgumentList "/c $command" -PassThru -Wait -WindowStyle Hidden - if ($process.ExitCode) {throw "Error running command: '$command'"} - } - Catch { - $_.Exception.Message - exit 1 - } + return [environment]::Is64BitOperatingSystem } function isProxyEnabled { diff --git a/coin/provisioning/common/windows/icu.ps1 b/coin/provisioning/common/windows/icu.ps1 index be0f7277..a03d10c4 100644 --- a/coin/provisioning/common/windows/icu.ps1 +++ b/coin/provisioning/common/windows/icu.ps1 @@ -37,9 +37,9 @@ $version = "53_1" -if(($env:PROCESSOR_ARCHITECTURE -eq "AMD64") -or ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64")) { +if (Is64BitWinHost) { # FIXME: do we really want to use the 4.8.2 ICU build? -[Environment]::SetEnvironmentVariable("CI_ICU_PATH_Mingw49", "C:\Utils\icu_53_1_Mingw_builds_4_8_2_posix_seh_64_devel\icu53_1", "Machine") +Set-EnvironmentVariable "CI_ICU_PATH_Mingw49" "C:\Utils\icu_53_1_Mingw_builds_4_8_2_posix_seh_64_devel\icu53_1" } diff --git a/coin/provisioning/common/windows/install-dependencywalker.ps1 b/coin/provisioning/common/windows/install-dependencywalker.ps1 index 3fc17052..1ccc0b7d 100644 --- a/coin/provisioning/common/windows/install-dependencywalker.ps1 +++ b/coin/provisioning/common/windows/install-dependencywalker.ps1 @@ -36,11 +36,10 @@ # This script will install Dependency Walker 2.2.6000 $version = "2.2.6000" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $arch = "_x64" $sha1 = "4831D2A8376D64110FF9CD18799FE6C69509D3EA" -} -else { +} else { $arch = "_x86" $sha1 = "bfec714057e8449b0246051be99ba46a7760bab9" } @@ -49,15 +48,15 @@ $url_official = "http://www.dependencywalker.com/depends22" + $arch + ".zip" $dependsPackage = "C:\Windows\Temp\depends-$version.zip" $TARGETDIR = "C:\Utils\dependencywalker" -if(!(Test-Path -Path $TARGETDIR )){ +if (!(Test-Path -Path $TARGETDIR )) { New-Item -ItemType directory -Path $TARGETDIR } Download $url_official $url_cache $dependsPackage Verify-Checksum $dependsPackage $sha1 -Get-ChildItem $dependsPackage | % {& "C:\Utils\sevenzip\7z.exe" "x" $_.fullname "-o$TARGETDIR"} +Extract-7Zip $dependsPackage $TARGETDIR -echo "Cleaning $dependsPackage.." -Remove-Item -Recurse -Force "$dependsPackage" +Write-Host "Cleaning $dependsPackage.." +Remove-Item -Recurse -Force -Path "$dependsPackage" -echo "Dependency Walker = $version" >> ~\versions.txt +Write-Output "Dependency Walker = $version" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/install-git.ps1 b/coin/provisioning/common/windows/install-git.ps1 index 00700a22..c57e7199 100644 --- a/coin/provisioning/common/windows/install-git.ps1 +++ b/coin/provisioning/common/windows/install-git.ps1 @@ -35,11 +35,10 @@ # Install Git version 2.13.0 $version = "2.13.0" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $arch = "-64-bit" $sha1 = "E1D7C6E5E16ACAF3C108064A2ED158F604FA29A7" -} -else { +} else { $arch = "-32-bit" $sha1 = "03c7df2e4ef61ea6b6f9c0eb7e6d5151d9682aec" } @@ -47,11 +46,11 @@ $gitPackage = "C:\Windows\Temp\Git-" + $version + $arch + ".exe" $url_cache = "\\ci-files01-hki.intra.qt.io\provisioning\windows\Git-" + $version + $arch + ".exe" $url_official = "https://github.com/git-for-windows/git/releases/download/v" + $version + ".windows.1/Git-" + $version + $arch + ".exe" -echo "Fetching Git $version..." +Write-Host "Fetching Git $version..." Download $url_official $url_cache $gitPackage Verify-Checksum $gitPackage $sha1 -echo "Installing Git $version..." -cmd /c "$gitPackage /SILENT /COMPONENTS="icons,ext\reg\shellhere,assoc,assoc_sh"" -remove-item $gitPackage +Write-Host "Installing Git $version..." +Run-Executable "$gitPackage" "/SILENT /COMPONENTS=`"icons,ext\reg\shellhere,assoc,assoc_sh`"" +Remove-Item -Path $gitPackage -echo "Git = $version" >> ~\versions.txt +Write-Output "Git = $version" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/install-jdk.ps1 b/coin/provisioning/common/windows/install-jdk.ps1 index 63e5edaf..73750489 100644 --- a/coin/provisioning/common/windows/install-jdk.ps1 +++ b/coin/provisioning/common/windows/install-jdk.ps1 @@ -38,11 +38,10 @@ $installdir = "C:\Program Files\Java\jdk1.8.0_144" $version = "8u144" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $arch = "x64" $sha1 = "adb03bc3f4b40bcb3227687860798981d58e1858" -} -else { +} else { $arch = "i586" $sha1 = "3b9ab95914514eaefd72b815c5d9dd84c8e216fc" } @@ -51,13 +50,13 @@ $url_cache = "\\ci-files01-hki.intra.qt.io\provisioning\windows\jdk-" + $version $official_url = "http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-" + $version + "-windows-" + $arch + ".exe" $javaPackage = "C:\Windows\Temp\jdk-$version.exe" -echo "Fetching Java SE $version..." +Write-Host "Fetching Java SE $version..." $ProgressPreference = 'SilentlyContinue' try { - echo "...from local cache" + Write-Host "...from local cache" Download $url_cache $url_cache $javaPackage } catch { - echo "...from oracle.com" + Write-Host "...from oracle.com" $client = new-object System.Net.WebClient $cookie = "oraclelicense=accept-securebackup-cookie" $client.Headers.Add("Cookie", $cookie) @@ -68,11 +67,11 @@ try { Verify-Checksum $javaPackage $sha1 -cmd /c "$javaPackage /s SPONSORS=0" -echo "Cleaning $javaPackage.." -Remove-Item -Recurse -Force "$javaPackage" +Run-Executable "$javaPackage" "/s SPONSORS=0" +Write-Host "Cleaning $javaPackage.." +Remove-Item -Recurse -Force -Path "$javaPackage" -[Environment]::SetEnvironmentVariable("JAVA_HOME", "$installdir", [EnvironmentVariableTarget]::Machine) +Set-EnvironmentVariable "JAVA_HOME" "$installdir" Add-Path "$installdir\bin" -echo "Java SE = $version $arch" >> ~\versions.txt +Write-Output "Java SE = $version $arch" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/install-mingw.ps1 b/coin/provisioning/common/windows/install-mingw.ps1 index f3e96318..8b7fe41d 100644 --- a/coin/provisioning/common/windows/install-mingw.ps1 +++ b/coin/provisioning/common/windows/install-mingw.ps1 @@ -55,14 +55,13 @@ function InstallMinGW Download $url_official $url_cache $mingwPackage Verify-Checksum $mingwPackage $sha1 - Get-ChildItem $mingwPackage | % {& "C:\Utils\sevenzip\7z.exe" "x" $_.fullname "-o$TARGETDIR"} + Extract-7Zip $mingwPackage $TARGETDIR - echo "Adding MinGW environment variable." - [Environment]::SetEnvironmentVariable("$envvar", "$targetdir\mingw" + $win_arch.Substring($win_arch.get_Length()-2), [EnvironmentVariableTarget]::Machine) + Set-EnvironmentVariable "$envvar" ("$targetdir\mingw" + $win_arch.Substring($win_arch.get_Length()-2)) - echo "Cleaning $mingwPackage.." - Remove-Item -Recurse -Force "$mingwPackage" + Write-Host "Cleaning $mingwPackage.." + Remove-Item -Recurse -Force -Path "$mingwPackage" - echo "MinGW = $version $release" >> ~\versions.txt + Write-Output "MinGW = $version $release" >> ~\versions.txt } diff --git a/coin/provisioning/common/windows/install-notepad++.ps1 b/coin/provisioning/common/windows/install-notepad++.ps1 index 4fad6f6d..8f8635b3 100644 --- a/coin/provisioning/common/windows/install-notepad++.ps1 +++ b/coin/provisioning/common/windows/install-notepad++.ps1 @@ -36,11 +36,10 @@ # This script will install Notepad++ $version = "7.3" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $arch = ".x64" $sha1 = "E7306DF1D6E81801FB4BE0868610DB70E979B0AA" -} -else { +} else { $arch = "" $sha1 = "d4c403675a21cc381f640b92e596bae3ef958dc6" } @@ -50,13 +49,12 @@ $nppPackage = "C:\Windows\Temp\npp-$version.exe" Download $url_official $url_cache $nppPackage Verify-Checksum $nppPackage $sha1 -cmd /c "$nppPackage /S" +Run-Executable "$nppPackage" "/S" -echo "Cleaning $nppPackage.." -Remove-Item -Recurse -Force "$nppPackage" +Write-Host "Cleaning $nppPackage.." +Remove-Item -Recurse -Force -Path "$nppPackage" -echo "Notepad++ = $version" >> ~\versions.txt +Write-Output "Notepad++ = $version" >> ~\versions.txt +Write-Host "Disabling auto updates." Rename-Item -Path "C:\Program Files\Notepad++\updater" -NewName "updater_disabled" - -echo "Auto-updating disabled." diff --git a/coin/provisioning/common/windows/install-ruby.ps1 b/coin/provisioning/common/windows/install-ruby.ps1 index 3a9aa0d2..d3b949d1 100644 --- a/coin/provisioning/common/windows/install-ruby.ps1 +++ b/coin/provisioning/common/windows/install-ruby.ps1 @@ -36,11 +36,10 @@ # This script will install Ruby $version = "2.4.2-2" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $arch = "-x64" $sha1 = "c961c2752a183487bc42ed24beb7e931230fa7d5" -} -else { +} else { $arch = "-x86" $sha1 = "2639a481c3b5ad11f57d5523cc41ca884286089e" } @@ -50,9 +49,9 @@ $rubyPackage = "C:\Windows\Temp\rubyinstaller-$version.exe" Download $url_official $url_cache $rubyPackage Verify-Checksum $rubyPackage $sha1 -Start-Process -FilePath $rubyPackage -ArgumentList "/dir=C:\Ruby-$version$arch /tasks=modpath /verysilent" -Wait +Run-Executable $rubyPackage "/dir=C:\Ruby-$version$arch /tasks=modpath /verysilent" -echo "Cleaning $rubyPackage.." -Remove-Item -Recurse -Force "$rubyPackage" +Write-Host "Cleaning $rubyPackage.." +Remove-Item -Recurse -Force -Path "$rubyPackage" -echo "Ruby = $version" >> ~\versions.txt +Write-Output "Ruby = $version" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/install-sevenzip.ps1 b/coin/provisioning/common/windows/install-sevenzip.ps1 index e7e73e9c..914895c1 100644 --- a/coin/provisioning/common/windows/install-sevenzip.ps1 +++ b/coin/provisioning/common/windows/install-sevenzip.ps1 @@ -38,11 +38,10 @@ $version = "16.04" $nonDottedVersion = "1604" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $arch = "-x64" $sha1 = "338A5CC5200E98EDD644FC21807FDBE59910C4D0" -} -else { +} else { $arch = "" $sha1 = "dd1cb1163c5572951c9cd27f5a8dd550b33c58a4" } @@ -54,11 +53,11 @@ $7zTargetLocation = "C:\Utils\sevenzip\" Download $url_official $url_cache $7zPackage Verify-Checksum $7zPackage $sha1 -Start-Process -FilePath $7zPackage -ArgumentList "/S","/D=$7zTargetLocation" -Wait +Run-Executable $7zPackage "/S","/D=$7zTargetLocation" -echo "Cleaning $7zPackage.." -Remove-Item -Recurse -Force "$7zPackage" +Write-Host "Cleaning $7zPackage.." +Remove-Item -Recurse -Force -Path "$7zPackage" Add-Path $7zTargetLocation -echo "7-Zip = $version" >> ~\versions.txt +Write-Output "7-Zip = $version" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/install-strawberry-perl.ps1 b/coin/provisioning/common/windows/install-strawberry-perl.ps1 index 8b4a4a25..c80f16a4 100644 --- a/coin/provisioning/common/windows/install-strawberry-perl.ps1 +++ b/coin/provisioning/common/windows/install-strawberry-perl.ps1 @@ -36,23 +36,23 @@ # This script installs Strawberry Perl $version = "5.26.0.1" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $arch = "-64bit" $sha1 = "2AE2EDA36A190701399130CBFEE04D00E9BA036D" -} -else { +} else { $arch = "-32bit" $sha1 = "b50b688a879f33941433774b2813bfd4b917e4ee" } -$url_cache = "\\ci-files01-hki.intra.qt.io\provisioning\windows\strawberry-perl-" + $version + $arch + ".msi" -$url_official = "http://strawberryperl.com/download/" + $version + "/strawberry-perl-" + $version + $arch + ".msi" -$strawberryPackage = "C:\Windows\Temp\strawberry-installer-$version.msi" +$installer_name = "strawberry-perl-" + $version + $arch + ".msi" +$url_cache = "\\ci-files01-hki.intra.qt.io\provisioning\windows\" + $installer_name +$url_official = "http://strawberryperl.com/download/" + $version + "/" + $installer_name +$strawberryPackage = "C:\Windows\Temp\" + $installer_name Download $url_official $url_cache $strawberryPackage Verify-Checksum $strawberryPackage $sha1 -cmd /c "$strawberryPackage /QB INSTALLDIR=C:\strawberry REBOOT=REALLYSUPPRESS" +Run-Executable "$strawberryPackage" "/QB INSTALLDIR=C:\strawberry REBOOT=REALLYSUPPRESS" -echo "Cleaning $strawberryPackage.." -Remove-Item -Recurse -Force "$strawberryPackage" +Write-Host "Cleaning $strawberryPackage.." +Remove-Item -Recurse -Force -Path "$strawberryPackage" -echo "strawberry = $version" >> ~\versions.txt +Write-Output "strawberry = $version" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/jom.ps1 b/coin/provisioning/common/windows/jom.ps1 index c1e2cbf7..efdbb97d 100644 --- a/coin/provisioning/common/windows/jom.ps1 +++ b/coin/provisioning/common/windows/jom.ps1 @@ -6,4 +6,4 @@ Invoke-WebRequest -UseBasicParsing http://download.qt.io/official_releases/jom/j Verify-Checksum $zip "80EE5678E714DE99DDAF5F7593AB04DB1C7928E4" Extract-Zip $zip C:\Utils\Jom -[Environment]::SetEnvironmentVariable("CI_JOM_PATH", "C:\Utils\Jom", "Machine") +Set-EnvironmentVariable "CI_JOM_PATH" "C:\Utils\Jom" diff --git a/coin/provisioning/common/windows/libclang.ps1 b/coin/provisioning/common/windows/libclang.ps1 index 5a25d2eb..84d3656f 100644 --- a/coin/provisioning/common/windows/libclang.ps1 +++ b/coin/provisioning/common/windows/libclang.ps1 @@ -22,9 +22,9 @@ if ( $archVer -eq 64 ) { Download $url $url $zip Verify-Checksum $zip $sha1 - C:\Utils\sevenzip\7z.exe x $zip -oC:\Utils\ + Extract-7Zip $zip C:\Utils\ Rename-Item C:\Utils\libclang $destination - del $zip + Remove-Item -Force -Path $zip } $sha1 = "64e826c00ae632fbb28655e6e1fa9194980e1205" @@ -34,9 +34,9 @@ $destination = $baseDestination + "-32" Download $url $url $zip Verify-Checksum $zip $sha1 -C:\Utils\sevenzip\7z.exe x $zip -oC:\Utils\ +Extract-7Zip $zip C:\Utils\ Rename-Item C:\Utils\libclang $destination -del $zip +Remove-Item -Force -Path $zip -[Environment]::SetEnvironmentVariable("LLVM_INSTALL_DIR", $baseDestination + "-_ARCH_", [EnvironmentVariableTarget]::Machine) -echo "libClang = $libclang_version" >> ~/versions.txt +Set-EnvironmentVariable "LLVM_INSTALL_DIR" ($baseDestination + "-_ARCH_") +Write-Output "libClang = $libclang_version" >> ~/versions.txt diff --git a/coin/provisioning/common/windows/libusb.ps1 b/coin/provisioning/common/windows/libusb.ps1 index 38d8b8e6..d5340484 100644 --- a/coin/provisioning/common/windows/libusb.ps1 +++ b/coin/provisioning/common/windows/libusb.ps1 @@ -44,4 +44,4 @@ Verify-Checksum $archive "396a3224c306480f24a583850d923d06aa4377c1" Extract-7Zip $archive $libusb_location # Tell qt-apps/qdb build system where to find libusb -[Environment]::SetEnvironmentVariable("LIBUSB_PATH", $libusb_location, "Machine") +Set-EnvironmentVariable "LIBUSB_PATH" $libusb_location diff --git a/coin/provisioning/common/windows/memorypershell.ps1 b/coin/provisioning/common/windows/memorypershell.ps1 index 2a8ebb68..6bc3c559 100644 --- a/coin/provisioning/common/windows/memorypershell.ps1 +++ b/coin/provisioning/common/windows/memorypershell.ps1 @@ -1,3 +1,3 @@ # This is needed e.g. for Android NDK installation for Windows 7 x86 -echo "Increase value of MaxMemoryPerShellMB to avoid 'out of memory' exception" +Write-Host "Increase value of MaxMemoryPerShellMB to avoid 'out of memory' exception" set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048 diff --git a/coin/provisioning/common/windows/mesa_llvmpipe.ps1 b/coin/provisioning/common/windows/mesa_llvmpipe.ps1 index 4a468e10..3f688f4c 100644 --- a/coin/provisioning/common/windows/mesa_llvmpipe.ps1 +++ b/coin/provisioning/common/windows/mesa_llvmpipe.ps1 @@ -47,14 +47,15 @@ function Extract-Mesa [string]$targetFolder ) Write-Host "Installing Mesa from $downloadUrl to $targetFolder" - $localArchivePath = "C:\Windows\temp\opengl32sw.7z" - Invoke-WebRequest -UseBasicParsing $downloadUrl -OutFile $localArchivePath - Verify-Checksum $localArchivePath $sha1 - Get-ChildItem $package | % {& "C:\Utils\sevenzip\7z.exe" "x" "-y" $_.fullname "-o$targetFolder"} - Remove-Item $localArchivePath + Write-Host "Downloading $downloadUrl to $package" + Invoke-WebRequest -UseBasicParsing $downloadUrl -OutFile $package + Verify-Checksum $package $sha1 + Extract-7Zip $package $targetFolder + Write-Host "Removing $package" + Remove-Item -Path $package } -if ( Test-Path C:\Windows\SysWOW64 ) { +if (Is64BitWinHost) { Extract-Mesa $mesaOpenglUrl_64 $mesaOpenglSha1_64 "C:\Windows\System32" Extract-Mesa $mesaOpenglUrl_32 $mesaOpenglSha1_32 "C:\Windows\SysWOW64" } else { diff --git a/coin/provisioning/common/windows/mqtt_broker.ps1 b/coin/provisioning/common/windows/mqtt_broker.ps1 index 35bb9823..b88f568e 100644 --- a/coin/provisioning/common/windows/mqtt_broker.ps1 +++ b/coin/provisioning/common/windows/mqtt_broker.ps1 @@ -33,7 +33,7 @@ . "$PSScriptRoot\helpers.ps1" -echo "MQTT: Downloading Paho test broker..." +Write-Host "MQTT: Downloading Paho test broker..." $zip = "c:\users\qt\downloads\pahotest.zip" $externalUrl = "http://ci-files01-hki.ci.local/input/mqtt_broker/paho.mqtt.testing-c342c09dadc7a664d0a8befad1ca031f5a0b0bc0.zip" $internalUrl = "https://github.com/eclipse/paho.mqtt.testing/archive/c342c09dadc7a664d0a8befad1ca031f5a0b0bc0.zip" @@ -42,9 +42,8 @@ $sha1 = "532fe145096cdd8d679f425cbfd883289150c968" Download $externalUrl $internalUrl $zip Verify-Checksum $zip $sha1 -echo "MQTT: Installing $zip..." +Write-Host "MQTT: Installing $zip..." Extract-Zip $zip C:\Utils -Remove-Item $zip +Remove-Item -Path $zip -echo "MQTT: Updating environment..." -[Environment]::SetEnvironmentVariable("MQTT_TEST_BROKER_LOCATION", "C:\Utils\paho.mqtt.testing-c342c09dadc7a664d0a8befad1ca031f5a0b0bc0\interoperability\startbroker.py", "Machine") +Set-EnvironmentVariable "MQTT_TEST_BROKER_LOCATION" "C:\Utils\paho.mqtt.testing-c342c09dadc7a664d0a8befad1ca031f5a0b0bc0\interoperability\startbroker.py" diff --git a/coin/provisioning/common/windows/msvc_2015_update3_patch.ps1 b/coin/provisioning/common/windows/msvc_2015_update3_patch.ps1 index bab0f3a1..3a351f41 100644 --- a/coin/provisioning/common/windows/msvc_2015_update3_patch.ps1 +++ b/coin/provisioning/common/windows/msvc_2015_update3_patch.ps1 @@ -36,25 +36,31 @@ # Original download page: https://msdn.microsoft.com/en-us/library/mt752379.aspx $version = "2015 update3 (KB3165756)" -$package = "C:\Windows\Temp\vs14-kb3165756.exe" +$packagePath = "C:\Windows\Temp" +$package = $packagePath + "\vs14-kb3165756.exe" $url_cache = "http://ci-files01-hki.intra.qt.io/input/windows/vs14-kb3165756.exe" $url_official = "http://go.microsoft.com/fwlink/?LinkID=816878" $sha1 = "6a21d9b291ca75d44baad95e278fdc0d05d84c02" -$preparedPackage="\\ci-files01-hki.intra.qt.io\provisioning\windows\vs14-kb3165756-update" +$preparedPackage = "\\ci-files01-hki.intra.qt.io\provisioning\windows\vs14-kb3165756-update" if (Test-Path $preparedPackage) { - echo "Using prepared package" - pushd $preparedPackage - $commandLine = "$preparedPackage\vs14-kb3165756.exe" + # The prepared package contains updated packages so that not everything has to be downloaded + Write-Host "Using prepared package" + Copy-Item -Recurse $preparedPackage $packagePath + exit 0 + # Remove the whole downloaded folder + $toRemove = $packagePath + "\vs14-kb3165756-update" + $executable = "$toRemove\vs14-kb3165756.exe" } else { - echo "Fetching patch for Visual Studio $version..." + Write-Host "Fetching patch for Visual Studio $version..." Download $url_official $url_cache $package - Verify-Checksum $package $sha1 - $commandLine = $package + $executable = $package + # Remove the downloaded executable + $toRemove = $executable } -echo "Installing patch for Visual Studio $version..." -. $commandLine /norestart /passive -if ($commandLine.StartsWith("C:\Windows")) { - remove-item $package -} +Verify-Checksum $executable $sha1 +Write-Host "Installing patch for Visual Studio $version..." +Run-Executable $executable "/norestart /passive" + +Remove-Item -Force -Recurse -Path $toRemove diff --git a/coin/provisioning/common/windows/mysql.ps1 b/coin/provisioning/common/windows/mysql.ps1 index 63088861..a22e439a 100644 --- a/coin/provisioning/common/windows/mysql.ps1 +++ b/coin/provisioning/common/windows/mysql.ps1 @@ -48,16 +48,16 @@ function DownloadAndInstall [string]$installPath ) - echo "Fetching from URL ..." + Write-Host "Fetching from URL ..." Copy-Item $internalUrl $package $zipDir = [io.path]::GetFileNameWithoutExtension($package) Extract-Dev-Folders-From-Zip $package $zipDir $installPath - Remove-Item $package + Remove-Item -Path $package } -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { # Install x64 bit version $architecture = "x64" $installFolder = "C:\Utils\my_sql\my_sql" @@ -65,26 +65,23 @@ if( (is64bitWinHost) -eq 1 ) { DownloadAndInstall $internalUrl $packagex64 $installFolder - echo "Set environment variables ..." - [Environment]::SetEnvironmentVariable("MYSQL_INCLUDE_x64", "$installFolder\include", "Machine") - [Environment]::SetEnvironmentVariable("MYSQL_LIB_x64", "$installFolder\lib", "Machine") + Set-EnvironmentVariable "MYSQL_INCLUDE_x64" "$installFolder\include" + Set-EnvironmentVariable "MYSQL_LIB_x64" "$installFolder\lib" } # Install x86 bit version $architecture = "x86" $internalUrl = "\\ci-files01-hki.intra.qt.io\provisioning\windows\mysql-$version-win32.zip" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $installFolder = "C:\Utils\my_sql\my_sql$architecture" -} -else { +} else { $installFolder = "C:\Utils\my_sql\my_sql" } DownloadAndInstall $internalUrl $packagex86 $installFolder -echo "Set environment variables ..." -[Environment]::SetEnvironmentVariable("MYSQL_INCLUDE_x86", "$installFolder\include", "Machine") -[Environment]::SetEnvironmentVariable("MYSQL_LIB_x86", "$installFolder\lib", "Machine") +Set-EnvironmentVariable "MYSQL_INCLUDE_x86" "$installFolder\include" +Set-EnvironmentVariable "MYSQL_LIB_x86" "$installFolder\lib" # Store version information to ~/versions.txt, which is used to print version information to provision log. -echo "MySQL = $version" >> ~/versions.txt +Write-Output "MySQL = $version" >> ~/versions.txt diff --git a/coin/provisioning/common/windows/ninja.ps1 b/coin/provisioning/common/windows/ninja.ps1 index 08bf2579..dd60ad69 100644 --- a/coin/provisioning/common/windows/ninja.ps1 +++ b/coin/provisioning/common/windows/ninja.ps1 @@ -6,6 +6,6 @@ Download https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win Verify-Checksum $zip "E01093F6533818425F8EFB0843CED7DCAABEA3B2" Extract-Zip $zip C:\Utils\Ninja -Remove-Item $zip +Remove-Item -Path $zip Add-Path "C:\Utils\Ninja" 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 diff --git a/coin/provisioning/common/windows/postgresql.ps1 b/coin/provisioning/common/windows/postgresql.ps1 index ca47f078..b9681809 100644 --- a/coin/provisioning/common/windows/postgresql.ps1 +++ b/coin/provisioning/common/windows/postgresql.ps1 @@ -40,7 +40,7 @@ $version = "9.1.9-1" $packagex64 = "C:\Windows\temp\postgresql-$version-windows-x64-binaries.zip" $packagex86 = "C:\Windows\temp\postgresql-$version-windows-binaries.zip" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { # Install x64 bit versions $architecture = "x64" $installFolder = "C:\Utils\postgresql\pgsql" @@ -48,18 +48,17 @@ if( (is64bitWinHost) -eq 1 ) { $internalUrl = "\\ci-files01-hki.intra.qt.io\provisioning\windows\postgresql-$version-windows-x64-binaries.zip" $sha1 = "4da0453cdfda335e064d4437cf5bb9d356054cfd" - echo "Fetching from URL ..." + Write-Host "Fetching from URL ..." Download $externalUrl $internalUrl $packagex64 Verify-Checksum $packagex64 $sha1 - echo "Installing $packagex64 ..." + Write-Host "Installing $packagex64 ..." Extract-Dev-Folders-From-Zip $packagex64 "pgsql" $installFolder - echo "Remove downloaded $packagex64 ..." - Remove-Item $packagex64 + Write-Host "Remove downloaded $packagex64 ..." + Remove-Item -Path $packagex64 - echo "Set $architecture environment variables ..." - [Environment]::SetEnvironmentVariable("POSTGRESQL_INCLUDE_x64", "$installFolder\include", "Machine") - [Environment]::SetEnvironmentVariable("POSTGRESQL_LIB_x64", "$installFolder\lib", "Machine") + Set-EnvironmentVariable "POSTGRESQL_INCLUDE_x64" "$installFolder\include" + Set-EnvironmentVariable "POSTGRESQL_LIB_x64" "$installFolder\lib" } # Install x86 bit version @@ -67,26 +66,24 @@ $architecture = "x86" $externalUrl = "http://get.enterprisedb.com/postgresql/postgresql-$version-windows-binaries.zip" $internalUrl = "\\ci-files01-hki.intra.qt.io\provisioning\windows\postgresql-$version-windows-binaries.zip" $sha1 = "eb4f01845e1592800edbb74f60944b6c0aca51a9" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $installFolder = "C:\Utils\postgresql$architecture\pgsql" -} -else { +} else { $installFolder = "C:\Utils\postgresql\pgsql" } -echo "Fetching from URL..." +Write-Host "Fetching from URL..." Download $externalUrl $internalUrl $packagex86 Verify-Checksum $packagex86 $sha1 -echo "Installing $packagex86 ..." +Write-Host "Installing $packagex86 ..." Extract-Dev-Folders-From-Zip $packagex86 "pgsql" $installFolder -echo "Remove downloaded $packagex86 ..." -Remove-Item $packagex86 +Write-Host "Remove downloaded $packagex86 ..." +Remove-Item -Path $packagex86 -echo "Set $architecture environment variables ..." -[Environment]::SetEnvironmentVariable("POSTGRESQL_INCLUDE_x86", "$installFolder\include", "Machine") -[Environment]::SetEnvironmentVariable("POSTGRESQL_LIB_x86", "$installFolder\lib", "Machine") +Set-EnvironmentVariable "POSTGRESQL_INCLUDE_x86" "$installFolder\include" +Set-EnvironmentVariable "POSTGRESQL_LIB_x86" "$installFolder\lib" # Store version information to ~/versions.txt, which is used to print version information to provision log. -echo "PostgreSQL = $version" >> ~/versions.txt +Write-Output "PostgreSQL = $version" >> ~/versions.txt diff --git a/coin/provisioning/common/windows/python.ps1 b/coin/provisioning/common/windows/python.ps1 index fe75aa35..ae9cbbbd 100644 --- a/coin/provisioning/common/windows/python.ps1 +++ b/coin/provisioning/common/windows/python.ps1 @@ -36,11 +36,10 @@ # Python is required for building Qt 5 from source. $version = "2.7.13" -if( (is64bitWinHost) -eq 1 ) { +if (Is64BitWinHost) { $arch = ".amd64" $sha1 = "d9113142bae8829365c595735e1ad1f9f5e2894c" -} -else { +} else { $arch = "" $sha1 = "7e3b54236dbdbea8fe2458db501176578a4d59c0" } @@ -48,23 +47,25 @@ $package = "C:\Windows\temp\python-$version.msi" $externalUrl = "https://www.python.org/ftp/python/$version/python-$version" + $arch + ".msi" $internalUrl = "\\ci-files01-hki.intra.qt.io\provisioning\windows\python-$version" + $arch + ".msi" -echo "Fetching from URL..." +Write-Host "Fetching from URL..." Download $externalUrl $internalUrl $package Verify-Checksum $package $sha1 -echo "Installing $package..." -cmd /c "msiexec /passive /i $package ALLUSERS=1" +Write-Host "Installing $package..." +Run-Executable "msiexec" "/passive /i $package ALLUSERS=1" + # We need to change allowZip64 from 'False' to 'True' to be able to create ZIP files that use the ZIP64 extensions when the zipfile is larger than 2 GB -echo "Chancing allowZip64 value to 'True'..." +Write-Host "Changing allowZip64 value to 'True'..." (Get-Content C:\Python27\lib\zipfile.py) | ForEach-Object { $_ -replace "allowZip64=False", "allowZip64=True" } | Set-Content C:\Python27\lib\zipfile.py -echo "Remove $package..." -del $package +Write-Host "Remove $package..." +Remove-Item -Path $package Add-Path "C:\Python27;C:\Python27\Scripts" -C:\Python27\python.exe -m ensurepip +Run-Executable "C:\Python27\python.exe" "-m ensurepip" + # Install python virtual env -#if ( isProxyEnabled ) { -# echo "Using proxy with pip" +#if (isProxyEnabled) { +# Write-Host "Using proxy with pip" # $pip_args = "--proxy=" + (getProxy) #} -C:\Python27\Scripts\pip.exe install virtualenv +Run-Executable "C:\Python27\Scripts\pip.exe" "install virtualenv" diff --git a/coin/provisioning/common/windows/python3.ps1 b/coin/provisioning/common/windows/python3.ps1 index 23ddb553..0ea93133 100644 --- a/coin/provisioning/common/windows/python3.ps1 +++ b/coin/provisioning/common/windows/python3.ps1 @@ -32,7 +32,6 @@ ## ############################################################################# -param([Int32]$archVer=32) . "$PSScriptRoot\helpers.ps1" # This script installs Python $version. @@ -43,32 +42,31 @@ $package = "C:\Windows\temp\python-$version.exe" $install_path = "C:\Python36" # check bit version -if ( $archVer -eq 64 ) { - echo "Running in 64 bit system" +if (Is64BitWinHost) { + Write-Host "Running in 64 bit system" $externalUrl = "https://www.python.org/ftp/python/$version/python-$version-amd64.exe" $internalUrl = "http://ci-files01-hki.intra.qt.io/input/windows/python-$version-amd64.exe" $sha1 = "bf54252c4065b20f4a111cc39cf5215fb1edccff" -} -else { +} else { $externalUrl = "https://www.python.org/ftp/python/$version/python-$version.exe" $internalUrl = "http://ci-files01-hki.intra.qt.io/input/windows/python-$version.exe" $sha1 = "76c50b747237a0974126dd8b32ea036dd77b2ad1" } -echo "Fetching from URL..." +Write-Host "Fetching from URL..." Download $externalUrl $internalUrl $package Verify-Checksum $package $sha1 -echo "Installing $package..." -cmd /c "$package /q TargetDir=$install_path" -echo "Remove $package..." -del $package +Write-Host "Installing $package..." +Run-Executable "$package" "/q TargetDir=$install_path" +Write-Host "Remove $package..." +Remove-Item -Path $package -[Environment]::SetEnvironmentVariable("PYTHON3_PATH", "$install_path", [EnvironmentVariableTarget]::Machine) -[Environment]::SetEnvironmentVariable("PIP3_PATH", "$install_path\Scripts", [EnvironmentVariableTarget]::Machine) +Set-EnvironmentVariable "PYTHON3_PATH" "$install_path" +Set-EnvironmentVariable "PIP3_PATH" "$install_path\Scripts" # Install python virtual env -#if ( isProxyEnabled ) { -# echo "Using proxy with pip" +#if (isProxyEnabled) { +# Write-Host "Using proxy with pip" # $pip_args = "--proxy=" + (getProxy) #} -cmd /c "$install_path\Scripts\pip3.exe install virtualenv" +Run-Executable "$install_path\Scripts\pip3.exe" "install virtualenv" diff --git a/coin/provisioning/common/windows/set-proxy.ps1 b/coin/provisioning/common/windows/set-proxy.ps1 index 914769f1..2b985b09 100644 --- a/coin/provisioning/common/windows/set-proxy.ps1 +++ b/coin/provisioning/common/windows/set-proxy.ps1 @@ -36,27 +36,24 @@ $n = $n.Split('=') New-Variable -Name $n[0] -Value $n[1] if (([string]::IsNullOrEmpty($proxy)) -or ($proxy -eq '""')) { - echo "No proxy is defined." -} -else { - echo "Checking proxy @ $proxy" + Write-Host "No proxy is defined." +} else { + Write-Host "Checking proxy @ $proxy" $proxy = $proxy -replace '"', "" $webclient = New-Object System.Net.WebClient $proxy_obj = New-Object System.Net.WebProxy($proxy) $webclient.proxy = $proxy_obj try { $webpage = $webclient.DownloadData("http://proxy.intra.qt.io") - } - catch { + } catch { $ErrorMessage = $_.Exception.Message $FailedItem = $_.Exception.ItemName $iserror = $true } if ($iserror -eq $true) { - echo "Testing download with proxy does not work: $ErrorMessage, $FailedItem. Not setting proxy." - } - else { - echo "Setting proxy to: $proxy" + Write-Host "Testing download with proxy does not work: $ErrorMessage, $FailedItem. Not setting proxy." + } else { + Write-Host "Setting proxy to: $proxy" Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyServer -Value "$proxy" Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable -Value 1 Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyOverride -Value 10.215 diff --git a/coin/provisioning/common/windows/squishInstall.ps1 b/coin/provisioning/common/windows/squishInstall.ps1 index 509eb93f..504b0077 100644 --- a/coin/provisioning/common/windows/squishInstall.ps1 +++ b/coin/provisioning/common/windows/squishInstall.ps1 @@ -50,10 +50,10 @@ $licensePackage = ".squish-3-license" $OSVersion = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName # This can be removed when using vanilla os -if((Test-Path -Path "$targetDir" )){ +if ((Test-Path -Path "$targetDir" )) { try { - echo "Renaming old Squish" - echo "Rename-Item -ErrorAction 'Stop' $targetDir $targetDir_deleted" + Write-Host "Renaming old Squish" + Write-Host "Rename-Item -ErrorAction 'Stop' $targetDir $targetDir_deleted" Rename-Item -ErrorAction 'Stop' "$targetDir" squish_deleted } catch {} } @@ -72,13 +72,12 @@ Function DownloadAndInstallSquish { $SquishUrl = $squishBranchUrl + "\squish-" + $version + "-qt" + $qtBranch + "-" + $bit + "-" + $squishPackage + ".exe" $SquishInstaller = "$targetDir\$squishPackage.exe" $SquishParameters = "unattended=1 targetdir=$targetDir\$squishPackage" - $Command = "$SquishInstaller $SquishParameters" - echo "Fetching from URL ..." + Write-Host "Fetching from URL $squishUrl" Copy-Item "$SquishUrl" "$SquishInstaller" - echo "Installing Squish" - Execute-Command $Command - remove-item $SquishInstaller + Write-Host "Installing Squish" + Run-Executable "$SquishInstaller" "$SquishParameters" + Remove-Item -Path $SquishInstaller } Function DownloadSquishLicence { @@ -90,26 +89,24 @@ Function DownloadSquishLicence { ) # This can be removed when using vanilla os - if ($Env:SQUISH_LICENSEKEY_DIR) - { - echo "Removing SQUISH_LICENSEKEY_DIR env variable" + if ($Env:SQUISH_LICENSEKEY_DIR) { + Write-Host "Removing SQUISH_LICENSEKEY_DIR env variable" Remove-Item Env:\SQUISH_LICENSEKEY_DIR } - echo "Installing Squish license to home directory" + Write-Host "Installing Squish license to home directory" Copy-Item $squishUrl\$licensePackage ~\$licensePackage } -echo "Creating $targetDir" +Write-Host "Creating $targetDir" New-Item -ErrorAction Ignore -ItemType directory -Path "$targetDir" DownloadSquishLicence $licensePackage $squishUrl $targetDir -if(($OSVersion -eq "Windows 10 Enterprise") -or ($OSVersion -eq "Windows 8.1 Enterprise")) -{ +if (($OSVersion -eq "Windows 10 Enterprise") -or ($OSVersion -eq "Windows 8.1 Enterprise")) { # Squish for MinGW $squishPackageMingw = "mingw_gcc53_posix_dwarf" - echo "Installing $squishPackageMingw" + Write-Host "Installing $squishPackageMingw" DownloadAndInstallSquish $version $squishBranchUrl $qtBranch win32 $targetDir $squishPackageMingw mv $targetDir\$squishPackageMingw $targetDir\mingw @@ -117,56 +114,45 @@ if(($OSVersion -eq "Windows 10 Enterprise") -or ($OSVersion -eq "Windows 8.1 Ent $squishPackage = "msvc14" $squishPackage64bit = "msvc14_64" - if(($env:PROCESSOR_ARCHITECTURE -eq "AMD64") -or ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64")) - { - echo "Installing $squishPackage_64" + if (Is64BitWinHost) { + Write-Host "Installing $squishPackage64bit" DownloadAndInstallSquish $version $squishBranchUrl $qtBranch win64 $targetDir $squishPackage - mv $targetDir\$squishPackage $targetDir\$squishPackage64bit + Rename-Item $targetDir\$squishPackage $targetDir\$squishPackage64bit } - echo "Installing $squishPackage" + Write-Host "Installing $squishPackage" DownloadAndInstallSquish $version $squishBranchUrl $qtBranch win32 $targetDir $squishPackage } -if($OSVersion -eq "Windows 8.1 Enterprise") -{ +if ($OSVersion -eq "Windows 8.1 Enterprise") { # Squish for Visual Studio 2013 $squishPackage64bit = "msvc12_64" - if(($env:PROCESSOR_ARCHITECTURE -eq "AMD64") -or ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64")) - { - echo "Installing $squishPackage_64" + if (Is64BitWinHost) { + Write-Host "Installing $squishPackage_64" DownloadAndInstallSquish $version $squishBranchUrl $qtBranch win64 $targetDir $squishPackage - mv $targetDir\$squishPackage $targetDir\$squishPackage64bit - } - else - { - echo "Change secret file to normal one" - attrib -h C:\Users\qt\.squish-3-license + Rename-Item $targetDir\$squishPackage $targetDir\$squishPackage64bit + } else { + Write-Host "Change secret file to normal one" + Run-Executable "attrib.exe" "-h C:\Users\qt\.squish-3-license" } } -if($OSVersion -eq "Windows 7") -{ - # Windows 7 - +if ($OSVersion -eq "Windows 7 Enterprise") { # Squish for MinGW $squishPackageMingw = "mingw_gcc53_posix_dwarf" - echo "Installing $squishPackageMingw" + Write-Host "Installing $squishPackageMingw" DownloadAndInstallSquish $version $squishBranchUrl $qtBranch win32 $targetDir $squishPackageMingw - mv $targetDir\$squishPackageMingw $targetDir\mingw + Rename-Item $targetDir\$squishPackageMingw $targetDir\mingw # Squish for Visual Studio 2015 $squishPackage = "msvc14" $squishPackage64bit = "msvc14_64" - echo "Installing $squishPackage" + Write-Host "Installing $squishPackage" DownloadAndInstallSquish $version $squishBranchUrl $qtBranch win32 $targetDir $squishPackage - if(($env:PROCESSOR_ARCHITECTURE -eq "AMD64") -or ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64")) - { - echo "Installing $squishPackage64bit" + if (Is64BitWinHost) { + Write-Host "Installing $squishPackage64bit" DownloadAndInstallSquish $version $squishBranchUrl $qtBranch win64 $targetDir $squishPackage - mv $targetDir\$squishPackage $targetDir\$squishPackage64bit + Rename-Item $targetDir\$squishPackage $targetDir\$squishPackage64bit } - - } diff --git a/coin/provisioning/common/windows/unset-proxy.ps1 b/coin/provisioning/common/windows/unset-proxy.ps1 index 86374ec1..d0a374ef 100644 --- a/coin/provisioning/common/windows/unset-proxy.ps1 +++ b/coin/provisioning/common/windows/unset-proxy.ps1 @@ -31,7 +31,7 @@ ## ############################################################################# -echo "Disabling proxy" +Write-Host "Disabling proxy" $dcs = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections").DefaultConnectionSettings $dcs[8] = $_ -band 0xF7 Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" -Name DefaultConnectionSettings -Value $dcs diff --git a/coin/provisioning/common/windows/vc_redist.ps1 b/coin/provisioning/common/windows/vc_redist.ps1 index 4a8376b6..c356ca2c 100644 --- a/coin/provisioning/common/windows/vc_redist.ps1 +++ b/coin/provisioning/common/windows/vc_redist.ps1 @@ -32,21 +32,18 @@ ## ############################################################################# -param([Int32]$archVer=32) . "$PSScriptRoot\helpers.ps1" # This script installs Visual C++ Redistributable for Visual Studio 2015 # This is a dependency of the current python3 version -# check bit version -if ( $archVer -eq 64 ) { - echo "Running in 64 bit system" +if (Is64BitWinHost) { + Write-Host "Running in 64 bit system" $arch = "x64" $externalUrl = "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe" $internalUrl = "http://ci-files01-hki.intra.qt.io/input/windows/vc_redist.x64.exe" $sha1 = "3155cb0f146b927fcc30647c1a904cd162548c8c" -} -else { +} else { $arch = "x86" $externalUrl = "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe" $internalUrl = "http://ci-files01-hki.intra.qt.io/input/windows/vc_redist.x86.exe" @@ -55,10 +52,10 @@ else { $package = "C:\Windows\temp\vc_redist.$arch.exe" -echo "Fetching from URL..." +Write-Host "Fetching from URL..." Download $externalUrl $internalUrl $package Verify-Checksum $package $sha1 -echo "Installing $package..." -Start-Process -FilePath $package -ArgumentList "/q" -Wait -echo "Remove $package..." -del $package +Write-Host "Installing $package..." +Run-Executable $package "/q" +Write-Host "Remove $package..." +Remove-Item -Force -Path $package diff --git a/coin/provisioning/common/windows/vulkansdk.ps1 b/coin/provisioning/common/windows/vulkansdk.ps1 index bade33ef..1629e676 100644 --- a/coin/provisioning/common/windows/vulkansdk.ps1 +++ b/coin/provisioning/common/windows/vulkansdk.ps1 @@ -40,9 +40,9 @@ $url_cache = "\\ci-files01-hki.ci.local\provisioning\windows\VulkanSDK-" +$versi $vulkanPackage = "C:\Windows\Temp\vulkan-installer-$version.exe" Copy-Item $url_cache $vulkanPackage -cmd /c "$vulkanPackage /S" +Run-Executable $vulkanPackage "/S" -echo "Cleaning $vulkanPackage.." -Remove-Item -Recurse -Force "$vulkanPackage" +Write-Host "Cleaning $vulkanPackage.." +Remove-Item -Recurse -Force -Path "$vulkanPackage" -echo "Vulkan SDK = $version" >> ~\versions.txt +Write-Output "Vulkan SDK = $version" >> ~\versions.txt diff --git a/coin/provisioning/common/windows/win10-enable-devmode.ps1 b/coin/provisioning/common/windows/win10-enable-devmode.ps1 index 2d7733c0..9b2d5cc1 100644 --- a/coin/provisioning/common/windows/win10-enable-devmode.ps1 +++ b/coin/provisioning/common/windows/win10-enable-devmode.ps1 @@ -3,14 +3,12 @@ # In order to run auto tests for UWP, we have to enable developer mode on Windows 10 machines. # https://docs.microsoft.com/en-us/windows/uwp/get-started/enable-your-device-for-development -if ([environment]::Is64BitOperatingSystem) { +. "$PSScriptRoot\helpers.ps1" + +if (Is64BitWinHost) { $bitness = "/reg:64" } else { $bitness = "/reg:32" } -REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /V AllowDevelopmentWithoutDevLicense /T REG_DWORD /D 1 /F $bitness -if ($LastExitCode -ne 0) { - Write-Host "Could not enable Developer Mode." - exit 1 -} +Run-Executable "reg.exe" "ADD `"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock`" /V AllowDevelopmentWithoutDevLicense /T REG_DWORD /D 1 /F $bitness" diff --git a/coin/provisioning/common/windows/winrtrunner.ps1 b/coin/provisioning/common/windows/winrtrunner.ps1 index d53c12d6..89a64344 100644 --- a/coin/provisioning/common/windows/winrtrunner.ps1 +++ b/coin/provisioning/common/windows/winrtrunner.ps1 @@ -6,6 +6,6 @@ $url = "http://download.qt.io/development_releases/prebuilt/winrtrunner/winrtrun Download $url $url $zip Verify-Checksum $zip "C19098A4C9DBD20EDEB4E5E0D3E6A5BBBCA73C42" Extract-Zip $zip C:\Utils\winrtrunner -Remove-Item $zip +Remove-Item -Path $zip -[Environment]::SetEnvironmentVariable("CI_WINRTRUNNER_PATH", "C:\Utils\winrtrunner", "Machine") +Set-EnvironmentVariable "CI_WINRTRUNNER_PATH" "C:\Utils\winrtrunner" diff --git a/coin/provisioning/common/windows/wsearch-off.ps1 b/coin/provisioning/common/windows/wsearch-off.ps1 index 09c45bbd..12e959bd 100644 --- a/coin/provisioning/common/windows/wsearch-off.ps1 +++ b/coin/provisioning/common/windows/wsearch-off.ps1 @@ -1,3 +1,4 @@ +. "$PSScriptRoot\helpers.ps1" # Disable the windows search indexing service -sc.exe config WSearch start= disabled +Run-Executable "sc.exe" "config WSearch start= disabled" -- cgit v1.2.3