Merge pull request 'fix(ci): ISO-assert discards stale WIM mount (was blocking ISO persist)' (#18) from fix/iso-assert-stale-mount into main
All checks were successful
Build SilverMetal Enhanced - Windows ISO / build (push) Successful in 5m45s
All checks were successful
Build SilverMetal Enhanced - Windows ISO / build (push) Successful in 5m45s
This commit was merged in pull request #18.
This commit is contained in:
@@ -17,8 +17,16 @@ function Assert { param([string]$Name,[bool]$Cond)
|
||||
if (-not (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
|
||||
[Security.Principal.WindowsBuiltInRole]::Administrator))) { throw 'must run elevated (WIM mount).' }
|
||||
|
||||
# Discard any stale WIM mounts from a prior aborted run (CI reuses the runner) and
|
||||
# use a fresh, unique mount dir — a leftover mount makes Mount-WindowsImage fail with
|
||||
# "attempted to mount to a directory that is not empty." Mirrors build.ps1 Stage 0.
|
||||
Get-WindowsImage -Mounted -EA SilentlyContinue | ForEach-Object {
|
||||
Dismount-WindowsImage -Path $_.MountPath -Discard -EA SilentlyContinue | Out-Null
|
||||
}
|
||||
Clear-WindowsCorruptMountPoint -EA SilentlyContinue | Out-Null
|
||||
|
||||
$img = Mount-DiskImage -ImagePath $IsoPath -PassThru
|
||||
$mount = Join-Path $env:TEMP 'sm-assert-wim'
|
||||
$mount = Join-Path $env:TEMP ('sm-assert-wim-' + [guid]::NewGuid().ToString('N'))
|
||||
$null = New-Item -ItemType Directory -Force $mount
|
||||
try {
|
||||
$drive = ($img | Get-Volume).DriveLetter + ':'
|
||||
@@ -43,10 +51,15 @@ try {
|
||||
Assert 'Welcome exe baked into WIM' (Test-Path $welcomeExe)
|
||||
$welcomeFlavours = Get-ChildItem (Join-Path $mount 'Program Files\SilverOS\Welcome\flavours') -Filter '*.json' -EA SilentlyContinue
|
||||
Assert 'Welcome flavours baked (>=1 .json)' ($welcomeFlavours.Count -ge 1)
|
||||
$welcomeCatalog = Join-Path $mount 'Program Files\SilverOS\Welcome\apps\catalog.json'
|
||||
Assert 'Welcome app catalog baked' (Test-Path $welcomeCatalog)
|
||||
}
|
||||
} finally { Dismount-WindowsImage -Path $mount -Discard | Out-Null }
|
||||
}
|
||||
} finally { Dismount-DiskImage -ImagePath $IsoPath | Out-Null }
|
||||
} finally {
|
||||
Dismount-DiskImage -ImagePath $IsoPath | Out-Null
|
||||
Remove-Item $mount -Recurse -Force -EA SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host "`n$($fail) assertion(s) failed."
|
||||
exit $fail
|
||||
|
||||
Reference in New Issue
Block a user