mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 14:17:22 +00:00
[Windows] Add shell symlinks (#2395)
* add shell symlinks * fix paths * add a wrapper * fix target output * fix tests
This commit is contained in:
committed by
GitHub
parent
da495ea119
commit
68e9c68855
2
images/win/post-generation/Msys2FirstLaunch.ps1
Normal file
2
images/win/post-generation/Msys2FirstLaunch.ps1
Normal file
@@ -0,0 +1,2 @@
|
||||
# create user profile at the first launch
|
||||
$null = cmd /c "C:\msys64\usr\bin\bash.exe -leo pipefail -c 'echo $SHELL' 2>&1"
|
||||
23
images/win/scripts/Installers/Configure-Shell.ps1
Normal file
23
images/win/scripts/Installers/Configure-Shell.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
# Create shells folder
|
||||
$shellPath = "C:\shells"
|
||||
New-Item -Path $shellPath -ItemType Directory | Out-Null
|
||||
|
||||
# add a wrapper for C:\msys64\usr\bin\bash.exe
|
||||
@'
|
||||
@echo off
|
||||
setlocal
|
||||
IF NOT DEFINED MSYS2_PATH_TYPE set MSYS2_PATH_TYPE=strict
|
||||
IF NOT DEFINED MSYSTEM set MSYSTEM=mingw64
|
||||
set CHERE_INVOKING=1
|
||||
C:\msys64\usr\bin\bash.exe -leo pipefail %*
|
||||
'@ | Out-File -FilePath "$shellPath\msys2bash.cmd"
|
||||
|
||||
# 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
|
||||
|
||||
# WSL is available on Windows Server 2019
|
||||
if (Test-IsWin19)
|
||||
{
|
||||
# wslbash <--> C:\Windows\System32\bash.exe
|
||||
New-Item -ItemType SymbolicLink -Path "$shellPath\wslbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null
|
||||
}
|
||||
@@ -304,6 +304,17 @@ function Get-CachedDockerImagesTableData {
|
||||
}
|
||||
}
|
||||
|
||||
function Get-ShellTarget {
|
||||
$shells = Get-ChildItem C:\shells -File | Select-Object Name, @{n="Target";e={
|
||||
if ($_.Name -eq "msys2bash.cmd") {
|
||||
"C:\msys64\usr\bin\bash.exe"
|
||||
} else {
|
||||
@($_.Target)[0]
|
||||
}
|
||||
}} | Sort-Object Name
|
||||
$shells | New-MDTable -Columns ([ordered]@{Name = "left"; Target = "left";})
|
||||
}
|
||||
|
||||
function Get-PacmanVersion {
|
||||
$msys2BinDir = "C:\msys64\usr\bin"
|
||||
$pacmanPath = Join-Path $msys2BinDir "pacman.exe"
|
||||
|
||||
@@ -142,6 +142,10 @@ $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
|
||||
|
||||
13
images/win/scripts/Tests/Shell.Tests.ps1
Normal file
13
images/win/scripts/Tests/Shell.Tests.ps1
Normal file
@@ -0,0 +1,13 @@
|
||||
Describe "Shell" {
|
||||
$shellTestCases = @(
|
||||
@{Name = "C:\shells\gitbash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"},
|
||||
@{Name = "C:\shells\msys2bash.cmd"; Target = $null}
|
||||
)
|
||||
if (Test-IsWin19) {
|
||||
$shellTestCases += @{Name = "C:\shells\wslbash.exe"; Target = "$env:SystemRoot\System32\bash.exe"}
|
||||
}
|
||||
|
||||
It "<Name> target to <Target>" -TestCases $shellTestCases {
|
||||
(Get-Item $Name).Target | Should -BeExactly $Target
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,8 @@
|
||||
"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/Configure-Shell.ps1"
|
||||
],
|
||||
"elevated_user": "{{user `install_user`}}",
|
||||
"elevated_password": "{{user `install_password`}}"
|
||||
|
||||
@@ -323,7 +323,8 @@
|
||||
"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/Configure-Shell.ps1"
|
||||
],
|
||||
"elevated_user": "{{user `install_user`}}",
|
||||
"elevated_password": "{{user `install_password`}}"
|
||||
|
||||
Reference in New Issue
Block a user