Skip to content

Commit bae5d20

Browse files
committed
CI: install templates for windows-plain-qemu
The first windows-plain-qemu run failed at create time with: fatal: template "_images/ubuntu.yaml" not found templates/default.yaml uses `base: template:_images/ubuntu` and `base: template:_default/mounts`, which Lima resolves via <prefix>/share/lima/templates/. Existing windows-qemu populates that directory by running `make`, whose TEMPLATES target does `cp -aL` of templates/ into _output/share/lima/templates/. windows-plain-qemu deliberately avoids `make` (so the build does not require MSYS2 make or bash), so the destination directory was empty and Lima could not find the base templates. Replicate the install in PowerShell. Recursive Copy-Item handles the plain files. The wrinkle is that templates/_images/<distro>.yaml and templates/<distro>.yaml are tracked as git symlinks (mode 120000), which Windows checks out as 17-byte plaintext stubs containing the target filename because core.symlinks defaults to false. We detect them via `git ls-tree`, follow the chain (opensuse.yaml -> opensuse-leap.yaml -> opensuse-leap-16.yaml is the deepest current chain), and overwrite the stub with the resolved file's contents. windows-plain-wsl2 does not need this; it uses templates/experimental/wsl2.yaml which has a self-contained images: section and no base: references. Signed-off-by: Jan Dubois <jan.dubois@suse.com>
1 parent 1218a5d commit bae5d20

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,56 @@ jobs:
489489
$env:GOARCH = 'amd64'
490490
go build -o _output\share\lima\lima-guestagent.Linux-x86_64 .\cmd\lima-guestagent
491491
if ($LASTEXITCODE -ne 0) { throw "lima-guestagent build failed: $LASTEXITCODE" }
492+
- name: Install templates (replicating make's TEMPLATES target)
493+
# The default.yaml template uses `base: template:_images/ubuntu` and
494+
# `base: template:_default/mounts`, which Lima resolves via
495+
# <prefix>/share/lima/templates/. We avoid `make` to stay free of MSYS2,
496+
# so we copy templates/ to _output/share/lima/templates/ ourselves.
497+
#
498+
# Wrinkle: several files under templates/ are git symlinks
499+
# (mode 120000) pointing at sibling files. The Windows checkout writes
500+
# them as plaintext stubs containing just the target filename, because
501+
# core.symlinks defaults to false on Windows. Some symlinks chain
502+
# (opensuse.yaml -> opensuse-leap.yaml -> opensuse-leap-16.yaml), so
503+
# the resolver follows the chain until it lands on a real blob.
504+
run: |
505+
$ErrorActionPreference = 'Stop'
506+
$srcRoot = 'templates'
507+
$dstRoot = '_output\share\lima\templates'
508+
if (Test-Path $dstRoot) { Remove-Item $dstRoot -Recurse -Force }
509+
New-Item -ItemType Directory -Force -Path $dstRoot | Out-Null
510+
Copy-Item -Path "$srcRoot\*" -Destination $dstRoot -Recurse -Force
511+
512+
# Build a set of paths git tracks as symlinks, keyed by Windows-style path.
513+
$stubPaths = @{}
514+
foreach ($line in (git ls-tree -r HEAD $srcRoot)) {
515+
if ($line -match '^120000\s') {
516+
$relPath = ($line -split "`t", 2)[1]
517+
$stubPaths[$relPath -replace '/', '\'] = $true
518+
}
519+
}
520+
if ($LASTEXITCODE -ne 0) { throw "git ls-tree failed: $LASTEXITCODE" }
521+
522+
function Resolve-StubChain($path) {
523+
$depth = 0
524+
while ($stubPaths[$path]) {
525+
if ($depth++ -gt 16) { throw "Symlink chain too deep starting from $path" }
526+
$target = (Get-Content -Raw $path).Trim()
527+
$next = Join-Path (Split-Path $path) $target
528+
if (-not (Test-Path $next)) {
529+
throw "Stub $path points at $target which does not exist at $next"
530+
}
531+
$path = $next
532+
}
533+
return $path
534+
}
535+
536+
foreach ($stub in $stubPaths.Keys) {
537+
$real = Resolve-StubChain $stub
538+
$dstPath = Join-Path '_output\share\lima' $stub
539+
Write-Host "Resolving symlink: $stub -> $real"
540+
Copy-Item -Force -Path $real -Destination $dstPath
541+
}
492542
- name: Scrub PATH and verify only native Windows toolchain is reachable
493543
run: |
494544
$ErrorActionPreference = 'Stop'

0 commit comments

Comments
 (0)