From dbdc50464b29c21d1e7c22301f0599e0390905ad Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Thu, 16 Apr 2020 19:29:18 +0300 Subject: [PATCH 1/8] Improve Install-CloudFoundryCli.ps1 --- .../Installers/Install-CloudFoundryCli.ps1 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 b/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 index cc1f0b5c29..194ed5a386 100644 --- a/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 +++ b/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 @@ -6,19 +6,18 @@ Import-Module -Name ImageHelpers # Download the latest cf cli exe -Invoke-WebRequest -UseBasicParsing -Uri "https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github" -OutFile cf-cli.zip +$CloudFoundryCliName = "cf-cli.zip" +$CloudFoundryCliUrl = "https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github" + +$CloudFoundryArchPath = Start-DownloadWithRetry -Url $CloudFoundryCliUrl -Name $CloudFoundryCliName # Create directory for cf cli -$cf_cli_path = "C:\cf-cli" -New-Item -Path $cf_cli_path -ItemType Directory -Force +$CloudFoundryCliPath = "C:\cf-cli" +New-Item -Path $CloudFoundryCliPath -ItemType Directory -Force # Extract the zip archive Write-Host "Extracting cf cli..." -Expand-Archive -Path cf-cli.zip -DestinationPath $cf_cli_path -Force +Expand-Archive -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath -Force # Add cf to path -Add-MachinePathItem $cf_cli_path - -# Delete the cfl-cli zip archive -Write-Host "Deleting downloaded archive of cf cli" -Remove-Item cf-cli.zip +Add-MachinePathItem $CloudFoundryCliPath \ No newline at end of file From a9e0a9651e5632d375414332af245af4cc5b5eb7 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Thu, 16 Apr 2020 19:29:45 +0300 Subject: [PATCH 2/8] Improve Install-Go.ps1 --- images/win/scripts/Installers/Install-Go.ps1 | 28 ++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/images/win/scripts/Installers/Install-Go.ps1 b/images/win/scripts/Installers/Install-Go.ps1 index db186186d8..6d98ef800f 100644 --- a/images/win/scripts/Installers/Install-Go.ps1 +++ b/images/win/scripts/Installers/Install-Go.ps1 @@ -6,12 +6,13 @@ Import-Module -Name ImageHelpers -Force $refsJson = Invoke-RestMethod "https://api.github.com/repos/golang/go/git/refs/tags" + function Install-GoVersion { Param ( - [String]$goVersion, - [Switch]$addToDefaultPath + [String] $goVersion, + [Switch] $addToDefaultPath ) $latestVersionObject = $refsJson | Where-Object { $_.ref -Match "refs/tags/go$goVersion[./d]*" } | Select-Object -Last 1 @@ -20,11 +21,15 @@ function Install-GoVersion # Download the Go zip archive. Write-Host "Downloading Go $latestVersion..." $ProgressPreference = 'SilentlyContinue' - Invoke-WebRequest -UseBasicParsing -Uri "https://dl.google.com/go/go$latestVersion.windows-amd64.zip" -OutFile go$latestVersion.windows-amd64.zip + + $goArchName = "go${latestVersion}.windows-amd64.zip" + $goArchUrl = "https://dl.google.com/go/${goArchName}" + + $goArchPath = Start-DownloadWithRetry -Url $goArchUrl -Name $goArchName # Extract the zip archive. It contains a single directory named "go". Write-Host "Extracting Go $latestVersion..." - Expand-Archive -Path go$latestVersion.windows-amd64.zip -DestinationPath "C:\" -Force + Expand-Archive -Path $goArchPath -DestinationPath "C:\" -Force # Delete unnecessary files to conserve space Write-Host "Cleaning directories of Go $latestVersion..." @@ -41,10 +46,6 @@ function Install-GoVersion $newDirName = "Go$latestVersion" Rename-Item -path "C:\go" -newName $newDirName - # Delete the Go zip archive. - Write-Host "Deleting downloaded archive of Go $latestVersion..." - Remove-Item go$latestVersion.windows-amd64.zip - # Make this the default version of Go? if ($addToDefaultPath) { @@ -63,13 +64,18 @@ function Install-GoVersion # Install Go $goVersionsToInstall = $env:GO_VERSIONS.split(", ", [System.StringSplitOptions]::RemoveEmptyEntries) -foreach($go in $goVersionsToInstall) { +foreach ($go in $goVersionsToInstall) +{ Write-Host "Installing Go ${go}" - if($go -eq $env:GO_DEFAULT) { + if ($go -eq $env:GO_DEFAULT) + { $installDirectory = Install-GoVersion -goVersion $go -addToDefaultPath - } else { + } + else + { $installDirectory = Install-GoVersion -goVersion $go } + $envName = "GOROOT_{0}_{1}_X64" -f $go.split(".") setx $envName "$installDirectory" /M } From bc3623f806d35e614637dab2fcb5277d5b944f2a Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Thu, 16 Apr 2020 19:30:08 +0300 Subject: [PATCH 3/8] Improve Install-Kind.ps1 --- images/win/scripts/Installers/Install-Kind.ps1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/images/win/scripts/Installers/Install-Kind.ps1 b/images/win/scripts/Installers/Install-Kind.ps1 index 6093049b35..12f0caa04c 100644 --- a/images/win/scripts/Installers/Install-Kind.ps1 +++ b/images/win/scripts/Installers/Install-Kind.ps1 @@ -6,25 +6,24 @@ $stableKindTag = "v0.7.0" $tagToUse = $stableKindTag; $destFilePath = "C:\ProgramData\kind" -$outFilePath = "C:\ProgramData\kind\kind.exe" try { - $getkindUri = "https://github.com/kubernetes-sigs/kind/releases/download/$tagToUse/kind-windows-amd64" + $kindUrl = "https://github.com/kubernetes-sigs/kind/releases/download/$tagToUse/kind-windows-amd64" + Write-Host "Downloading kind.exe..." New-Item -Path $destFilePath -ItemType Directory -Force - Invoke-WebRequest -Uri $getkindUri -OutFile $outFilePath + $kindInstallerPath = Start-DownloadWithRetry -Url $kindUrl -Name "kind.exe" -DownloadPath $destFilePath Write-Host "Starting Install kind.exe..." - $process = Start-Process -FilePath $outFilePath -Wait -PassThru + $process = Start-Process -FilePath $kindInstallerPath -Wait -PassThru $exitCode = $process.ExitCode if ($exitCode -eq 0 -or $exitCode -eq 3010) { Write-Host -Object 'Installation successful' Add-MachinePathItem $destFilePath - exit $exitCode } else { From dc237bb61f2b563092ac4bcb3e935c36891be1fb Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Thu, 16 Apr 2020 19:30:41 +0300 Subject: [PATCH 4/8] Improve Install-MysqlCli.ps1 --- .../scripts/Installers/Install-MysqlCli.ps1 | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/images/win/scripts/Installers/Install-MysqlCli.ps1 b/images/win/scripts/Installers/Install-MysqlCli.ps1 index 76930d6e34..a9db2f4295 100644 --- a/images/win/scripts/Installers/Install-MysqlCli.ps1 +++ b/images/win/scripts/Installers/Install-MysqlCli.ps1 @@ -3,37 +3,26 @@ ## Desc: Install Mysql CLI ################################################################################ - ## Downloading mysql jar -$uri = 'https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-winx64.zip' -$mysqlPath = 'C:\mysql-5.7.21-winx64\bin' +$MysqlVersionName = "mysql-5.7.21-winx64" +$MysqlVersionUrl = "https://dev.mysql.com/get/Downloads/MySQL-5.7/${MysqlVersionName}.zip" +$MysqlPath = "C:\$MysqlVersionName\bin" # Installing visual c++ redistibutable package. -$InstallerURI = 'https://download.microsoft.com/download/0/5/6/056dcda9-d667-4e27-8001-8a0c6971d6b1/vcredist_x64.exe' -$InstallerName = 'vcredist_x64.exe' -$ArgumentList = ('/install', '/quiet', '/norestart' ) - -$exitCode = Install-EXE -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList -if ($exitCode -eq 0 -or $exitCode -eq 3010) -{ - # MySQL disabled TLS 1.0 support on or about Jul-14-2018. Need to make sure TLS 1.2 is enabled. - [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" +$InstallerName = "vcredist_x64.exe" +$InstallerURI = "https://download.microsoft.com/download/0/5/6/056dcda9-d667-4e27-8001-8a0c6971d6b1/${InstallerName}" +$ArgumentList = ("/install", "/quiet", "/norestart") - # Get the latest mysql command line tools . - Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile mysql.zip +Install-Binary -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList - # Expand the zip - Expand-Archive -Path mysql.zip -DestinationPath "C:\" -Force +# MySQL disabled TLS 1.0 support on or about Jul-14-2018. Need to make sure TLS 1.2 is enabled. +[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" - # Deleting zip folder - Remove-Item -Recurse -Force mysql.zip +# Get the latest mysql command line tools . +$mysqlArchPath = Start-DownloadWithRetry -Url $MysqlVersionUrl -Name "mysql.zip" - # Adding mysql in system environment path - Add-MachinePathItem $mysqlPath +# Expand the zip +Expand-Archive -Path $mysqlArchPath -DestinationPath "C:\" -Force - return 0; -} -else -{ - return $exitCode; -} +# Adding mysql in system environment path +Add-MachinePathItem $mysqlPath \ No newline at end of file From 4629c4e877dd02e67406b48f2aaecee2c758f0a2 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Thu, 16 Apr 2020 19:31:05 +0300 Subject: [PATCH 5/8] Improve Install-Rust.ps1 --- images/win/scripts/Installers/Install-Rust.ps1 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/images/win/scripts/Installers/Install-Rust.ps1 b/images/win/scripts/Installers/Install-Rust.ps1 index 61588a86f9..ae18371afd 100644 --- a/images/win/scripts/Installers/Install-Rust.ps1 +++ b/images/win/scripts/Installers/Install-Rust.ps1 @@ -11,13 +11,10 @@ $env:CARGO_HOME="C:\Rust\.cargo" # Download the latest rustup-init.exe for Windows x64 # See https://rustup.rs/# -Invoke-WebRequest -UseBasicParsing -Uri "https://win.rustup.rs/x86_64" -OutFile rustup-init.exe +$rustupPath = Start-DownloadWithRetry -Url "https://win.rustup.rs/x86_64" -Name "rustup-init.exe" # Install Rust by running rustup-init.exe (disabling the confirmation prompt with -y) -.\rustup-init.exe -y --default-toolchain=stable --profile=minimal - -# Delete rustup-init.exe when it's no longer needed -Remove-Item -Path .\rustup-init.exe +& $rustupPath -y --default-toolchain=stable --profile=minimal # Add Rust binaries to the path Add-MachinePathItem "$env:CARGO_HOME\bin" From f1b1a52522b8b7ca1a8c0d7989b2809d6439a75a Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Thu, 16 Apr 2020 19:31:40 +0300 Subject: [PATCH 6/8] Improve Install-SQLPowerShellTools.ps1 --- .../Installers/Install-SQLPowerShellTools.ps1 | 58 ++++--------------- 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 b/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 index bf330f6907..8369a9944f 100644 --- a/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 +++ b/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 @@ -5,57 +5,21 @@ Import-Module -Name ImageHelpers -Force -Function InstallMSI -{ - Param - ( - [String]$MsiUrl, - [String]$MsiName - ) - - $exitCode = -1 - - try - { - Write-Host "Downloading $MsiName..." - $FilePath = "${env:Temp}\$MsiName" - - Invoke-WebRequest -Uri $MsiUrl -OutFile $FilePath - - $Arguments = ('/i', $FilePath, '/QN', '/norestart' ) - - Write-Host "Starting Install $MsiName..." - $process = Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -PassThru - $exitCode = $process.ExitCode - - if ($exitCode -eq 0 -or $exitCode -eq 3010) - { - Write-Host -Object 'Installation successful' - return $exitCode - } - else - { - Write-Host -Object "Non zero exit code returned by the installation process : $exitCode." - exit $exitCode - } - } - catch - { - Write-Host -Object "Failed to install the MSI $MsiName" - Write-Host -Object $_.Exception.Message - exit -1 - } -} +$BaseUrl = "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64" # install required MSIs -$SQLSysClrTypesExitCode = InstallMSI -MsiUrl "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64/SQLSysClrTypes.msi" -MsiName "SQLSysClrTypes.msi" +$SQLSysClrTypesName = "SQLSysClrTypes.msi" +$SQLSysClrTypesUrl = "${BaseUrl}/${SQLSysClrTypesName}" +Install-Binary -Url $SQLSysClrTypesUrl -Name $SQLSysClrTypesName -$SharedManagementObjectsExitCode = InstallMSI -MsiUrl "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64/SharedManagementObjects.msi" -MsiName "SharedManagementObjects.msi" +$SharedManagementObjectsName = "SharedManagementObjects.msi" +$SharedManagementObjectsUrl = "${BaseUrl}/${SharedManagementObjectsName}" +Install-Binary -Url $SharedManagementObjectsUrl -Name $SharedManagementObjectsName -$PowerShellToolsExitCode = InstallMSI -MsiUrl "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64/PowerShellTools.msi" -MsiName "PowerShellTools.msi" +$PowerShellToolsName = "PowerShellTools.msi" +$PowerShellToolsUrl = "${BaseUrl}/${PowerShellToolsName}" +Install-Binary -Url $PowerShellToolsUrl -Name $PowerShellToolsName # install sqlserver PS module Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -Install-Module -Name SqlServer -AllowClobber - -exit $PowerShellToolsExitCode +Install-Module -Name SqlServer -AllowClobber \ No newline at end of file From 7a3e4236089ae20e39a8db719fe82a113b25fa95 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Thu, 16 Apr 2020 19:32:00 +0300 Subject: [PATCH 7/8] Improve Update-AndroidSDK.ps1 --- images/win/scripts/Installers/Update-AndroidSDK.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/win/scripts/Installers/Update-AndroidSDK.ps1 b/images/win/scripts/Installers/Update-AndroidSDK.ps1 index 4a04b0b6f6..0e35c27a77 100644 --- a/images/win/scripts/Installers/Update-AndroidSDK.ps1 +++ b/images/win/scripts/Installers/Update-AndroidSDK.ps1 @@ -5,10 +5,10 @@ # Download the latest command line tools so that we can accept all of the licenses. # See https://developer.android.com/studio/#command-tools -Invoke-WebRequest -UseBasicParsing -Uri "https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip" -OutFile android-sdk-tools.zip +$sdkArchPath = Start-DownloadWithRetry -Url "https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip" -Name "android-sdk-tools.zip" # Don't replace the one that VS installs as it seems to break things. -Expand-Archive -Path android-sdk-tools.zip -DestinationPath android-sdk -Force +Expand-Archive -Path $sdkArchPath -DestinationPath android-sdk -Force $sdk = Get-Item -Path .\android-sdk From 5d7c7f69183132f626a36fa129b14aeef15a5142 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Tue, 21 Apr 2020 14:49:30 +0300 Subject: [PATCH 8/8] Fix issue with resolve --- images/win/scripts/Installers/Install-MysqlCli.ps1 | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/images/win/scripts/Installers/Install-MysqlCli.ps1 b/images/win/scripts/Installers/Install-MysqlCli.ps1 index 0fc2a6baed..a9db2f4295 100644 --- a/images/win/scripts/Installers/Install-MysqlCli.ps1 +++ b/images/win/scripts/Installers/Install-MysqlCli.ps1 @@ -19,20 +19,10 @@ Install-Binary -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentLi [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" # Get the latest mysql command line tools . -<<<<<<< HEAD $mysqlArchPath = Start-DownloadWithRetry -Url $MysqlVersionUrl -Name "mysql.zip" # Expand the zip Expand-Archive -Path $mysqlArchPath -DestinationPath "C:\" -Force -======= -Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile mysql.zip - -# Expand the zip -Expand-Archive -Path mysql.zip -DestinationPath "C:\" -Force - -# Deleting zip folder -Remove-Item -Recurse -Force mysql.zip ->>>>>>> master # Adding mysql in system environment path Add-MachinePathItem $mysqlPath \ No newline at end of file