diff --git a/tools/rust/cargo-proton-bundle/Cargo.lock b/tools/rust/cargo-proton-bundle/Cargo.lock index 7926cb542..a4c0c39f3 100644 --- a/tools/rust/cargo-proton-bundle/Cargo.lock +++ b/tools/rust/cargo-proton-bundle/Cargo.lock @@ -1365,27 +1365,6 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand" version = "0.6.5" @@ -2182,7 +2161,6 @@ name = "uuid" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2562,8 +2540,6 @@ dependencies = [ "checksum publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5afecba86dcf1e4fd610246f89899d1924fe12e1e89f555eb7c7f710f3c5ad1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" diff --git a/tools/rust/cargo-proton-bundle/Cargo.toml b/tools/rust/cargo-proton-bundle/Cargo.toml index 7ce5f2d8a..9eda6a23b 100644 --- a/tools/rust/cargo-proton-bundle/Cargo.toml +++ b/tools/rust/cargo-proton-bundle/Cargo.toml @@ -28,7 +28,7 @@ tar = "0.4" target_build_utils = "0.3" term = "0.4" toml = "0.4" -uuid = { version = "0.5", features = ["v5", "v4"] } +uuid = { version = "0.5", features = ["v5"] } walkdir = "2" slog-term = "2.4.1" @@ -40,6 +40,7 @@ reqwest = "0.9.19" hex = "0.3" zip = "0.5" + [dev-dependencies] tempfile = "3" winit = "0.11" diff --git a/tools/rust/cargo-proton-bundle/src/bundle/msi_bundle.rs b/tools/rust/cargo-proton-bundle/src/bundle/msi_bundle.rs index bc1838013..99ca787c4 100644 --- a/tools/rust/cargo-proton-bundle/src/bundle/msi_bundle.rs +++ b/tools/rust/cargo-proton-bundle/src/bundle/msi_bundle.rs @@ -3,6 +3,7 @@ use super::settings::Settings; use super::wix; use crate::ResultExt; use cab; +use dirs; use msi; use slog::Drain; use slog_term; @@ -30,12 +31,6 @@ const FILE_ATTR_VITAL: u16 = 0x200; // The name of the installer package's sole Feature: const MAIN_FEATURE_NAME: &str = "MainFeature"; -// A v4 UUID that was generated specifically for cargo-bundle, to be used as a -// namespace for generating v5 UUIDs from bundle identifier strings. -const UUID_NAMESPACE: [u8; 16] = [ - 0xfd, 0x85, 0x95, 0xa8, 0x17, 0xa3, 0x47, 0x4e, 0xa6, 0x16, 0x76, 0x14, 0x8d, 0xfa, 0x0c, 0x7b, -]; - // Info about a resource file (including the main executable) in the bundle. struct ResourceInfo { // The path to the existing file that will be bundled as a resource. @@ -81,10 +76,10 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { new_empty_package(&msi_path).chain_err(|| "Failed to initialize MSI package")?; // Generate package metadata: - let guid = generate_package_guid(settings); - set_summary_info(&mut package, guid, settings); - create_property_table(&mut package, guid, settings) - .chain_err(|| "Failed to generate Property table")?; + // let guid = generate_package_guid(settings); + // set_summary_info(&mut package, guid, settings); + // create_property_table(&mut package, guid, settings) + // .chain_err(|| "Failed to generate Property table")?; // Copy resource files into package: let mut resources = @@ -99,7 +94,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { let drain = std::sync::Mutex::new(drain).fuse(); let logger = slog::Logger::root(drain, o!()); - wix::get_and_extract_wix(&logger, &env::home_dir().unwrap()); + wix::get_and_extract_wix(&logger, &dirs::home_dir().unwrap()); // Set up installer database tables: // create_directory_table(&mut package, &directories) @@ -151,12 +146,6 @@ fn new_empty_package(msi_path: &Path) -> crate::Result { Ok(package) } -// Generates a GUID for the package, based on `settings.bundle_identifier()`. -fn generate_package_guid(settings: &Settings) -> Uuid { - let namespace = Uuid::from_bytes(&UUID_NAMESPACE).unwrap(); - Uuid::new_v5(&namespace, &settings.bundle_identifier()) -} - // Populates the summary metadata for the package from the bundle settings. fn set_summary_info(package: &mut Package, package_guid: Uuid, settings: &Settings) { let summary_info = package.summary_info_mut(); diff --git a/tools/rust/cargo-proton-bundle/src/bundle/wix.rs b/tools/rust/cargo-proton-bundle/src/bundle/wix.rs index 4c1aa9ac0..1cd43088d 100644 --- a/tools/rust/cargo-proton-bundle/src/bundle/wix.rs +++ b/tools/rust/cargo-proton-bundle/src/bundle/wix.rs @@ -28,6 +28,12 @@ const VC_REDIST_X64_URL: &str = const VC_REDIST_X64_SHA256: &str = "d6cd2445f68815fe02489fafe0127819e44851e26dfbe702612bc0d223cbbc2b"; +// A v4 UUID that was generated specifically for cargo-bundle, to be used as a +// namespace for generating v5 UUIDs from bundle identifier strings. +const UUID_NAMESPACE: [u8; 16] = [ + 0xfd, 0x85, 0x95, 0xa8, 0x17, 0xa3, 0x47, 0x4e, 0xa6, 0x16, 0x76, 0x14, 0x8d, 0xfa, 0x0c, 0x7b, +]; + lazy_static! { static ref HANDLEBARS: Handlebars = { let mut handlebars = Handlebars::new(); @@ -105,6 +111,11 @@ fn extract_zip(data: &Vec, path: &Path) -> Result<(), String> { Ok(()) } +fn generate_package_guid(settings: &Settings) -> Uuid { + let namespace = Uuid::from_bytes(&UUID_NAMESPACE).unwrap(); + Uuid::new_v5(&namespace, &settings.bundle_identifier()) +} + pub fn get_and_extract_wix(logger: &Logger, path: &Path) -> Result<(), String> { info!(logger, "downloading WIX Toolkit..."); @@ -288,8 +299,8 @@ pub fn build_wix_app_installer( data.insert("upgrade_code", &upgrade_code); - let path_guid = Uuid::new_v4().to_string(); - data.insert("path_component_guid", &path_guid); + let path_guid = generate_package_guid(settings).to_string(); + data.insert("path_component_guid", &path_guid.as_str()); let app_exe_name = settings .binary_path()