diff --git a/cli/tauri-cli/src/bundle/dmg_bundle.rs b/cli/tauri-cli/src/bundle/dmg_bundle.rs index 593ce2a72..dfb6802c2 100644 --- a/cli/tauri-cli/src/bundle/dmg_bundle.rs +++ b/cli/tauri-cli/src/bundle/dmg_bundle.rs @@ -6,9 +6,10 @@ use handlebars::Handlebars; use lazy_static::lazy_static; use std::collections::BTreeMap; -use std::fs::write; +use std::fs::{File, write}; use std::path::PathBuf; use std::process::{Command, Stdio}; +use std::io::Write; // Create handlebars template for shell scripts lazy_static! { @@ -50,11 +51,18 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { // write the scripts write(&bundle_sh, bundle_temp).or_else(|e| Err(e.to_string()))?; + // copy seticon binary + let seticon = include_bytes!("templates/seticon"); + let seticon_out = &output_path.join("seticon"); + let mut seticon_buffer = File::create(seticon_out).or_else(|e| Err(e.to_string()))?; + seticon_buffer.write_all(seticon).or_else(|e| Err(e.to_string()))?; + // chmod script for execution Command::new("chmod") .arg("777") .arg(&bundle_sh) + .arg(&seticon_out) .current_dir(output_path) .stdout(Stdio::piped()) .stderr(Stdio::piped()) diff --git a/cli/tauri-cli/src/bundle/settings.rs b/cli/tauri-cli/src/bundle/settings.rs index 8642f763b..09b8dc284 100644 --- a/cli/tauri-cli/src/bundle/settings.rs +++ b/cli/tauri-cli/src/bundle/settings.rs @@ -73,6 +73,8 @@ const ALL_PACKAGE_TYPES: &[PackageType] = &[ PackageType::WindowsMsi, PackageType::OsxBundle, PackageType::Rpm, + #[cfg(feature = "dmg")] + PackageType::Dmg, ]; #[derive(Clone, Debug)] diff --git a/cli/tauri-cli/src/bundle/templates/bundle_dmg b/cli/tauri-cli/src/bundle/templates/bundle_dmg index f2f6371c1..c0c8c1590 100644 --- a/cli/tauri-cli/src/bundle/templates/bundle_dmg +++ b/cli/tauri-cli/src/bundle/templates/bundle_dmg @@ -34,7 +34,7 @@ sleep 5 bless --folder "${MOUNT_DIR}" -label "${MACOS_APP_NAME}" test -d "${MOUNT_DIR}/.background" || mkdir "${MOUNT_DIR}/.background" -cp ../../icons/bg.png "${MOUNT_DIR}"/.background/bg.png +test -f ../../icons/bg.png && cp ../../icons/bg.png "${MOUNT_DIR}"/.background/bg.png # I couldn't get DeRez and Rez to work. Leaving it here in case its helpful in the future. ### DeRez -only icns "${MOUNT_DIR}/.VolumeIcon.icns" > "${MOUNT_DIR}/.VolumeIcon.rsrc" @@ -46,7 +46,7 @@ VERSION=$(sw_vers -productVersion | cut -d'.' -f2) if [ "$VERSION" -gt 12 ]; then echo "Using SIPS v10.13+" - sips --i "${MOUNT_DIR}/.VolumeIcon.icns" # 10.13+ + sips -i "${MOUNT_DIR}/.VolumeIcon.icns" # 10.13+ else echo "Using SIPS v10.12-" sips --addIcon "${MOUNT_DIR}/.VolumeIcon.icns"