#!/bin/sh # SPDX-FileCopyrightText: 2026 Alexander Bates # # SPDX-License-Identifier: 0BSD # Builds the macOS disk image without macOS, which electron-builder can't: # an HFS+ volume holding the app, an Applications shortcut, and the # background, laid out by dmg-layout.py and compressed with LZFSE, like # electron-builder.yml's ULMO. Run from the cross devshell. # # scripts/make-dmg.sh dist/mac-universal/Diorama64.app dist/Diorama64.dmg set -eu here=$(cd "$(dirname "$0")" && pwd) app=$1 out=$2 name=$(basename "$app" .app) work=$(mktemp -d) trap 'rm -rf "$work"' EXIT mkdir -p "$work/stage/.background" # One TIFF holding both resolutions, which is how Finder picks the Retina # one. Each needs its own DPI, or Finder draws the 1x one at half size. magick "$here/../build/background.png" -units PixelsPerInch -set density 72 \ \( "$here/../build/background@2x.png" -units PixelsPerInch -set density 144 \) \ -compress lzw "$work/stage/.background/background.tiff" cp -a "$app" "$work/stage/" ln -s /Applications "$work/stage/Applications" # The volume is fixed-size, so leave room for the filesystem's own data. size=$(($(du -sm "$work/stage" | cut -f1) * 115 / 100 + 20)) truncate -s "${size}M" "$work/volume.hfs" mkfs.hfsplus -v "$name" "$work/volume.hfs" >/dev/null hfsplus "$work/volume.hfs" addall "$work/stage" -s clone_link >/dev/null python3 "$here/dmg-layout.py" "$work/DS_Store" "$name" "$name.app" hfsplus "$work/volume.hfs" add "$work/DS_Store" /.DS_Store dmg build "$work/volume.hfs" "$out" -c lzfse >/dev/null