#!/bin/sh set -eu fail() { printf 'Achilles: %s\n' "$1" >&2 exit 1 } need() { for tool in "$@"; do command -v "$tool" >/dev/null || fail "$tool is needed to install" done } choose() { artifact "$1" || fail "there is no build for $1" } fetch() { file=$1 shift curl --fail --silent --show-error --location --proto '=https' --tlsv1.2 --output "$file" "$download" printf '%s %s\n' "$digest" "$file" | "$@" --check --status || fail "the download is damaged, run the installer again" } replace() { if [ -e "$2" ]; then mv "$2" "$work/previous" fi if ! mv "$1" "$2"; then [ ! -e "$work/previous" ] || mv "$work/previous" "$2" fail "could not install into $2" fi } cleanup() { if [ -n "$volume" ]; then hdiutil detach -quiet "$volume" || hdiutil detach -quiet -force "$volume" || true fi [ -z "$scratch" ] || rm -rf "$scratch" [ -z "$work" ] || rm -rf "$work" } exec_argument() { printf '%s' "$1" | sed -e 's/[\\"`$]/\\&/g' -e 's/%/%%/g' -e 's/\\/\\\\/g' } desktop_string() { printf '%s' "$1" | sed -e 's/\\/\\\\/g' } terminal_hint() { case ":${PATH:-}:" in *":$1:"*) return ;; esac case "${SHELL:-}" in */fish) printf 'To run achilles from a terminal, run: fish_add_path %s\n' "$1" ;; *) printf 'Add %s to PATH to run achilles from a terminal\n' "$1" ;; esac } macos() { if [ "$(sysctl -n hw.optional.arm64 2>/dev/null || true)" = 1 ]; then target=macos-aarch64 else target=macos-universal fi choose "$target" need curl shasum hdiutil ditto mktemp applications=/Applications if [ ! -w "$applications" ]; then applications=${HOME:?}/Applications mkdir -p "$applications" fi scratch=$(mktemp -d) work=$(mktemp -d "$applications/.Achilles.XXXXXX") image=$scratch/Achilles.dmg fetch "$image" shasum -a 256 volume=$scratch/volume hdiutil attach -quiet -nobrowse -noautoopen -readonly -mountpoint "$volume" "$image" [ -d "$volume/Achilles.app" ] || fail "the disk image holds no Achilles.app" ditto "$volume/Achilles.app" "$work/Achilles.app" hdiutil detach -quiet "$volume" volume= replace "$work/Achilles.app" "$applications/Achilles.app" printf 'Achilles %s is installed in %s: open it from Launchpad or Spotlight\n' "$build" "$applications" } linux() { case "$(uname -m)" in x86_64) target=linux-x86_64 ;; aarch64) target=linux-aarch64 ;; *) target=linux-$(uname -m) ;; esac choose "$target" need curl tar sha256sum mktemp home=${HOME:?} opt=$home/.local/opt folder=$opt/Achilles bin=$home/.local/bin applications=${XDG_DATA_HOME:-$home/.local/share}/applications executable=$folder/Achilles mkdir -p "$opt" "$bin" "$applications" work=$(mktemp -d "$opt/.Achilles.XXXXXX") archive=$work/Achilles.tar.gz fetch "$archive" sha256sum tar -xzf "$archive" -C "$work" if command -v ldd >/dev/null; then missing=$(ldd "$work/Achilles/Achilles" 2>&1 | grep 'not found' || true) [ -z "$missing" ] || fail "this system lacks libraries Achilles needs, install them from your distribution's packages: $missing" fi replace "$work/Achilles" "$folder" ln -sf "$executable" "$bin/achilles" cat >"$work/Achilles.desktop" </dev/null || printf 'Videos need ffmpeg from your distribution'"'"'s packages\n' } main() { scratch='' work='' volume='' trap cleanup EXIT trap 'exit 130' INT HUP TERM case "$(uname -s)" in Darwin) macos ;; Linux) linux ;; MINGW* | MSYS* | CYGWIN*) fail "on Windows, run this in PowerShell instead: irm $install | iex" ;; *) fail "there is no build for $(uname -s)" ;; esac } artifact() { case $1 in 'macos-aarch64') download='https://releases.achilles-space.com/builds/2026.12/Achilles-2026.12.005-macos-aarch64.dmg' digest='8606eb8c7bb07af1560c0ab365e44900fb063668326401a76029648dfc4c1c51' ;; 'macos-universal') download='https://releases.achilles-space.com/builds/2026.12/Achilles-2026.12.005-macos-universal.dmg' digest='7496a83830d2bec3caccb6dc0a425f02bf8583157ecd60beb5f2c9d790f0286f' ;; 'linux-x86_64') download='https://releases.achilles-space.com/builds/2026.12/Achilles-2026.12.005-linux-x86_64.tar.gz' digest='65073047bfcd285c360da12afa7b0f179fc4b179bfcfeecf08c41fd6671d5ba1' ;; 'linux-aarch64') download='https://releases.achilles-space.com/builds/2026.12/Achilles-2026.12.005-linux-aarch64.tar.gz' digest='c6e609049360b2c0197436914660a239f94e2cf6c2a190783599b4249de09987' ;; *) return 1 ;; esac } build='2026.12.005' install='https://install.achilles-space.com' main