8000 [WIP] MSI Installer by Boddlnagg · Pull Request #635 · rust-lang/rustup · GitHub
[go: up one dir, main page]

Skip to content

[WIP] MSI Installer #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 17, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Create hardlinks in installer CA
  • Loading branch information
Boddlnagg committed Aug 13, 2016
commit c12368e561c6f2e5eeed7583cf022109b084710c
4 changes: 2 additions & 2 deletions src/rustup-win-installer/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::env;

fn main() {
println!("cargo:rustc-link-lib=static=wcautil");
println!("cargo:rustc-link-lib=static=dutil");
println!("cargo:rustc-link-lib=dylib=msi");
println!("cargo:rustc-link-lib=dylib=wcautil");
println!("cargo:rustc-link-lib=dylib=dutil");
println!("cargo:rustc-link-lib=dylib=user32");
println!("cargo:rustc-link-lib=dylib=mincore");

Expand Down
3 changes: 2 additions & 1 deletion src/rustup-win-installer/msi/rustup.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
<Custom Action="AssignInstallLocation" After="RustupSetInstallLocation"/>
<Custom Action="SetInstallOptions" Before="InstallInitialize">NOT Installed</Custom>
<Custom Action="RustupInstall" After="InstallFiles">NOT Installed</Custom>
<Custom Action="RustupUninstall" Before="RemoveFiles">Installed</Custom>
<!-- Run RustupUninstall only on true uninstall, not on upgrade -->
<Custom Action="RustupUninstall" After="RemoveFiles">Installed AND (NOT UPGRADINGPRODUCTCODE)</Custom>
</InstallExecuteSequence>

<!-- Send a WM_SETTINGCHANGE message to tell processes like explorer to update their
Expand Down
23 changes: 18 additions & 5 deletions src/rustup-win-installer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pub const LOGMSG_TRACEONLY: i32 = 0;
pub const LOGMSG_VERBOSE: i32 = 1;
pub const LOGMSG_STANDARD: i32 = 2;

// TODO: share this with self_update.rs
static TOOLS: &'static [&'static str]
= &["rustc", "rustdoc", "cargo", "rust-lldb", "rust-gdb"];

#[no_mangle]
/// This is run as an `immediate` action early in the install sequence
pub unsafe extern "system" fn RustupSetInstallLocation(hInstall: MSIHANDLE) -> UINT {
Expand All @@ -26,30 +30,39 @@ pub unsafe extern "system" fn RustupSetInstallLocation(hInstall: MSIHANDLE) -> U
}

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

#[no_mangle]
/// This is be run as a `deferred` action before `RemoveFiles` on uninstall
/// This is be run as a `deferred` action after `RemoveFiles` on uninstall (not on upgrade!)
pub unsafe extern "system" fn RustupUninstall(hInstall: MSIHANDLE) -> UINT {
let name = CString::new("RustupUninstall").unwrap();
let hr = WcaInitialize(hInstall, name.as_ptr());
// For deferred custom actions, all data must be passed through the `CustomActionData` property
let custom_action_data = get_property("CustomActionData");
// TODO: use rustup_utils::cargo_home() or pass through CustomActionData
let path = PathBuf::from(::std::env::var_os("USERPROFILE").unwrap()).join(".rustup-test");
let exe_installed = path.join("bin").join("rustup.exe").exists();
log(&format!("Hello World from RustupUninstall, confirming that rustup.exe has not yet been removed: {}! CustomActionData: {}", exe_installed, custom_action_data));
let exe_deleted = !path.join("bin").join("rustup.exe").exists();
log(&format!("Hello World from RustupUninstall, confirming that rustup.exe has been deleted: {}! CustomActionData: {}", exe_deleted, custom_action_data));
// TODO: Remove .cargo and .multirust
::rustup::utils::remove_dir("rustup-test", &path, &|_| {});
WcaFinalize(hr)
}

Expand Down
0