fix(bundler): Fix DMG script (#283)

- Fix sips command
- Copy seticon from templates folder
- Only cp bg.png if it exists
This commit is contained in:
Rajiv Shah 2020-01-08 05:52:23 -05:00 committed by nothingismagick
parent e3d21dae5f
commit 2b28b52097
3 changed files with 13 additions and 3 deletions

View File

@ -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<Vec<PathBuf>> {
// 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())

View File

@ -73,6 +73,8 @@ const ALL_PACKAGE_TYPES: &[PackageType] = &[
PackageType::WindowsMsi,
PackageType::OsxBundle,
PackageType::Rpm,
#[cfg(feature = "dmg")]
PackageType::Dmg,
];
#[derive(Clone, Debug)]

View File

@ -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"