From c54471ee2eaedd74a8a5305ec3ffaf408bb2c302 Mon Sep 17 00:00:00 2001 From: kua-agent Date: Tue, 1 Sep 2026 12:55:22 +0400 Subject: [PATCH] =?UTF-8?q?installer:=20make-dmg.sh=20=E2=80=94=20signed?= =?UTF-8?q?=20app=20DMG=20with=20/Applications=20symlink?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/make-dmg.sh | 95 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 scripts/make-dmg.sh diff --git a/scripts/make-dmg.sh b/scripts/make-dmg.sh new file mode 100755 index 0000000..301e1cb --- /dev/null +++ b/scripts/make-dmg.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$ROOT" + +APP_BUNDLE="${ROOT}/.build/Shotdeck.app" +STAGING="${ROOT}/.build/dmg-staging" +DMG="${ROOT}/.build/Shotdeck.dmg" +MOUNT_POINT="${ROOT}/.build/dmg-mnt" + +SKIP_SIGN=0 +for arg in "$@"; do + case "${arg}" in + --skip-sign) + SKIP_SIGN=1 + ;; + *) + echo "Unknown argument: ${arg}" >&2 + echo "Usage: $0 [--skip-sign]" >&2 + exit 1 + ;; + esac +done + +echo "==> Building Shotdeck.app" +if [[ "${SKIP_SIGN}" -eq 1 ]]; then + ./scripts/build-app.sh --skip-sign +else + ./scripts/build-app.sh +fi + +if [[ ! -d "${APP_BUNDLE}" ]]; then + echo "App bundle not found at ${APP_BUNDLE}" >&2 + exit 1 +fi + +echo "==> Staging DMG contents" +rm -rf "${STAGING}" +mkdir -p "${STAGING}" +ditto "${APP_BUNDLE}" "${STAGING}/Shotdeck.app" +ln -s /Applications "${STAGING}/Applications" + +echo "==> Creating ${DMG}" +mkdir -p "$(dirname "${DMG}")" +hdiutil create -volname "Shotdeck" -srcfolder "${STAGING}" -ov -format UDZO "${DMG}" + +MOUNTED=0 +detach_dmg() { + if [[ "${MOUNTED}" -eq 1 ]]; then + hdiutil detach "${MOUNT_POINT}" || hdiutil detach "${MOUNT_POINT}" -force || true + MOUNTED=0 + fi +} +trap detach_dmg EXIT + +if [[ -d "${MOUNT_POINT}" ]] && /sbin/mount | grep -F -q "${MOUNT_POINT}"; then + hdiutil detach "${MOUNT_POINT}" || hdiutil detach "${MOUNT_POINT}" -force +fi +rm -rf "${MOUNT_POINT}" +mkdir -p "${MOUNT_POINT}" + +echo "==> Verifying ${DMG}" +hdiutil attach "${DMG}" -nobrowse -readonly -mountpoint "${MOUNT_POINT}" +MOUNTED=1 + +echo "==> Mount contents" +ls -la "${MOUNT_POINT}" + +if [[ ! -d "${MOUNT_POINT}/Shotdeck.app" ]]; then + echo "Verification failed: Shotdeck.app missing from mounted DMG" >&2 + exit 1 +fi +if [[ ! -L "${MOUNT_POINT}/Applications" ]]; then + echo "Verification failed: Applications symlink missing from mounted DMG" >&2 + exit 1 +fi +if [[ "$(readlink "${MOUNT_POINT}/Applications")" != "/Applications" ]]; then + echo "Verification failed: Applications does not point at /Applications" >&2 + exit 1 +fi + +echo "==> codesign --verify --deep" +codesign --verify --deep --verbose=2 "${MOUNT_POINT}/Shotdeck.app" + +echo "==> Detaching ${MOUNT_POINT}" +hdiutil detach "${MOUNT_POINT}" +MOUNTED=0 +trap - EXIT + +SHA256="$(shasum -a 256 "${DMG}" | awk '{print $1}')" + +echo +echo "DMG path: ${DMG}" +echo "SHA256: ${SHA256}" -- 2.54.0