Implement root install loop using a switch

This commit is contained in:
Manuel Thalmann 2024-08-09 13:34:46 +02:00
parent d23bcac5d2
commit dc7fe9f418

View file

@ -35,9 +35,12 @@ $null = New-Module {
#> #>
function Start-InstallationLoop { function Start-InstallationLoop {
while (-not (Get-IsFinished)) { while (-not (Get-IsFinished)) {
if ($null -eq (Get-Stage)) { switch (Get-Stage) {
($null) {
Set-Stage ([SetupStage]::Initialize); Set-Stage ([SetupStage]::Initialize);
} elseif ((Get-Stage) -eq ([SetupStage]::Initialize)) { break;
}
([SetupStage]::Initialize) {
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) { if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
Invoke-Hook "Install-Chocolatey" -Fallback { Invoke-Hook "Install-Chocolatey" -Fallback {
# Install chocolatey # Install chocolatey
@ -116,7 +119,9 @@ $null = New-Module {
}; };
Set-Stage ([SetupStage]::Configure); Set-Stage ([SetupStage]::Configure);
} else { break;
}
default {
$null = Import-Module PSWindowsUpdate; $null = Import-Module PSWindowsUpdate;
Invoke-Hook "Invoke-WindowsUpdate" -Fallback { Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
@ -476,6 +481,7 @@ $null = New-Module {
} }
} }
} }
}
function Invoke-WindowsInstallation([Context] $context) { function Invoke-WindowsInstallation([Context] $context) {
$Global:InformationPreference = "Continue"; $Global:InformationPreference = "Continue";