# post_bootpack_pointer_refresh_v1.0.ps1 # Post-build hook for BootPack: refresh KB pointer + optional acceptance check (PS 5.1 safe) param( [string]$Root = '', [switch]$Preview, [switch]$NoPrompt, [switch]$Verify ) # Resolve script and registry root $ThisFile = $MyInvocation.MyCommand.Path $ScriptDir = Split-Path -LiteralPath $ThisFile -Parent $DefaultRoot = Split-Path -LiteralPath $ScriptDir -Parent # ...\_registry if([string]::IsNullOrWhiteSpace($Root)){ $Root = $DefaultRoot } # Dependencies $PtrRefresh = Join-Path $ScriptDir 'kb_pointer_refresh_v1.0.ps1' $Acceptance = Join-Path $ScriptDir 'kb_acceptance_tests_v1.0.1.ps1' # Plan (Preview) Write-Host '== PLAN :: post_bootpack_pointer_refresh_v1.0 ==' Write-Host ("Root : {0}" -f $Root) Write-Host ("PtrRefresh : {0} {1}" -f $PtrRefresh, (Test-Path -LiteralPath $PtrRefresh)) Write-Host ("Acceptance : {0} {1}" -f $Acceptance, (Test-Path -LiteralPath $Acceptance)) Write-Host ("Actions : 1) Refresh KB pointer 2) Verify PTR (optional)") if($Preview){ Write-Host '[PREVIEW] Simulation uniquement. Aucune écriture déclenchée par ce hook.' exit 0 } if(-not $NoPrompt){ $resp = Read-Host 'Exécuter le hook maintenant ? (O/N)' if($resp -notmatch '^[OoYy]'){ Write-Host '[ABORT] Hook non exécuté.'; exit 0 } } # Guards if(-not (Test-Path -LiteralPath $Root)){ Write-Host '[ERROR] Root introuvable.'; exit 3 } if(-not (Test-Path -LiteralPath $PtrRefresh)){ Write-Host '[ERROR] kb_pointer_refresh_v1.0.ps1 introuvable.'; exit 3 } # 1) Refresh pointer + paste Write-Host '[STEP] Rafraîchissement du KB Pointer...' & powershell -NoProfile -ExecutionPolicy Bypass -File $PtrRefresh $Root $rc1 = $LASTEXITCODE if($rc1 -ne 0){ Write-Host ("[FAIL] kb_pointer_refresh_v1.0.ps1 rc={0}" -f $rc1) exit $rc1 } Write-Host '[OK] Pointer rafraîchi.' # 2) Acceptance (optionnel) if($Verify){ if(-not (Test-Path -LiteralPath $Acceptance)){ Write-Host '[WARN] Test d’acceptance absent, skip vérification.' } else { Write-Host '[STEP] Vérification acceptance PTR...' & powershell -NoProfile -ExecutionPolicy Bypass -File $Acceptance $Root $rc2 = $LASTEXITCODE if($rc2 -ne 0){ Write-Host ("[FAIL] Acceptance PTR rc={0}" -f $rc2) exit $rc2 } Write-Host '[OK] Acceptance PTR PASS.' } } Write-Host '[OK] post_bootpack_pointer_refresh_v1.0 exécuté avec succès.' # DOC-VERSION-FOOTER: post_bootpack_pointer_refresh_v1.0.ps1 | Enc=UTF8-noBOM CRLF | _MAJ_=2025-10-22T18:25:00+02:00