#!/bin/sh # Lattice installer: verify the signed archive, stage it, then replace atomically. # Read this script before running it. Unsigned beta: this is not Apple notarization. set -eu url='https://vgmrjdvpdbzckmzplkss.supabase.co/storage/v1/object/public/releases/2.6.85/Lattice-2.6.85.app.tar.gz' version='2.6.85' id='com.lmcorporations.lattice.public' fail() { printf '\nLattice: %s\n' "$*" >&2; exit 1; } [ "$(uname -s)" = Darwin ] || fail "Lattice runs on macOS." [ "$(uname -m)" = arm64 ] || fail "Lattice needs Apple Silicon." major=$(sw_vers -productVersion | cut -d. -f1) [ "$major" -ge 14 ] || fail "Lattice needs macOS 14 or later." command -v minisign >/dev/null 2>&1 || fail "Install minisign from its official distribution first, or use the download instructions at https://uselattice.site/install." dest="${LATTICE_DEST:-/Applications}" [ -w "$dest" ] || { dest="$HOME/Applications"; mkdir -p "$dest"; } app="$dest/Lattice.app" check_stopped() { if [ -e "$app" ]; then have=$(defaults read "$app/Contents/Info" CFBundleIdentifier 2>/dev/null || true) [ "$have" = "$id" ] || fail "$app is a different app. Move it somewhere else, then run this again." state=$(osascript -e "application id "$id" is running" 2>/dev/null) || fail "Couldn't check whether Lattice is running." [ "$state" != true ] || fail "Lattice is open. Quit it when ready, then try again." fi } check_stopped tmp=$(mktemp -d) stage=$(mktemp -d "$dest/.lattice-stage.XXXXXX") previous="$stage/previous.app" cleanup() { if [ -e "$previous" ] && [ ! -e "$app" ]; then mv "$previous" "$app" || true; fi rm -rf "$tmp" if [ ! -e "$previous" ]; then rm -rf "$stage"; fi } trap cleanup EXIT trap 'exit 1' HUP INT TERM curl --proto '=https' --proto-redir '=https' -fL --progress-bar "$url" -o "$tmp/Lattice.tar.gz" || fail "Download failed. Your previous installation was kept." printf '%s\n' 'untrusted comment: signature from tauri secret key RUT/UYtXSXzud8GplGKtc1oQB5HHNxAbI7mSlbCdI/2BPZMEKGFfjfzKML0mgsVK3fdBgN08C/l5SwvFBF3jDwOH4PkHr/2pWQ0= trusted comment: timestamp:1793004005 file:Lattice.app.tar.gz 9c8n7KPrO0d0noTLMojj3/DlBKMtpNwB/rYwXNucjt4OpFREoPuSYuUm9PpSPadAeyvNz61x1G8tXTpNURUiDg== ' > "$tmp/Lattice.minisig" minisign -Vm "$tmp/Lattice.tar.gz" -x "$tmp/Lattice.minisig" -P 'RWT/UYtXSXzudyemllruQDDMuv8NkdCzHkCa39eQbHes+UEK9JL1KORc' || fail "The archive wasn't signed by Lattice. Nothing was installed." tar -tzf "$tmp/Lattice.tar.gz" | awk '/^\// || /(^|\/)\.\.(\/|$)/ { bad=1 } END { exit bad }' || fail "Unsafe archive paths." tar -xzf "$tmp/Lattice.tar.gz" -C "$tmp" verify() { [ "$(defaults read "$1/Contents/Info" CFBundleIdentifier 2>/dev/null || true)" = "$id" ] || fail "Wrong application identifier." [ "$(defaults read "$1/Contents/Info" CFBundleShortVersionString 2>/dev/null || true)" = "$version" ] || fail "Wrong application version." codesign --verify --deep --strict "$1" 2>/dev/null || fail "Bundle integrity check failed." } verify "$tmp/Lattice.app" ditto "$tmp/Lattice.app" "$stage/Lattice.app" || fail "Copy failed. Your previous installation was kept." verify "$stage/Lattice.app" check_stopped if [ -e "$app" ]; then mv "$app" "$previous" || fail "Couldn't keep the previous app."; fi if ! mv "$stage/Lattice.app" "$app"; then fail "Couldn't install the staged app. The previous app will be restored."; fi # Only the verified replacement is live now; an old copy is no longer needed. rm -rf "$previous" printf 'Lattice %s is installed. Paste the key from your email.\n' "$version" [ -n "${LATTICE_NO_OPEN:-}" ] || open "$app"