Skip to content

Commit 0ba53fd

Browse files
authored
Feature/installer/exit codes (#1537)
* Change reg entry to exit codes * Spoof exit 0 if Multipass already installed
1 parent 3784d89 commit 0ba53fd

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

installer/windows/microk8s.nsi

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Page custom ConfigureVm LaunchVm
3535

3636
!insertmacro MUI_LANGUAGE "English"
3737

38+
Var MultipassExitCode
3839
Var VmConfigureDialog
3940
Var VmConfigureDialogCpu
4041
Var VmConfigureDialogCpuLabel
@@ -47,17 +48,21 @@ Var VmConfigureDialogTrackLabel
4748
Var VmConfigureDialogFootnote
4849

4950
Section "Multipass (Required)" multipass_id
51+
;Exit 0 : Multipass is installed and backing hypervisor is ready to roll (e.g. HyperV is already enabled).
52+
;Exit 3010: Multipass is installed but backing hypervisor requires a reboot (e.g. HyperV just enabled).
53+
;Exit 3011: Multipass is installed but no backing hypervisor has been (e.g. virtualbox needs installing).
5054
SectionIn RO
5155
IfFileExists $PROGRAMFILES64\Multipass\bin\multipass.exe endMultipass beginMultipass
5256
Goto endMultipass
5357
beginMultipass:
5458
SetOutPath $INSTDIR
5559
File "multipass.exe"
5660
${If} ${Silent}
57-
ExecWait "multipass.exe /NoRestart /S"
61+
ExecWait "multipass.exe /NoRestart /S" $0
5862
${Else}
59-
ExecWait "multipass.exe /NoRestart"
63+
ExecWait "multipass.exe /NoRestart" $0
6064
${EndIf}
65+
StrCpy $MultipassExitCode $0
6166
IfErrors failedMultipass
6267
Delete "$INSTDIR\multipass.exe"
6368
Goto endMultipass
@@ -100,19 +105,18 @@ Function .onInit
100105
SectionSetFlags ${multipass_id} $0
101106
Return
102107
untickMultipass:
108+
StrCpy $MultipassExitCode "0" ; Multipass is installed.
103109
SectionSetFlags ${multipass_id} ${SF_RO}
104110
Return
105111
FunctionEnd
106112

107113
Function "ConfigureVm"
108-
ClearErrors
109-
ReadRegStr $0 HKLM "Software\canonical\multipass" "InstallerRebootRequired"
110-
${IfNot} ${Errors} ; Error means hypervisor is available, so we can proceed.
111-
${If} $0 == "true"
114+
${IfNot} $MultipassExitCode == "0"
115+
${If} $MultipassExitCode == "3010"
112116
MessageBox MB_ICONEXCLAMATION "Cannot configure the ${PRODUCT_NAME} VM as a reboot is required. Please re-run this wizard after reboot to configure the VM."
113117
SetRebootFlag true
114118
Abort
115-
${ElseIf} $0 == "false"
119+
${ElseIf} $MultipassExitCode == "3011"
116120
MessageBox MB_ICONEXCLAMATION "Cannot configure the ${PRODUCT_NAME} VM as VirtualBox needs to be installed. Please re-run this wizard after installing VirtualBox to configure the VM."
117121
Abort
118122
${EndIf}

0 commit comments

Comments
 (0)