Skip to content

Commit c12368e

Browse files
committed
Create hardlinks in installer CA
1 parent ae5d5ed commit c12368e

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/rustup-win-installer/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::env;
22

33
fn main() {
4+
println!("cargo:rustc-link-lib=static=wcautil");
5+
println!("cargo:rustc-link-lib=static=dutil");
46
println!("cargo:rustc-link-lib=dylib=msi");
5-
println!("cargo:rustc-link-lib=dylib=wcautil");
6-
println!("cargo:rustc-link-lib=dylib=dutil");
77
println!("cargo:rustc-link-lib=dylib=user32");
88
println!("cargo:rustc-link-lib=dylib=mincore");
99

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
<Custom Action="AssignInstallLocation" After="RustupSetInstallLocation"/>
7676
<Custom Action="SetInstallOptions" Before="InstallInitialize">NOT Installed</Custom>
7777
<Custom Action="RustupInstall" After="InstallFiles">NOT Installed</Custom>
78-
<Custom Action="RustupUninstall" Before="RemoveFiles">Installed</Custom>
78+
<!-- Run RustupUninstall only on true uninstall, not on upgrade -->
79+
<Custom Action="RustupUninstall" After="RemoveFiles">Installed AND (NOT UPGRADINGPRODUCTCODE)</Custom>
7980
</InstallExecuteSequence>
8081

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

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ pub const LOGMSG_TRACEONLY: i32 = 0;
1313
pub const LOGMSG_VERBOSE: i32 = 1;
1414
pub const LOGMSG_STANDARD: i32 = 2;
1515

16+
// TODO: share this with self_update.rs
17+
static TOOLS: &'static [&'static str]
18+
= &["rustc", "rustdoc", "cargo", "rust-lldb", "rust-gdb"];
19+
1620
#[no_mangle]
1721
/// This is run as an `immediate` action early in the install sequence
1822
pub unsafe extern "system" fn RustupSetInstallLocation(hInstall: MSIHANDLE) -> UINT {
@@ -26,30 +30,39 @@ pub unsafe extern "system" fn RustupSetInstallLocation(hInstall: MSIHANDLE) -> U
2630
}
2731

2832
#[no_mangle]
29-
/// This is be run as a `deferred` action after `InstallFiles`
33+
/// This is be run as a `deferred` action after `InstallFiles` on install and upgrade
3034
pub unsafe extern "system" fn RustupInstall(hInstall: MSIHANDLE) -> UINT {
3135
let name = CString::new("RustupInstall").unwrap();
3236
let hr = WcaInitialize(hInstall, name.as_ptr());
3337
// For deferred custom actions, all data must be passed through the `CustomActionData` property
3438
let custom_action_data = get_property("CustomActionData");
3539
// TODO: use rustup_utils::cargo_home() or pass through CustomActionData
3640
let path = PathBuf::from(::std::env::var_os("USERPROFILE").unwrap()).join(".rustup-test");
37-
let exe_installed = path.join("bin").join("rustup.exe").exists();
41+
let bin_path = path.join("bin");
42+
let rustup_path = bin_path.join("rustup.exe");
43+
let exe_installed = rustup_path.exists();
3844
log(&format!("Hello World from RustupInstall, confirming that rustup.exe has been installed: {}! CustomActionData: {}", exe_installed, custom_action_data));
45+
for tool in TOOLS {
46+
let ref tool_path = bin_path.join(&format!("{}.exe", tool));
47+
::rustup::utils::hardlink_file(&rustup_path, tool_path);
48+
}
49+
// TODO: install default toolchain and report progress to UI
3950
WcaFinalize(hr)
4051
}
4152

4253
#[no_mangle]
43-
/// This is be run as a `deferred` action before `RemoveFiles` on uninstall
54+
/// This is be run as a `deferred` action after `RemoveFiles` on uninstall (not on upgrade!)
4455
pub unsafe extern "system" fn RustupUninstall(hInstall: MSIHANDLE) -> UINT {
4556
let name = CString::new("RustupUninstall").unwrap();
4657
let hr = WcaInitialize(hInstall, name.as_ptr());
4758
// For deferred custom actions, all data must be passed through the `CustomActionData` property
4859
let custom_action_data = get_property("CustomActionData");
4960
// TODO: use rustup_utils::cargo_home() or pass through CustomActionData
5061
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));
62+
let exe_deleted = !path.join("bin").join("rustup.exe").exists();
63+
log(&format!("Hello World from RustupUninstall, confirming that rustup.exe has been deleted: {}! CustomActionData: {}", exe_deleted, custom_action_data));
64+
// TODO: Remove .cargo and .multirust
65+
::rustup::utils::remove_dir("rustup-test", &path, &|_| {});
5366
WcaFinalize(hr)
5467
}
5568

0 commit comments

Comments
 (0)