Files

44 lines
1.9 KiB
PowerShell

# Deploy everything staged on D: to the flash (p1 GRUB2 loader + p2 Ventoy cfg).
$ErrorActionPreference = 'Stop'
$src = 'C:\PF\ParavisGrub'
$g2 = 'F:\efi\Paravis\Boot\grub2'
$ven = 'C:\PF\Ventoy\vtoyefi\grub\grub.cfg'
function Fail($m) { Write-Host "ERROR: $m"; exit 1 }
if (-not (Test-Path 'F:\efi\Paravis\Boot')) { Fail 'p1 (F:) not available - VM may hold the disk' }
if (-not (Test-Path 'G:\grub\grub.cfg')) { Fail 'p2 (G:) not available - VM may hold the disk' }
New-Item -ItemType Directory -Force "$g2\menu", "$g2\apps" | Out-Null
# --- p1: our loader tree only
Copy-Item "$src\grub.cfg" "$g2\grub.cfg" -Force
Copy-Item "$src\menu\*.cfg" "$g2\menu\" -Force
Copy-Item "$src\apps\super.efi" "$g2\apps\super.efi" -Force
Copy-Item "$src\apps\memtest86p.efi" "$g2\apps\memtest86p.efi" -Force
foreach ($stale in 'memtest.efi','memtest86.efi') {
Remove-Item "$g2\apps\$stale" -Force -ErrorAction SilentlyContinue
}
# --- p2: Ventoy config (language default + earlier patches), backup first
Copy-Item 'G:\grub\grub.cfg' 'C:\PF\Ventoy\backup\grub.cfg.before-ru-default' -Force
Copy-Item $ven 'G:\grub\grub.cfg' -Force
# --- report
'=== p1 grub2 tree:'
Get-ChildItem $g2 -Recurse -File | Select-Object @{n='rel';e={$_.FullName.Replace("$g2\",'')}},Length |
Sort-Object rel | Format-Table -AutoSize
'=== p2 ventoy cfg:'
'{0} bytes {1}' -f (Get-Item 'G:\grub\grub.cfg').Length, (Get-FileHash 'G:\grub\grub.cfg' -Algorithm SHA256).Hash.ToLower()
'{0} bytes {1}' -f (Get-Item $ven).Length, (Get-FileHash $ven -Algorithm SHA256).Hash.ToLower()
Select-String -Path 'G:\grub\grub.cfg' -Pattern 'vt_init_menu_lang' | ForEach-Object { ' ' + $_.Line.Trim() }
'=== syntax:'
$checker = 'C:\PF\grub2-a1ive\grub\grub-script-check.exe'
Get-ChildItem "$g2\grub.cfg", "$g2\menu\*.cfg" | ForEach-Object {
& $checker $_.FullName
if ($LASTEXITCODE -eq 0) { " OK $($_.Name)" } else { " FAIL $($_.Name)" }
}