diff --git a/.changes/log-binary-patching.md b/.changes/log-binary-patching.md new file mode 100644 index 000000000..fafcc316f --- /dev/null +++ b/.changes/log-binary-patching.md @@ -0,0 +1,7 @@ +--- +"tauri-bundler": patch:changes +"tauri-cli": patch:changes +"@tauri-apps/cli": patch:changes +--- + +Log patching bundle type information again diff --git a/crates/tauri-bundler/src/bundle.rs b/crates/tauri-bundler/src/bundle.rs index 042a3dfb2..e20fb19c8 100644 --- a/crates/tauri-bundler/src/bundle.rs +++ b/crates/tauri-bundler/src/bundle.rs @@ -22,41 +22,45 @@ const BUNDLE_VAR_TOKEN: &[u8] = b"__TAURI_BUNDLE_TYPE_VAR_UNK"; /// Patch a binary with bundle type information #[cfg(any(target_os = "linux", target_os = "windows"))] fn patch_binary(binary: &PathBuf, package_type: &PackageType) -> crate::Result<()> { + log::info!( + "Patching {} with bundle type information: {}", + display_path(binary), + package_type.short_name() + ); + let mut file_data = std::fs::read(binary).expect("Could not read binary file."); - if let Some(bundle_var_index) = kmp::index_of(BUNDLE_VAR_TOKEN, &file_data) { - #[cfg(target_os = "linux")] - let bundle_type = match package_type { - crate::PackageType::Deb => b"__TAURI_BUNDLE_TYPE_VAR_DEB", - crate::PackageType::Rpm => b"__TAURI_BUNDLE_TYPE_VAR_RPM", - crate::PackageType::AppImage => b"__TAURI_BUNDLE_TYPE_VAR_APP", - _ => { - return Err(crate::Error::InvalidPackageType( - package_type.short_name().to_owned(), - "Linux".to_owned(), - )) - } - }; - #[cfg(target_os = "windows")] - let bundle_type = match package_type { - crate::PackageType::Nsis => b"__TAURI_BUNDLE_TYPE_VAR_NSS", - crate::PackageType::WindowsMsi => b"__TAURI_BUNDLE_TYPE_VAR_MSI", - _ => { - return Err(crate::Error::InvalidPackageType( - package_type.short_name().to_owned(), - "Windows".to_owned(), - )) - } - }; + let bundle_var_index = + kmp::index_of(BUNDLE_VAR_TOKEN, &file_data).ok_or(crate::Error::MissingBundleTypeVar)?; + #[cfg(target_os = "linux")] + let bundle_type = match package_type { + crate::PackageType::Deb => b"__TAURI_BUNDLE_TYPE_VAR_DEB", + crate::PackageType::Rpm => b"__TAURI_BUNDLE_TYPE_VAR_RPM", + crate::PackageType::AppImage => b"__TAURI_BUNDLE_TYPE_VAR_APP", + _ => { + return Err(crate::Error::InvalidPackageType( + package_type.short_name().to_owned(), + "Linux".to_owned(), + )) + } + }; + #[cfg(target_os = "windows")] + let bundle_type = match package_type { + crate::PackageType::Nsis => b"__TAURI_BUNDLE_TYPE_VAR_NSS", + crate::PackageType::WindowsMsi => b"__TAURI_BUNDLE_TYPE_VAR_MSI", + _ => { + return Err(crate::Error::InvalidPackageType( + package_type.short_name().to_owned(), + "Windows".to_owned(), + )) + } + }; - file_data[bundle_var_index..bundle_var_index + BUNDLE_VAR_TOKEN.len()] - .copy_from_slice(bundle_type); + file_data[bundle_var_index..bundle_var_index + BUNDLE_VAR_TOKEN.len()] + .copy_from_slice(bundle_type); + + std::fs::write(binary, &file_data).map_err(|e| crate::Error::BinaryWriteError(e.to_string()))?; - std::fs::write(binary, &file_data) - .map_err(|e| crate::Error::BinaryWriteError(e.to_string()))?; - } else { - return Err(crate::Error::MissingBundleTypeVar); - } Ok(()) }