Skip to content

Commit 9310982

Browse files
committed
Add stubs for uninstall (also handles upgrade)
1 parent 1a77ba9 commit 9310982

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/rustup-win-installer/msi/rustup.wxs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
<Property Id="ARPURLINFOABOUT" Value="http://www.rustup.rs" />
2424
<!--<Property Id="ARPHELPLINK" Value="http://www.rustup.rs" />-->
2525
<Property Id="ARPPRODUCTICON" Value="rust.ico" />
26+
27+
<!-- Disable Modify and Repair options (our custom actions based install model does not support repairing) -->
28+
<Property Id="ARPNOMODIFY" Value="1" />
29+
<Property Id="ARPNOREPAIR" Value="1" />
2630

2731
<Icon Id="rust.ico" SourceFile="rust-logo.ico"/>
2832

@@ -62,14 +66,15 @@
6266
<!-- Propagate the value of `RustupInstallLocation` (set by custom action) to `INSTALLLOCATION` -->
6367
<CustomAction Id="AssignInstallLocation" Directory="INSTALLLOCATION" Value="[RustupInstallLocation]"/>
6468
<CustomAction Id="RustupInstall" BinaryKey="RustupCustomActionDll" DllEntry="RustupInstall" Execute="deferred" Return="check" Impersonate="yes"/>
69+
<CustomAction Id="RustupUninstall" BinaryKey="RustupCustomActionDll" DllEntry="RustupUninstall" Execute="deferred" Return="check" Impersonate="yes"/>
6570

6671
<InstallExecuteSequence>
6772
<DisableRollback Before="InstallInitialize"/>
6873
<Custom Action="RustupSetInstallLocation" After="CostFinalize"/>
6974
<Custom Action="AssignInstallLocation" After="RustupSetInstallLocation"/>
70-
<!-- The next two will not be run on uninstall (TODO: add RustupUninstall and also handle upgrade) -->
7175
<Custom Action="SetInstallOptions" Before="InstallInitialize">NOT Installed</Custom>
7276
<Custom Action="RustupInstall" After="InstallFiles">NOT Installed</Custom>
77+
<Custom Action="RustupUninstall" Before="RemoveFiles">Installed</Custom>
7378
</InstallExecuteSequence>
7479

7580
<!-- Send a WM_SETTINGCHANGE message to tell processes like explorer to update their

src/rustup-win-installer/msi/ui.wxs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
3636
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
3737
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
38-
39-
<Property Id="ARPNOMODIFY" Value="1" />
4038
</UI>
4139
<UIRef Id="WixUI_Common" />
4240
</Fragment>

src/rustup-win-installer/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ pub unsafe extern "system" fn RustupInstall(hInstall: MSIHANDLE) -> UINT {
3939
WcaFinalize(hr)
4040
}
4141

42+
#[no_mangle]
43+
/// This is be run as a `deferred` action before `RemoveFiles` on uninstall
44+
pub unsafe extern "system" fn RustupUninstall(hInstall: MSIHANDLE) -> UINT {
45+
let name = CString::new("RustupUninstall").unwrap();
46+
let hr = WcaInitialize(hInstall, name.as_ptr());
47+
// For deferred custom actions, all data must be passed through the `CustomActionData` property
48+
let custom_action_data = get_property("CustomActionData");
49+
// TODO: use rustup_utils::cargo_home() or pass through CustomActionData
50+
let path = PathBuf::from(::std::env::var_os("USERPROFILE").unwrap()).join(".rustup-test");
51+
let exe_installed = path.join("bin").join("rustup.exe").exists();
52+
log(&format!("Hello World from RustupUninstall, confirming that rustup.exe has not yet been removed: {}! CustomActionData: {}", exe_installed, custom_action_data));
53+
WcaFinalize(hr)
54+
}
55+
4256
// wrapper for WcaGetProperty (TODO: error handling)
4357
fn get_property(name: &str) -> String {
4458
let encoded_name = to_wide_chars(name);

0 commit comments

Comments
 (0)