From a5e3159c62c8f2ce4e691ba1290b35024dfebec5 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Tue, 22 Sep 2020 16:18:15 +0300 Subject: [PATCH 01/16] replace git for windows internal tools --- images/win/Windows2016-Azure.json | 20 +++++----- images/win/Windows2019-Azure.json | 33 ++++++--------- images/win/scripts/Installers/Install-Git.ps1 | 4 +- .../win/scripts/Installers/Install-Msys2.ps1 | 40 +++++++++---------- .../scripts/Installers/Post-Deployment.ps1 | 19 +++++++++ images/win/scripts/Tests/Git.Tests.ps1 | 2 +- 6 files changed, 62 insertions(+), 56 deletions(-) create mode 100644 images/win/scripts/Installers/Post-Deployment.ps1 diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 6aa1423c6..fa1352c87 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -235,6 +235,14 @@ "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1" ] }, + { + "type": "powershell", + "elevated_user": "SYSTEM", + "elevated_password": "", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -290,15 +298,6 @@ "{{ template_dir }}/scripts/Installers/Install-DotnetSDK.ps1" ] }, - - { - "type": "powershell", - "elevated_user": "SYSTEM", - "elevated_password": "", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -385,7 +384,8 @@ "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1" + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", + "{{ template_dir }}/scripts/Installers/Post-Deployment.ps1" ] }, { diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 515caba9d..351ea5b72 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -249,6 +249,14 @@ ] }, + { + "type": "powershell", + "elevated_user": "SYSTEM", + "elevated_password": "", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -276,14 +284,6 @@ "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" }, - { - "type": "powershell", - "elevated_user": "SYSTEM", - "elevated_password": "", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -382,19 +382,10 @@ { "type": "powershell", "scripts":[ - "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Run-NGen.ps1" + "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", + "{{ template_dir }}/scripts/Installers/Run-NGen.ps1", + "{{ template_dir }}/scripts/Installers/Post-Deployment.ps1" ] }, { diff --git a/images/win/scripts/Installers/Install-Git.ps1 b/images/win/scripts/Installers/Install-Git.ps1 index 2a5ea9259..701cf6c4f 100644 --- a/images/win/scripts/Installers/Install-Git.ps1 +++ b/images/win/scripts/Installers/Install-Git.ps1 @@ -28,7 +28,7 @@ Install-Binary -Url $downloadUrl ` "/SP-", ` "/CLOSEAPPLICATIONS", ` "/RESTARTAPPLICATIONS", ` - "/o:PathOption=CmdTools", ` + "/o:PathOption=Cmd", ` "/o:BashTerminalOption=ConHost", ` "/o:EnableSymlinks=Enabled", ` "/COMPONENTS=gitlfs") @@ -38,7 +38,5 @@ Choco-Install -PackageName hub # Disable GCM machine-wide [Environment]::SetEnvironmentVariable("GCM_INTERACTIVE", "Never", [System.EnvironmentVariableTarget]::Machine) -Add-MachinePathItem "C:\Program Files\Git\bin" - Invoke-PesterTests -TestFile "Git" -TestName "Git" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Hub CLI" diff --git a/images/win/scripts/Installers/Install-Msys2.ps1 b/images/win/scripts/Installers/Install-Msys2.ps1 index f0da38503..919fd1716 100644 --- a/images/win/scripts/Installers/Install-Msys2.ps1 +++ b/images/win/scripts/Installers/Install-Msys2.ps1 @@ -9,35 +9,22 @@ $dash = "-" * 40 -$origPath = $env:PATH -$gitPath = "$env:ProgramFiles\Git" - -$msys2_release = "https://api.github.com/repos/msys2/msys2-installer/releases/latest" - -$msys2Uri = ((Invoke-RestMethod $msys2_release).assets | Where-Object { +# Downloading msys2 +$msys2Release = "https://api.github.com/repos/msys2/msys2-installer/releases/latest" +$msys2Uri = ((Invoke-RestMethod $msys2Release).assets | Where-Object { $_.name -match "x86_64" -and $_.name.EndsWith("tar.xz") }).browser_download_url - -# Download the latest msys2 x86_64, filename includes release date -Write-Host "Starting msys2 download using $($msys2Uri.split('/')[-1])" $msys2File = Start-DownloadWithRetry -Url $msys2Uri -Write-Host "Finished download" - -# nix style path for tar -$msys2FileU = "/$msys2File".replace(':', '').replace('\', '/') - -# Git tar needs exe's from mingw64\bin -$env:PATH = "$gitPath\usr\bin;$gitPath\mingw64\bin;$origPath" - -$tar = "$gitPath\usr\bin\tar.exe" # extract tar.xz to C:\ Write-Host "Starting msys2 extraction" -&$tar -xJf $msys2FileU -C /c/ -Remove-Item $msys2File +$tempPath = Join-Path $env:Temp msys +Extract-7Zip -Path $msys2File -DestinationPath $tempPath +$tarPath = Resolve-Path $tempPath\msys*.tar +Extract-7Zip -Path $tarPath -DestinationPath C:\ Write-Host "Finished extraction" # Add msys2 bin tools folders to PATH temporary -$env:PATH = "C:\msys64\mingw64\bin;C:\msys64\usr\bin;$origPath" +$env:PATH = "C:\msys64\mingw64\bin;C:\msys64\usr\bin;$env:PATH" Write-Host "`n$dash bash pacman-key --init" bash.exe -c "pacman-key --init 2>&1" @@ -88,4 +75,15 @@ pacman.exe -Q | grep -v ^mingw-w64- Write-Host "`nMSYS2 installation completed" +# Environment +# add C:\msys64\mingw64\bin and C:\msys64\usr\bin to PATH +# C:\msys64\mingw64\bin add after C:\Windows\System32 to not replace built-in tar.exe +$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' +$pathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path' +$pathValue += ";C:\msys64\mingw64\bin;C:\msys64\usr\bin" +Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $pathValue + +# Rename python +Rename-Item "C:\msys64\usr\bin\python.exe" -NewName "_python.exe" + Invoke-PesterTests -TestFile "MSYS2" diff --git a/images/win/scripts/Installers/Post-Deployment.ps1 b/images/win/scripts/Installers/Post-Deployment.ps1 new file mode 100644 index 000000000..c514800d6 --- /dev/null +++ b/images/win/scripts/Installers/Post-Deployment.ps1 @@ -0,0 +1,19 @@ +# Create shells folder +$shellPath = "C:\shells" +$null = New-Item -Path $shellPath -ItemType Directory + +# MSYS2 <--> C:\msys64\usr\bin\bash.exe +$null = New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe" + +# sh and bash <--> C:\msys64\usr\bin\bash.exe +$null = New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe" +$null = New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe" + +# winbash <--> C:\Windows\System32\bash.exe +$null = New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" + +# git4bash <--> C:\Program Files\Git\bin\bash.exe +$null = New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" + +# Add shells to PATH +Add-MachinePathItem $shellPath \ No newline at end of file diff --git a/images/win/scripts/Tests/Git.Tests.ps1 b/images/win/scripts/Tests/Git.Tests.ps1 index 8dd159fa4..e7675ee07 100644 --- a/images/win/scripts/Tests/Git.Tests.ps1 +++ b/images/win/scripts/Tests/Git.Tests.ps1 @@ -1,5 +1,5 @@ Describe "Git" { - $gitTools = 'bash', 'awk', 'git', 'git-lfs' + $gitTools = 'git', 'git-lfs' $gitTestCases = $gitTools | ForEach-Object { @{ toolName = $_ From 56ea603436fd9f51c33c97cf61b96d914ff8547f Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Tue, 22 Sep 2020 16:28:42 +0300 Subject: [PATCH 02/16] merge edge fix --- images/win/scripts/Installers/Install-Edge.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-Edge.ps1 b/images/win/scripts/Installers/Install-Edge.ps1 index ebb7871b7..1f4ce0ae4 100644 --- a/images/win/scripts/Installers/Install-Edge.ps1 +++ b/images/win/scripts/Installers/Install-Edge.ps1 @@ -24,7 +24,14 @@ $EdgeDriverVersionFile = Start-DownloadWithRetry -Url $EdgeDriverVersionUrl -Nam Write-Host "Download Microsoft Edge WebDriver..." $EdgeDriverLatestVersion = Get-Content -Path $EdgeDriverVersionFile $EdgeDriverArchName = "edgedriver_win64.zip" -$EdgeDriverDownloadUrl="https://msedgedriver.azureedge.net/${EdgeDriverLatestVersion}/${EdgeDriverArchName}" +# A temporary workaround to install the previous driver version because 85.0.564.60 for win64 doesn't exist +if ($EdgeDriverLatestVersion -eq "85.0.564.60") +{ + $EdgeDriverLatestVersion = "85.0.564.51" + Set-Content -Path $EdgeDriverVersionFile -Value $EdgeDriverLatestVersion +} + +$EdgeDriverDownloadUrl = "https://msedgedriver.azureedge.net/${EdgeDriverLatestVersion}/${EdgeDriverArchName}" $EdgeDriverArchPath = Start-DownloadWithRetry -Url $EdgeDriverDownloadUrl -Name $EdgeDriverArchName From 2148a2bd2fdbe4b88b42097ae839e2e9dd82f8da Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Tue, 22 Sep 2020 18:22:15 +0300 Subject: [PATCH 03/16] adding pester tests --- images/win/Windows2016-Azure.json | 8 ++-- images/win/Windows2019-Azure.json | 8 ++-- .../scripts/Installers/Configure-Shell.ps1 | 19 ++++++++ .../scripts/Installers/Post-Deployment.ps1 | 19 -------- images/win/scripts/Tests/Shell.Tests.ps1 | 43 +++++++++++++++++++ 5 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 images/win/scripts/Installers/Configure-Shell.ps1 delete mode 100644 images/win/scripts/Installers/Post-Deployment.ps1 create mode 100644 images/win/scripts/Tests/Shell.Tests.ps1 diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index fa1352c87..442218d32 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -325,7 +325,9 @@ "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1", - "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1" + "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1", + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", + "{{ template_dir }}/scripts/Installers/Configure-Shell.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -383,9 +385,7 @@ { "type": "powershell", "scripts":[ - "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", - "{{ template_dir }}/scripts/Installers/Post-Deployment.ps1" + "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1" ] }, { diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 351ea5b72..0e3d180bd 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -324,7 +324,9 @@ "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1", - "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1" + "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1", + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", + "{{ template_dir }}/scripts/Installers/Configure-Shell.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -383,9 +385,7 @@ "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", - "{{ template_dir }}/scripts/Installers/Run-NGen.ps1", - "{{ template_dir }}/scripts/Installers/Post-Deployment.ps1" + "{{ template_dir }}/scripts/Installers/Run-NGen.ps1" ] }, { diff --git a/images/win/scripts/Installers/Configure-Shell.ps1 b/images/win/scripts/Installers/Configure-Shell.ps1 new file mode 100644 index 000000000..6bb7bc50e --- /dev/null +++ b/images/win/scripts/Installers/Configure-Shell.ps1 @@ -0,0 +1,19 @@ +# Create shells folder +$shellPath = "C:\shells" +New-Item -Path $shellPath -ItemType Directory | Out-Null + +# sh and bash <--> C:\msys64\usr\bin\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null +New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe" | Out-Null + +# winbash <--> C:\Windows\System32\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null + +# git4bash <--> C:\Program Files\Git\bin\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null + +# MSYS2 <--> C:\msys64\usr\bin\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null + +# Add shells to PATH +Add-MachinePathItem $shellPath \ No newline at end of file diff --git a/images/win/scripts/Installers/Post-Deployment.ps1 b/images/win/scripts/Installers/Post-Deployment.ps1 deleted file mode 100644 index c514800d6..000000000 --- a/images/win/scripts/Installers/Post-Deployment.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -# Create shells folder -$shellPath = "C:\shells" -$null = New-Item -Path $shellPath -ItemType Directory - -# MSYS2 <--> C:\msys64\usr\bin\bash.exe -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe" - -# sh and bash <--> C:\msys64\usr\bin\bash.exe -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe" -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe" - -# winbash <--> C:\Windows\System32\bash.exe -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" - -# git4bash <--> C:\Program Files\Git\bin\bash.exe -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" - -# Add shells to PATH -Add-MachinePathItem $shellPath \ No newline at end of file diff --git a/images/win/scripts/Tests/Shell.Tests.ps1 b/images/win/scripts/Tests/Shell.Tests.ps1 new file mode 100644 index 000000000..e7645f2e8 --- /dev/null +++ b/images/win/scripts/Tests/Shell.Tests.ps1 @@ -0,0 +1,43 @@ +Describe "Shell" { + $shellTestCases = @( + @{Name = "C:\shells\bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"}, + @{Name = "C:\shells\sh.exe"; Target = "C:\msys64\usr\bin\sh.exe"}, + @{Name = "C:\shells\winbash.exe"; Target = "$env:SystemRoot\System32\bash.exe"}, + @{Name = "C:\shells\git4bash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"}, + @{Name = "C:\shells\msys2.exe"; Target = "C:\msys64\usr\bin\bash.exe"} + ) + + $pathTestCases = @( + @{Path = "C:\shells"}, + @{Path = "C:\msys64\mingw64\bin"}, + @{Path = "C:\msys64\usr\bin"} + ) + + It "Default bash.exe from MSYS2" { + (Get-Command bash).Path | Should -BeExactly "C:\shells\bash.exe" + } + + It "Default sh.exe from MSYS2" { + (Get-Command sh).Path | Should -BeExactly "C:\shells\sh.exe" + } + + It "Folder C:\shells exists" { + "C:\shells" | Should -Exist + } + + It "C:\Windows\System32 before C:\msys64\mingw64\bin and C:\msys64\usr\bin" { + $path = $env:Path.Split(";").ToLower() + $indexOfSystem32 = $path.IndexOf("c:\windows\system32") + + $path.IndexOf("c:\msys64\mingw64\bin") | Should -BeGreaterThan $indexOfSystem32 + $path.IndexOf("c:\msys64\usr\bin") | Should -BeGreaterThan $indexOfSystem32 + } + + It " target to " -TestCases $shellTestCases { + (Get-Item $Name).Target | Should -BeExactly $Target + } + + It " is in PATH" -TestCases $pathTestCases { + $env:Path.Split(";") | Should -Contain $Path + } +} \ No newline at end of file From ed62416e84b73fc13ffff7b61e60a0cbfff25437 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 23 Sep 2020 10:41:23 +0300 Subject: [PATCH 04/16] fix pester tests --- images/win/scripts/Installers/Configure-Shell.ps1 | 10 +++++++--- images/win/scripts/Installers/Install-Msys2.ps1 | 12 +++--------- images/win/scripts/Tests/Shell.Tests.ps1 | 11 +++++++++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/images/win/scripts/Installers/Configure-Shell.ps1 b/images/win/scripts/Installers/Configure-Shell.ps1 index 6bb7bc50e..1eabdc08c 100644 --- a/images/win/scripts/Installers/Configure-Shell.ps1 +++ b/images/win/scripts/Installers/Configure-Shell.ps1 @@ -6,14 +6,18 @@ New-Item -Path $shellPath -ItemType Directory | Out-Null New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe" | Out-Null -# winbash <--> C:\Windows\System32\bash.exe -New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null +# WSL is available on Windows Server 2019 +if (Test-IsWin19) +{ + # winbash <--> C:\Windows\System32\bash.exe + New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null +} # git4bash <--> C:\Program Files\Git\bin\bash.exe New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null # MSYS2 <--> C:\msys64\usr\bin\bash.exe -New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null +New-Item -ItemType SymbolicLink -Path "$shellPath\msys2bash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null # Add shells to PATH Add-MachinePathItem $shellPath \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Msys2.ps1 b/images/win/scripts/Installers/Install-Msys2.ps1 index 919fd1716..b077f5cd9 100644 --- a/images/win/scripts/Installers/Install-Msys2.ps1 +++ b/images/win/scripts/Installers/Install-Msys2.ps1 @@ -12,15 +12,12 @@ $dash = "-" * 40 # Downloading msys2 $msys2Release = "https://api.github.com/repos/msys2/msys2-installer/releases/latest" $msys2Uri = ((Invoke-RestMethod $msys2Release).assets | Where-Object { - $_.name -match "x86_64" -and $_.name.EndsWith("tar.xz") }).browser_download_url + $_.name -match "x86_64" -and $_.name.EndsWith("sfx.exe") }).browser_download_url $msys2File = Start-DownloadWithRetry -Url $msys2Uri -# extract tar.xz to C:\ +# extract sfx.exe to C:\ Write-Host "Starting msys2 extraction" -$tempPath = Join-Path $env:Temp msys -Extract-7Zip -Path $msys2File -DestinationPath $tempPath -$tarPath = Resolve-Path $tempPath\msys*.tar -Extract-7Zip -Path $tarPath -DestinationPath C:\ +& $msys2File -y -oC:\ Write-Host "Finished extraction" # Add msys2 bin tools folders to PATH temporary @@ -83,7 +80,4 @@ $pathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path' $pathValue += ";C:\msys64\mingw64\bin;C:\msys64\usr\bin" Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $pathValue -# Rename python -Rename-Item "C:\msys64\usr\bin\python.exe" -NewName "_python.exe" - Invoke-PesterTests -TestFile "MSYS2" diff --git a/images/win/scripts/Tests/Shell.Tests.ps1 b/images/win/scripts/Tests/Shell.Tests.ps1 index e7645f2e8..eec1a3bf9 100644 --- a/images/win/scripts/Tests/Shell.Tests.ps1 +++ b/images/win/scripts/Tests/Shell.Tests.ps1 @@ -2,9 +2,8 @@ Describe "Shell" { $shellTestCases = @( @{Name = "C:\shells\bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"}, @{Name = "C:\shells\sh.exe"; Target = "C:\msys64\usr\bin\sh.exe"}, - @{Name = "C:\shells\winbash.exe"; Target = "$env:SystemRoot\System32\bash.exe"}, @{Name = "C:\shells\git4bash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"}, - @{Name = "C:\shells\msys2.exe"; Target = "C:\msys64\usr\bin\bash.exe"} + @{Name = "C:\shells\msys2bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"} ) $pathTestCases = @( @@ -13,6 +12,8 @@ Describe "Shell" { @{Path = "C:\msys64\usr\bin"} ) + $IsWin16 = Test-IsWin16 + It "Default bash.exe from MSYS2" { (Get-Command bash).Path | Should -BeExactly "C:\shells\bash.exe" } @@ -33,6 +34,12 @@ Describe "Shell" { $path.IndexOf("c:\msys64\usr\bin") | Should -BeGreaterThan $indexOfSystem32 } + It "C:\shells\winbash.exe target to $env:SystemRoot\System32\bash.exe" -Skip:$IsWin16 { + $Name = "C:\shells\winbash.exe" + $Target = "$env:SystemRoot\System32\bash.exe" + (Get-Item $Name).Target | Should -BeExactly $Target + } + It " target to " -TestCases $shellTestCases { (Get-Item $Name).Target | Should -BeExactly $Target } From b6d36cae6103cc622c55c34af25f74b2c238ff52 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 23 Sep 2020 11:45:36 +0300 Subject: [PATCH 05/16] consistency shell naming --- images/win/scripts/Installers/Configure-Shell.ps1 | 8 ++++---- images/win/scripts/Tests/Shell.Tests.ps1 | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/images/win/scripts/Installers/Configure-Shell.ps1 b/images/win/scripts/Installers/Configure-Shell.ps1 index 1eabdc08c..8eb163bcf 100644 --- a/images/win/scripts/Installers/Configure-Shell.ps1 +++ b/images/win/scripts/Installers/Configure-Shell.ps1 @@ -13,11 +13,11 @@ if (Test-IsWin19) New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null } -# git4bash <--> C:\Program Files\Git\bin\bash.exe -New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null +# gitbash <--> C:\Program Files\Git\bin\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\gitbash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null -# MSYS2 <--> C:\msys64\usr\bin\bash.exe -New-Item -ItemType SymbolicLink -Path "$shellPath\msys2bash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null +# msysbash <--> C:\msys64\usr\bin\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\msysbash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null # Add shells to PATH Add-MachinePathItem $shellPath \ No newline at end of file diff --git a/images/win/scripts/Tests/Shell.Tests.ps1 b/images/win/scripts/Tests/Shell.Tests.ps1 index eec1a3bf9..915940e2a 100644 --- a/images/win/scripts/Tests/Shell.Tests.ps1 +++ b/images/win/scripts/Tests/Shell.Tests.ps1 @@ -2,8 +2,8 @@ Describe "Shell" { $shellTestCases = @( @{Name = "C:\shells\bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"}, @{Name = "C:\shells\sh.exe"; Target = "C:\msys64\usr\bin\sh.exe"}, - @{Name = "C:\shells\git4bash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"}, - @{Name = "C:\shells\msys2bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"} + @{Name = "C:\shells\gitbash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"}, + @{Name = "C:\shells\msysbash.exe"; Target = "C:\msys64\usr\bin\bash.exe"} ) $pathTestCases = @( From cdc9d19df849adcce5dec98866e65f3c7359100b Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Fri, 25 Sep 2020 11:54:37 +0300 Subject: [PATCH 06/16] msys2 after openssl --- images/win/Windows2016-Azure.json | 16 ++++++++-------- images/win/Windows2019-Azure.json | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 442218d32..8d47c4625 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -235,14 +235,6 @@ "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1" ] }, - { - "type": "powershell", - "elevated_user": "SYSTEM", - "elevated_password": "", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -270,6 +262,14 @@ "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" }, + { + "type": "powershell", + "elevated_user": "SYSTEM", + "elevated_password": "", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" + ] + }, { "type": "windows-shell", "inline": ["wmic product where \"name like '%%microsoft azure powershell%%'\" call uninstall /nointeractive"] diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 0e3d180bd..b1500edbc 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -249,14 +249,6 @@ ] }, - { - "type": "powershell", - "elevated_user": "SYSTEM", - "elevated_password": "", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -284,6 +276,14 @@ "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" }, + { + "type": "powershell", + "elevated_user": "SYSTEM", + "elevated_password": "", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" + ] + }, { "type": "powershell", "scripts":[ From caefc77d7ad916c0e56d763a4adbd7b435061109 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 28 Sep 2020 15:08:08 +0300 Subject: [PATCH 07/16] update msys2 notes --- .../scripts/SoftwareReport/SoftwareReport.Common.psm1 | 6 ++++++ .../SoftwareReport/SoftwareReport.Generator.ps1 | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 05b101aac..45a9a4acc 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -271,6 +271,12 @@ function Get-PacmanVersion { return "- Pacman $pacmanVersion" } +function Get-ShellTarget { + $shells = Get-ChildItem C:\shells -File | Select-Object @{n="Name";e={ + if ($_.Name -eq 'bash.exe') {"$($_.Name) (Default)"} else {$_.Name}}},@{n="Target";e={$_.Target[0]}} | Sort-Object Name + $shells | New-MDTable -Columns ([ordered]@{Name = "left"; Target = "left";}) +} + function Get-YAMLLintVersion { yamllint --version } \ No newline at end of file diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 2f45ecde1..4a24d73e3 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -148,14 +148,22 @@ $markdown += New-MDList -Style Unordered -Lines @( (Get-SeleniumWebDriverVersion -Driver "iexplorer") ) +$markdown += New-MDHeader "Shells" -Level 3 +$markdown += Get-ShellTarget +$markdown += New-MDNewLine + $markdown += New-MDHeader "MSYS2" -Level 3 $markdown += Get-PacmanVersion $markdown += New-MDNewLine +$markdown += New-MDHeader "Notes:" -Level 5 $markdown += @' ``` Location: C:\msys64 -Note: MSYS2 is pre-installed on image but not added to PATH. +1. MSYS2 is pre-installed on image +2. C:\msys64\mingw64\bin is added to PATH and has lower precedence than C:\Windows\System32 +3. C:\msys64\usr\bin is added to PATH and has lower precedence than C:\Windows\System32 +4. Default bash.exe shell is set to the C:\msys64\usr\bin\bash.exe ``` '@ $markdown += New-MDNewLine From 55b69ec4b48c3ef16642484919051035eb12feb0 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 30 Sep 2020 10:33:53 +0300 Subject: [PATCH 08/16] remove duplicate msys2 record --- images/win/Windows2016-Azure.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index be64ae479..e20404c82 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -266,14 +266,6 @@ "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" }, - { - "type": "powershell", - "elevated_user": "SYSTEM", - "elevated_password": "", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1" - ] - }, { "type": "windows-shell", "inline": [ From fe810160ee404f091d1ca84173477cb89bbd8d7c Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 30 Sep 2020 19:08:14 +0300 Subject: [PATCH 09/16] fix target --- images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 45a9a4acc..0ca95ee71 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -273,7 +273,8 @@ function Get-PacmanVersion { function Get-ShellTarget { $shells = Get-ChildItem C:\shells -File | Select-Object @{n="Name";e={ - if ($_.Name -eq 'bash.exe') {"$($_.Name) (Default)"} else {$_.Name}}},@{n="Target";e={$_.Target[0]}} | Sort-Object Name + $name = $_.Name + if ($name -eq 'bash.exe') {"$name (Default)"} else {$name}}},@{n="Target";e={@($_.Target)[0]}} | Sort-Object Name $shells | New-MDTable -Columns ([ordered]@{Name = "left"; Target = "left";}) } From fc389f0cc0a1420c2249ceeb830609a682b6166f Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Fri, 23 Oct 2020 14:30:10 +0300 Subject: [PATCH 10/16] fix ssh-keyscan Windows Server 2016 --- images/win/scripts/Install-OpenSSH.ps1 | 13 +++++++++++++ images/win/windows2016.json | 1 + 2 files changed, 14 insertions(+) create mode 100644 images/win/scripts/Install-OpenSSH.ps1 diff --git a/images/win/scripts/Install-OpenSSH.ps1 b/images/win/scripts/Install-OpenSSH.ps1 new file mode 100644 index 000000000..b0ea15273 --- /dev/null +++ b/images/win/scripts/Install-OpenSSH.ps1 @@ -0,0 +1,13 @@ +################################################################################ +## File: Install-OpenSSH.ps1 +## Desc: Install OpenSSH-Win64 +################################################################################ + +Write-Host "Download Latest OpenSSH-Win64 archive" +$url = 'https://api.github.com/repos/PowerShell/Win32-OpenSSH/releases/latest' +$name = 'OpenSSH-Win64.zip' +# Explicitly set type to string since match returns array by default +[string]$opensshLatest = (Invoke-RestMethod -Uri $url).assets.browser_download_url -match $name +$opensshArchivePath = Start-DownloadWithRetry -Url $opensshLatest -Name $name +Write-Host "Expand OpenSSH-Win64 archive" +Extract-7Zip -Path $opensshArchivePath -DestinationPath $env:ProgramFiles \ No newline at end of file diff --git a/images/win/windows2016.json b/images/win/windows2016.json index a008e760a..43faaa254 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -245,6 +245,7 @@ "{{ template_dir }}/scripts/Installers/Install-Sbt.ps1", "{{ template_dir }}/scripts/Installers/Install-OpenSSL.ps1", "{{ template_dir }}/scripts/Installers/Install-Perl.ps1", + "{{ template_dir }}/scripts/Installers/Install-OpenSSH.ps1", "{{ template_dir }}/scripts/Installers/Install-Git.ps1", "{{ template_dir }}/scripts/Installers/Install-GitHub-CLI.ps1", "{{ template_dir }}/scripts/Installers/Install-PHP.ps1", From e8bd1e858e9ce94c75a0450995034d8941c2d247 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Fri, 23 Oct 2020 14:37:52 +0300 Subject: [PATCH 11/16] move Install-OpenSSH.ps1 --- images/win/scripts/{ => Installers}/Install-OpenSSH.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename images/win/scripts/{ => Installers}/Install-OpenSSH.ps1 (100%) diff --git a/images/win/scripts/Install-OpenSSH.ps1 b/images/win/scripts/Installers/Install-OpenSSH.ps1 similarity index 100% rename from images/win/scripts/Install-OpenSSH.ps1 rename to images/win/scripts/Installers/Install-OpenSSH.ps1 From 96faa1ea2a69b8bdcef676f8fae168439085e0ee Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 26 Oct 2020 12:20:14 +0300 Subject: [PATCH 12/16] fix mingw64 --- images/win/scripts/Installers/Install-Mingw64.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-Mingw64.ps1 b/images/win/scripts/Installers/Install-Mingw64.ps1 index b6c860485..2b999f450 100644 --- a/images/win/scripts/Installers/Install-Mingw64.ps1 +++ b/images/win/scripts/Installers/Install-Mingw64.ps1 @@ -7,7 +7,7 @@ Choco-Install -PackageName mingw # Make a copy of mingw32-make.exe to make.exe, which is a more discoverable name # and so the same command line can be used on Windows as on macOS and Linux -$path = where.exe mingw32-make.exe | Get-Item +$path = Get-Command mingw32-make.exe -CommandType All | Where-Object { $_.Path.Contains("C:\ProgramData\Chocolatey") } | Get-Item Copy-Item -Path $path -Destination (Join-Path $path.Directory 'make.exe') Invoke-PesterTests -TestFile "Tools" -TestName "Mingw64" From eb92aba93bcc53d0028086ea6abd8f2e53d12994 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 26 Oct 2020 14:33:46 +0300 Subject: [PATCH 13/16] add ssh host keys --- images/win/scripts/Installers/Install-Msys2.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/images/win/scripts/Installers/Install-Msys2.ps1 b/images/win/scripts/Installers/Install-Msys2.ps1 index b077f5cd9..844c071b6 100644 --- a/images/win/scripts/Installers/Install-Msys2.ps1 +++ b/images/win/scripts/Installers/Install-Msys2.ps1 @@ -57,6 +57,10 @@ Write-Host "`n$dash Install mingw32 packages" $pre = "mingw-w64-i686-" pacman.exe -S --noconfirm --needed --noprogressbar $tools32.replace('___', $pre).split(' ') +# install openssh +Write-Host "`n$dash Install openssh package" +pacman.exe -S --noconfirm --needed --noprogressbar openssh + # clean all packages to decrease image size Write-Host "`n$dash Clean packages" pacman.exe -Scc --noconfirm @@ -80,4 +84,8 @@ $pathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path' $pathValue += ";C:\msys64\mingw64\bin;C:\msys64\usr\bin" Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $pathValue +# Add well-known SSH host keys to ssh_known_hosts +ssh-keyscan -t rsa github.com >> "C:\msys64\etc\ssh\ssh_known_hosts" +ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\msys64\etc\ssh\ssh_known_hosts" + Invoke-PesterTests -TestFile "MSYS2" From 222f3bb86f3d9f64c0832a70469fa45f717c7567 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Tue, 27 Oct 2020 11:05:36 +0300 Subject: [PATCH 14/16] use ssh-keyscan from git --- images/win/scripts/Installers/Install-Git.ps1 | 2 +- images/win/scripts/Installers/Install-OpenSSH.ps1 | 13 ------------- images/win/windows2016.json | 2 -- images/win/windows2019.json | 1 - 4 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 images/win/scripts/Installers/Install-OpenSSH.ps1 diff --git a/images/win/scripts/Installers/Install-Git.ps1 b/images/win/scripts/Installers/Install-Git.ps1 index 2a5eb546b..c7b2c4579 100644 --- a/images/win/scripts/Installers/Install-Git.ps1 +++ b/images/win/scripts/Installers/Install-Git.ps1 @@ -37,7 +37,7 @@ Choco-Install -PackageName hub [Environment]::SetEnvironmentVariable("GCM_INTERACTIVE", "Never", [System.EnvironmentVariableTarget]::Machine) if (Test-IsWin16) { - $env:Path += ";$env:ProgramFiles\OpenSSH-Win64" + $env:Path += ";$env:ProgramFiles\Git\usr\bin\" } # Add well-known SSH host keys to ssh_known_hosts diff --git a/images/win/scripts/Installers/Install-OpenSSH.ps1 b/images/win/scripts/Installers/Install-OpenSSH.ps1 deleted file mode 100644 index b0ea15273..000000000 --- a/images/win/scripts/Installers/Install-OpenSSH.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -################################################################################ -## File: Install-OpenSSH.ps1 -## Desc: Install OpenSSH-Win64 -################################################################################ - -Write-Host "Download Latest OpenSSH-Win64 archive" -$url = 'https://api.github.com/repos/PowerShell/Win32-OpenSSH/releases/latest' -$name = 'OpenSSH-Win64.zip' -# Explicitly set type to string since match returns array by default -[string]$opensshLatest = (Invoke-RestMethod -Uri $url).assets.browser_download_url -match $name -$opensshArchivePath = Start-DownloadWithRetry -Url $opensshLatest -Name $name -Write-Host "Expand OpenSSH-Win64 archive" -Extract-7Zip -Path $opensshArchivePath -DestinationPath $env:ProgramFiles \ No newline at end of file diff --git a/images/win/windows2016.json b/images/win/windows2016.json index 43faaa254..8c1314d63 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -245,7 +245,6 @@ "{{ template_dir }}/scripts/Installers/Install-Sbt.ps1", "{{ template_dir }}/scripts/Installers/Install-OpenSSL.ps1", "{{ template_dir }}/scripts/Installers/Install-Perl.ps1", - "{{ template_dir }}/scripts/Installers/Install-OpenSSH.ps1", "{{ template_dir }}/scripts/Installers/Install-Git.ps1", "{{ template_dir }}/scripts/Installers/Install-GitHub-CLI.ps1", "{{ template_dir }}/scripts/Installers/Install-PHP.ps1", @@ -334,7 +333,6 @@ "scripts": [ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1", "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", "{{ template_dir }}/scripts/Installers/Configure-Shell.ps1" ], "elevated_user": "{{user `install_user`}}", diff --git a/images/win/windows2019.json b/images/win/windows2019.json index dd7177117..a002f77f5 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -331,7 +331,6 @@ "scripts": [ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1", "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", "{{ template_dir }}/scripts/Installers/Configure-Shell.ps1" ], "elevated_user": "{{user `install_user`}}", From 37d1fd3e1af0c8a9500f5fc31f7864e4657f34ab Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 28 Oct 2020 09:29:33 +0300 Subject: [PATCH 15/16] update base url --- images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 b/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 index 60cbbefaf..37f5ece9b 100644 --- a/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 +++ b/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 @@ -3,7 +3,7 @@ ## Desc: Install SQL PowerShell tool ################################################################################ -$BaseUrl = "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64" +$BaseUrl = "https://download.microsoft.com/download/B/1/7/B1783FE9-717B-4F78-A39A-A2E27E3D679D/ENU/x64" # install required MSIs $SQLSysClrTypesName = "SQLSysClrTypes.msi" From 3ef46361f35afc327cfad7d86bed53ef2eb4c00d Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 28 Oct 2020 09:41:57 +0300 Subject: [PATCH 16/16] update ssh-keyscan in msys2 script --- images/win/scripts/Installers/Install-Git.ps1 | 8 -------- images/win/scripts/Installers/Install-Msys2.ps1 | 9 ++++++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/images/win/scripts/Installers/Install-Git.ps1 b/images/win/scripts/Installers/Install-Git.ps1 index c7b2c4579..6c89250e9 100644 --- a/images/win/scripts/Installers/Install-Git.ps1 +++ b/images/win/scripts/Installers/Install-Git.ps1 @@ -36,13 +36,5 @@ Choco-Install -PackageName hub # Disable GCM machine-wide [Environment]::SetEnvironmentVariable("GCM_INTERACTIVE", "Never", [System.EnvironmentVariableTarget]::Machine) -if (Test-IsWin16) { - $env:Path += ";$env:ProgramFiles\Git\usr\bin\" -} - -# Add well-known SSH host keys to ssh_known_hosts -ssh-keyscan -t rsa github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" -ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" - Invoke-PesterTests -TestFile "Git" -TestName "Git" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Hub CLI" diff --git a/images/win/scripts/Installers/Install-Msys2.ps1 b/images/win/scripts/Installers/Install-Msys2.ps1 index 844c071b6..dea3b95d0 100644 --- a/images/win/scripts/Installers/Install-Msys2.ps1 +++ b/images/win/scripts/Installers/Install-Msys2.ps1 @@ -84,8 +84,15 @@ $pathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path' $pathValue += ";C:\msys64\mingw64\bin;C:\msys64\usr\bin" Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $pathValue -# Add well-known SSH host keys to ssh_known_hosts +# Add well-known SSH host keys to ssh_known_hosts to Msys2 ssh-keyscan -t rsa github.com >> "C:\msys64\etc\ssh\ssh_known_hosts" ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\msys64\etc\ssh\ssh_known_hosts" +# Add well-known SSH host keys to ssh_known_hosts to Git +if (Test-Path "C:\Program Files\Git\etc\ssh") +{ + ssh-keyscan -t rsa github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" + ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" +} + Invoke-PesterTests -TestFile "MSYS2"