Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(packaging): macOS .dmg build script with signing and notarization

rubenluetke10-beep8c67015ab566
diff --git a/packaging/macos/.gitattributes b/packaging/macos/.gitattributes
new file mode 100644
index 0000000000..db5ecfc16e
--- /dev/null
+++ b/packaging/macos/.gitattributes
@@ -0,0 +1,2 @@
+# Shell scripts run on macOS and Linux runners; a CRLF shebang breaks them.
+*.sh text eol=lf
diff --git a/packaging/macos/build.sh b/packaging/macos/build.sh
new file mode 100644
index 0000000000..f0457a3dc8
--- /dev/null
+++ b/packaging/macos/build.sh
@@ -0,0 +1,257 @@
+#!/usr/bin/env bash
+#
+# Build the distributable macOS disk image for Personal Jarvis.
+#
+# packaging/macos/build.sh
+#
+# Output (per the release contract):
+# dist/installers/PersonalJarvis-macOS-arm64.dmg on Apple Silicon
+# dist/installers/PersonalJarvis-macOS-x64.dmg on Intel
+#
+# The disk image contains "Personal Jarvis.app" next to a symlink to
+# /Applications, which is the drag-to-install layout every Mac user already
+# knows. The app is a PyInstaller BUNDLE built from jarvis.spec.
+#
+# Signing and notarization are driven entirely by the environment, so the same
+# script runs unchanged on a maintainer's Mac and on a GitHub runner:
+#
+# APPLE_SIGNING_IDENTITY "Developer ID Application: NAME (TEAMID)"
+# APPLE_ID Apple ID used for notarization
+# APPLE_TEAM_ID 10-character team identifier
+# APPLE_APP_SPECIFIC_PASSWORD app-specific password for that Apple ID
+#
+# With APPLE_SIGNING_IDENTITY unset the script ad-hoc signs instead and skips
+# notarization, printing one clear line about what that means for the person
+# who downloads the result. Nothing is silently "signed enough".
+#
+# Extra knobs:
+# DRY_RUN=1 print every command instead of running it (CI-free rehearsal)
+# PYTHON=... interpreter to build with (default: python3)
+# SKIP_FRONTEND=1 never run npm, even when the web bundle is missing
+#
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
+DRY_RUN="${DRY_RUN:-0}"
+PYTHON="${PYTHON:-python3}"
+SKIP_FRONTEND="${SKIP_FRONTEND:-0}"
+
+APP_NAME="Personal Jarvis"
+VOLUME_NAME="Personal Jarvis"
+DIST_DIR="${REPO_ROOT}/dist"
+APP_BUNDLE="${DIST_DIR}/${APP_NAME}.app"
+OUT_DIR="${DIST_DIR}/installers"
+FRONTEND_DIST="${REPO_ROOT}/jarvis/ui/web/dist"
+ENTITLEMENTS="${SCRIPT_DIR}/entitlements.plist"
+ICNS="${REPO_ROOT}/assets/icons/jarvis.icns"
+
+log() { printf '[macos-build] %s\n' "$*"; }
+die() { printf '[macos-build] ERROR: %s\n' "$*" >&2; exit 1; }
+
+# Echo the exact command, then run it (or not, under DRY_RUN). Never used for
+# anything that carries a secret - see notarize() for that path.
+run() {
+ printf '+'
+ printf ' %q' "$@"
+ printf '\n'
+ if [ "${DRY_RUN}" = "1" ]; then
+ return 0
+ fi
+ "$@"
+}
+
+# True when a real build is happening; DRY_RUN skips the existence checks that
+# would otherwise abort a rehearsal on a machine with no build output.
+building() { [ "${DRY_RUN}" != "1" ]; }
+
+# --- 0. Host and target -----------------------------------------------------
+
+if building && [ "$(uname -s)" != "Darwin" ]; then
+ die "this script builds a macOS app bundle and only runs on macOS (use DRY_RUN=1 to rehearse elsewhere)"
+fi
+
+MACHINE="$(uname -m)"
+case "${MACHINE}" in
+ arm64) ARCH_TAG="arm64" ;;
+ x86_64) ARCH_TAG="x64" ;;
+ *) die "unsupported macOS architecture: ${MACHINE}" ;;
+esac
+DMG_PATH="${OUT_DIR}/PersonalJarvis-macOS-${ARCH_TAG}.dmg"
+log "host ${MACHINE} -> building ${ARCH_TAG}"
+
+# --- 1. Web bundle ----------------------------------------------------------
+
+if [ -d "${FRONTEND_DIST}" ] && [ -f "${FRONTEND_DIST}/index.html" ]; then
+ log "web bundle present: ${FRONTEND_DIST}"
+elif [ "${SKIP_FRONTEND}" = "1" ]; then
+ die "web bundle missing and SKIP_FRONTEND=1 - build it with 'npm run build' in jarvis/ui/web/frontend"
+else
+ log "web bundle missing - building it"
+ command -v npm >/dev/null 2>&1 || die "npm is required to build the web bundle"
+ (
+ cd "${REPO_ROOT}/jarvis/ui/web/frontend"
+ if [ ! -d node_modules ]; then
+ run npm ci
+ fi
+ run npm run build
+ )
+fi
+
+# --- 2. Freeze --------------------------------------------------------------
+
+command -v "${PYTHON}" >/dev/null 2>&1 || die "interpreter not found: ${PYTHON}"
+if building; then
+ "${PYTHON}" -c "import PyInstaller" >/dev/null 2>&1 \
+ || die "PyInstaller is not installed for ${PYTHON} (pip install pyinstaller)"
+fi
+
+if [ -f "${ICNS}" ] || [ "${DRY_RUN}" = "1" ]; then
+ :
+else
+ log "regenerating the app icon (${ICNS} is missing)"
+ run "${PYTHON}" "${SCRIPT_DIR}/make_icns.py"
+fi
+
+log "running PyInstaller"
+(
+ cd "${REPO_ROOT}"
+ run "${PYTHON}" -m PyInstaller jarvis.spec --noconfirm --clean
+)
+
+if building; then
+ [ -d "${APP_BUNDLE}" ] || die "PyInstaller did not produce '${APP_BUNDLE}'. jarvis.spec must contain a darwin BUNDLE(...) block that names the app '${APP_NAME}'."
+ [ -x "${APP_BUNDLE}/Contents/MacOS/jarvis" ] \
+ || die "'${APP_BUNDLE}/Contents/MacOS/jarvis' is missing. The bundle must ship the console CLI entry so 'jarvis serve' works from a native install."
+fi
+log "app bundle: ${APP_BUNDLE}"
+
+# --- 3. Code signing --------------------------------------------------------
+
+SIGNED_FOR_DISTRIBUTION=0
+if [ -n "${APPLE_SIGNING_IDENTITY:-}" ]; then
+ SIGNED_FOR_DISTRIBUTION=1
+ log "signing with Developer ID identity: ${APPLE_SIGNING_IDENTITY}"
+ [ -f "${ENTITLEMENTS}" ] || die "entitlements file missing: ${ENTITLEMENTS}"
+
+ # Inside-out first: codesign refuses to seal a bundle whose nested Mach-O
+ # objects are unsigned or stale, and a PyInstaller bundle carries hundreds of
+ # them. Apple's own guidance is to sign nested code before the container;
+ # --deep on the outer seal below is the safety net, not the strategy.
+ if building; then
+ while IFS= read -r -d '' object; do
+ run codesign --force --timestamp --options runtime \
+ --entitlements "${ENTITLEMENTS}" \
+ --sign "${APPLE_SIGNING_IDENTITY}" "${object}"
+ done < <(
+ find "${APP_BUNDLE}/Contents" -type f \
+ \( -name '*.dylib' -o -name '*.so' -o -perm -u+x \) -print0 \
+ | while IFS= read -r -d '' candidate; do
+ if file -b "${candidate}" | grep -q 'Mach-O'; then
+ printf '%s\0' "${candidate}"
+ fi
+ done
+ )
+ else
+ log "[dry-run] would sign every Mach-O object under ${APP_BUNDLE}/Contents"
+ fi
+
+ run codesign --force --deep --timestamp --options runtime \
+ --entitlements "${ENTITLEMENTS}" \
+ --sign "${APPLE_SIGNING_IDENTITY}" "${APP_BUNDLE}"
+ run codesign --verify --strict --verbose=2 "${APP_BUNDLE}"
+else
+ log "NOTICE: APPLE_SIGNING_IDENTITY is not set - ad-hoc signing this build. It is NOT notarized; macOS will refuse the first double-click and the user must right-click the app once and choose Open."
+ run codesign --force --deep -s - "${APP_BUNDLE}"
+fi
+
+# --- 4. Notarization --------------------------------------------------------
+
+NOTARIZED=0
+notary_credentials_present() {
+ [ -n "${APPLE_ID:-}" ] && [ -n "${APPLE_TEAM_ID:-}" ] && [ -n "${APPLE_APP_SPECIFIC_PASSWORD:-}" ]
+}
+
+# Submit one artifact and wait for Apple's verdict. The password never reaches
+# the log: the command line is printed with the secret replaced, and the real
+# invocation is not echoed.
+notarize() {
+ local artifact="$1"
+ printf '+ xcrun notarytool submit %q --apple-id %q --team-id %q --password <redacted> --wait\n' \
+ "${artifact}" "${APPLE_ID:-}" "${APPLE_TEAM_ID:-}"
+ if [ "${DRY_RUN}" = "1" ]; then
+ return 0
+ fi
+ xcrun notarytool submit "${artifact}" \
+ --apple-id "${APPLE_ID}" \
+ --team-id "${APPLE_TEAM_ID}" \
+ --password "${APPLE_APP_SPECIFIC_PASSWORD}" \
+ --wait
+}
+
+if [ "${SIGNED_FOR_DISTRIBUTION}" = "1" ] && notary_credentials_present; then
+ NOTARIZED=1
+ # The app is notarized on its own before the disk image so the ticket can be
+ # stapled INTO the bundle. A ticket stapled only to the .dmg disappears the
+ # moment the user drags the app out of it, which is the one thing every user
+ # does - the app would then need a network round trip on first launch.
+ ZIP_PATH="${DIST_DIR}/PersonalJarvis-macOS-${ARCH_TAG}-notarize.zip"
+ run rm -f "${ZIP_PATH}"
+ run ditto -c -k --keepParent "${APP_BUNDLE}" "${ZIP_PATH}"
+ notarize "${ZIP_PATH}"
+ run xcrun stapler staple "${APP_BUNDLE}"
+ run rm -f "${ZIP_PATH}"
+elif [ "${SIGNED_FOR_DISTRIBUTION}" = "1" ]; then
+ log "NOTICE: Developer ID signed but NOT notarized - APPLE_ID, APPLE_TEAM_ID and APPLE_APP_SPECIFIC_PASSWORD must all be set for notarization."
+fi
+
+# --- 5. Disk image ----------------------------------------------------------
+
+run mkdir -p "${OUT_DIR}"
+run rm -f "${DMG_PATH}"
+
+STAGE_DIR="${DIST_DIR}/dmg-stage-${ARCH_TAG}"
+run rm -rf "${STAGE_DIR}"
+run mkdir -p "${STAGE_DIR}"
+# -R: the bundle contains symlinks (Frameworks/Versions/Current); cp -R keeps
+# them as symlinks instead of duplicating the targets and doubling the size.
+run cp -R "${APP_BUNDLE}" "${STAGE_DIR}/${APP_NAME}.app"
+run ln -s /Applications "${STAGE_DIR}/Applications"
+
+log "building the disk image"
+# UDZO = zlib-compressed read-only image, the ordinary format for a downloaded
+# .dmg. HFS+ rather than APFS so the image also mounts on the older macOS
+# versions the app still supports.
+run hdiutil create \
+ -volname "${VOLUME_NAME}" \
+ -srcfolder "${STAGE_DIR}" \
+ -fs HFS+ \
+ -format UDZO \
+ -ov \
+ "${DMG_PATH}"
+run rm -rf "${STAGE_DIR}"
+
+if [ "${SIGNED_FOR_DISTRIBUTION}" = "1" ]; then
+ run codesign --force --timestamp --sign "${APPLE_SIGNING_IDENTITY}" "${DMG_PATH}"
+fi
+if [ "${NOTARIZED}" = "1" ]; then
+ # Second submission, this time for the container itself: a downloaded .dmg
+ # carries its own quarantine flag and is gatekeeper-checked before anything
+ # inside it is read.
+ notarize "${DMG_PATH}"
+ run xcrun stapler staple "${DMG_PATH}"
+fi
+
+log "verifying the disk image"
+run hdiutil verify "${DMG_PATH}"
+if [ "${NOTARIZED}" = "1" ]; then
+ run xcrun stapler validate "${DMG_PATH}"
+fi
+
+# --- 6. Report --------------------------------------------------------------
+
+if [ "${SIGNED_FOR_DISTRIBUTION}" != "1" ]; then
+ log "NOTICE: this build is ad-hoc signed and unnotarized - suitable for local testing, not for public download."
+fi
+log "done"
+printf '%s\n' "${DMG_PATH}"
diff --git a/packaging/macos/entitlements.plist b/packaging/macos/entitlements.plist
new file mode 100644
index 0000000000..87184f3cbc
--- /dev/null
+++ b/packaging/macos/entitlements.plist
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!--
+ Hardened Runtime entitlements for the notarized "Personal Jarvis.app".
+
+ Notarization requires the Hardened Runtime (codesign --options runtime), and
+ the Hardened Runtime denies by default exactly the things this app needs.
+ Every entry below is here because leaving it out breaks a shipped feature or
+ stops the app from launching at all — nothing is requested "just in case",
+ because each one weakens a real platform protection.
+
+ The matching user-facing NSxxxUsageDescription strings live in the bundle's
+ Info.plist (built by jarvis.spec). Entitlements grant the app the RIGHT to
+ ask; the usage strings are what the person reads in the prompt. Both halves
+ are required: a hardened app missing the entitlement is refused before the
+ prompt appears, and one missing the usage string is killed by the system the
+ moment it asks.
+-->
+<plist version="1.0">
+<dict>
+ <!--
+ Microphone. The whole voice pipeline (wake word, dictation, calls) reads
+ the default input device through PortAudio. Without this a hardened build
+ fails every capture attempt instead of showing the microphone prompt.
+ -->
+ <key>com.apple.security.device.audio-input</key>
+ <true/>
+
+ <!--
+ Camera. Only the vision/screen-share features touch it, and they degrade
+ honestly when the user declines - but a hardened app without the
+ entitlement cannot even ask, so the decline would not be the user's.
+ -->
+ <key>com.apple.security.device.camera</key>
+ <true/>
+
+ <!--
+ Apple events. Jarvis drives other applications through AppleScript for the
+ media-session and window-control paths (jarvis/platform/media_session.py,
+ music_player.py). Sending an Apple event to another process from a hardened
+ app requires this entitlement plus the NSAppleEventsUsageDescription string.
+ -->
+ <key>com.apple.security.automation.apple-events</key>
+ <true/>
+
+ <!--
+ Unsigned executable memory. Not optional for a CPython application:
+ ctypes/libffi build closure trampolines in memory it marks executable
+ (sounddevice's PortAudio binding, vosk's libvosk binding, and several
+ numeric wheels all go through ctypes). The Hardened Runtime kills the
+ process on the first such allocation without this. Justified rather than
+ inherited: it is the narrowest of the three "allow ... memory" entitlements
+ - allow-jit and allow-unsigned-executable-memory's unrestricted sibling are
+ deliberately NOT requested.
+ -->
+ <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
+ <true/>
+
+ <!--
+ Library validation. A PyInstaller bundle dlopen()s dozens of third-party
+ .so/.dylib files out of Contents/Frameworks and Contents/Resources at
+ runtime (onnxruntime, PortAudio, libvosk, PyAV's FFmpeg libraries). Library
+ validation demands every loaded library be signed by the SAME team ID as
+ the main binary; the re-sign pass in packaging/macos/build.sh does re-sign
+ them, but any library loaded from a path the pass did not walk - or a
+ plugin the user installs later into the same process - is then refused and
+ the feature dies with an opaque "code signature invalid". This is the one
+ entitlement here that could be dropped later: it needs a build where every
+ loadable object is provably signed by us, which the plugin system's
+ "install a wheel at runtime" design currently rules out.
+ -->
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+</dict>
+</plist>