#!/usr/bin/env bash set -euo pipefail BASE_URL="${PONPOKO_DOWNLOAD_URL:-https://ponpoko.app}" APP_NAME="Ponpoko.app" INSTALL_DIR="${PONPOKO_INSTALL_DIR:-/Applications}" TMP_DMG="$(mktemp -t ponpoko-install).dmg" MOUNT_POINT="" cleanup() { if [ -n "$MOUNT_POINT" ]; then hdiutil detach "$MOUNT_POINT" -quiet 2>/dev/null || true rmdir "$MOUNT_POINT" 2>/dev/null || true fi rm -f "$TMP_DMG" } trap cleanup EXIT tauri_arch() { case "$(uname -m)" in arm64) echo "aarch64" ;; x86_64) echo "x64" ;; *) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;; esac } latest_version() { curl -fsSL "$BASE_URL/latest.json" | sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' } mount_dmg() { hdiutil attach "$TMP_DMG" -nobrowse -readonly -mountpoint "$MOUNT_POINT" -quiet } trust_own_https_build() { xattr -dr com.apple.quarantine "$INSTALL_DIR/$APP_NAME" 2>/dev/null || true } arch="$(tauri_arch)" echo "→ Fetching release info…" version="$(latest_version)" version="${version#v}" if [ -z "$version" ]; then echo "Could not determine latest version from $BASE_URL/latest.json" >&2 exit 1 fi dmg_name="ponpoko_${version}_${arch}.dmg" echo "→ Downloading ${dmg_name}…" curl -fSL --progress-bar "$BASE_URL/download/$dmg_name" -o "$TMP_DMG" echo "→ Installing to ${INSTALL_DIR}…" # finisher-hygiene-allow: `hdiutil attach -quiet` stopped printing the device table on recent macOS, so an explicit mountpoint is the only way to know where the volume landed MOUNT_POINT="$(mktemp -d -t ponpoko-mount)" mount_dmg rm -rf "$INSTALL_DIR/$APP_NAME" mkdir -p "$INSTALL_DIR" cp -R "$MOUNT_POINT/$APP_NAME" "$INSTALL_DIR/" hdiutil detach "$MOUNT_POINT" -quiet rmdir "$MOUNT_POINT" 2>/dev/null || true MOUNT_POINT="" trust_own_https_build echo "✓ Ponpoko $version installed → $INSTALL_DIR/$APP_NAME" open "$INSTALL_DIR/$APP_NAME"