#!/bin/bash set -e # Generated by binary-publish. Do not edit by hand. APP_NAME="Bloom" SLUG="bloom" BASE_URL="https://artifacts.videodb.io/${SLUG}" APP_DIR="/Applications/${APP_NAME}.app" RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; BOLD='\033[1m'; NC='\033[0m' info() { printf "${BLUE}${BOLD}==>${NC} ${BOLD}%s${NC}\n" "$1"; } success() { printf "${GREEN}${BOLD}==>${NC} ${BOLD}%s${NC}\n" "$1"; } warn() { printf "${YELLOW}${BOLD}warning:${NC} %s\n" "$1"; } error() { printf "${RED}${BOLD}error:${NC} %s\n" "$1" >&2; exit 1; } [ "$(uname)" = "Darwin" ] || error "This installer only supports macOS." command -v curl >/dev/null || error "curl is required." VERSION="$(curl -fsSL "${BASE_URL}/latest-version.txt" | tr -d '[:space:]')" [ -n "$VERSION" ] || error "Could not resolve latest version from ${BASE_URL}/latest-version.txt" info "Latest ${APP_NAME}: ${VERSION}" ARCH="$(uname -m)" case "$ARCH" in arm64) DMG="${SLUG}-${VERSION}-mac-arm64.dmg" ;; x86_64) DMG="${SLUG}-${VERSION}-mac-x64.dmg" ;; *) error "Unsupported architecture: $ARCH" ;; esac DMG_URL="${BASE_URL}/v${VERSION}/${DMG}" SHA_URL="${DMG_URL}.sha256" TMP_DIR="$(mktemp -d)" TMP_DMG="${TMP_DIR}/${DMG}" MOUNT_POINT="" cleanup() { if [ -n "$MOUNT_POINT" ] && [ -d "$MOUNT_POINT" ]; then hdiutil detach "$MOUNT_POINT" -quiet 2>/dev/null || true; fi rm -rf "$TMP_DIR" } trap cleanup EXIT info "Downloading ${DMG}..." curl -fSL --progress-bar "$DMG_URL" -o "$TMP_DMG" || error "Failed to download $DMG_URL" info "Verifying SHA256..." EXPECTED="$(curl -fsSL "$SHA_URL" | awk '{print $1}')" ACTUAL="$(shasum -a 256 "$TMP_DMG" | awk '{print $1}')" if [ -n "$EXPECTED" ] && [ "$EXPECTED" != "$ACTUAL" ]; then error "SHA256 mismatch. expected=$EXPECTED actual=$ACTUAL" fi success "Checksum verified." info "Mounting disk image..." # Note: no -quiet here — it suppresses the mount table, leaving us no mount point to parse. MOUNT_OUTPUT="$(hdiutil attach "$TMP_DMG" -nobrowse 2>&1)" || error "Failed to mount disk image: $MOUNT_OUTPUT" MOUNT_POINT="$(echo "$MOUNT_OUTPUT" | grep -o '/Volumes/.*' | head -1)" if [ -z "$MOUNT_POINT" ] || [ ! -d "$MOUNT_POINT" ]; then # Fallback: locate the volume by name (case-insensitive). MOUNT_POINT="$(find /Volumes -maxdepth 1 -iname "${APP_NAME}*" -type d 2>/dev/null | head -1)" fi [ -d "$MOUNT_POINT" ] || error "Failed to find mounted volume. hdiutil output: $MOUNT_OUTPUT" SOURCE_APP="${MOUNT_POINT}/${APP_NAME}.app" [ -d "$SOURCE_APP" ] || SOURCE_APP="$(find "$MOUNT_POINT" -maxdepth 1 -name '*.app' -type d | head -1)" [ -d "$SOURCE_APP" ] || error "Could not find ${APP_NAME}.app in the disk image." if [ -d "$APP_DIR" ]; then warn "Existing installation found. Replacing..."; rm -rf "$APP_DIR"; fi info "Installing to /Applications..." cp -R "$SOURCE_APP" "$APP_DIR" || error "Failed to copy app to /Applications." info "Removing quarantine attribute..." xattr -cr "$APP_DIR" 2>/dev/null || true success "${APP_NAME} ${VERSION} installed to /Applications."