Skip to content

Commit fccfa1d

Browse files
authored
fix(windows-installer): add new cleanup script on install (#824)
Issue #, if available: *Description of changes:* - Add new script that runs upon installation to cleanup any dangling Finch VM - This is needed because earlier versions of Finch's Windows installer don't clean up properly on uninstall / reinstall - Even with this change, user's will be prompted to stop limactl on reinstall if Finch is running. Regardless of which action they choose, the install script will cleanup any dangling VMs. *Testing done:* - Tested locally - [x] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Signed-off-by: Justin Alvarez <[email protected]>
1 parent f64835d commit fccfa1d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

msi-builder/BuildFinchMSI.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Write-Host "Files copied successfully."
6060
Write-Host "4. Copy extra scripts, license and icon..."
6161
Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "postinstall.bat") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch")
6262
Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "uninstall.bat") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch")
63+
Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "removevm.bat") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch")
6364
Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "finch.ico") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch")
6465
Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "LICENSE.rtf") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch")
6566
Write-Host "Files copied successfully."

msi-builder/FinchMSITemplate.wxs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<File Id="config_yaml" Source="__SOURCE__\config.yaml" />
2222
<File Id="finch_ico" Source="__SOURCE__\finch.ico" />
2323
<File Id="LICENSE_rtf" Source="__SOURCE__\LICENSE.rtf" />
24+
<File Id="removevm_bat" Source="__SOURCE__\removevm.bat" />
2425
<File Id="postinstall_bat" Source="__SOURCE__\postinstall.bat" />
2526
<File Id="uninstall_bat" Source="__SOURCE__\uninstall.bat" />
2627
</Component>
@@ -102,9 +103,11 @@
102103
</ComponentGroup>
103104
<CustomAction Id="RunPostInstallScript" FileKey="postinstall_bat" ExeCommand="&quot;[INSTALLFOLDER]&quot;" Return="check" Execute="deferred" Impersonate="no" />
104105
<CustomAction Id="RunUninstallScript" FileKey="uninstall_bat" ExeCommand="&quot;[INSTALLFOLDER]&quot;" Execute="deferred" Return="ignore" Impersonate="yes" />
106+
<CustomAction Id="RunVMCleanupScript" FileKey="removevm_bat" ExeCommand="&quot;[INSTALLFOLDER]&quot;" Execute="deferred" Return="ignore" Impersonate="yes" />
105107
<InstallExecuteSequence>
106108
<RemoveExistingProducts After="InstallInitialize" />
107-
<Custom Action="RunPostInstallScript" After="InstallFiles">NOT Installed</Custom>
109+
<Custom Action="RunVMCleanupScript" After="InstallFiles">NOT Installed</Custom>
110+
<Custom Action="RunPostInstallScript" After="RunVMCleanupScript">NOT Installed</Custom>
108111
<Custom Action="RunUninstallScript" After="InstallInitialize">REMOVE="ALL"</Custom>
109112
</InstallExecuteSequence>
110113
<Property Id="WIXUI_INSTALLDIR" Value="ProgramFiles64Folder" />

msi-builder/removevm.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@echo off
2+
SET InstallDir=%~1
3+
4+
:: Stop and remove any running instance
5+
finch.exe vm stop -f ^ &
6+
finch.exe vm remove -f ^ &
7+
8+
:: Just in case
9+
wsl --terminate lima-finch ^ &
10+
wsl --unregister lima-finch

0 commit comments

Comments
 (0)