#!/bin/sh # DreamCoder installer for macOS (Apple silicon) and Debian/Ubuntu (x86_64). # # curl -fsSL https://www.dreamcoder.ai/install.sh | sh # # Everything runs inside main(), called on the last line, so a download that # stops part-way cannot run half of this script. say() { printf '%s\n' "$*" } fail() { printf 'DreamCoder: %s\n' "$*" >&2 exit 1 } make_work_dir() { dreamcoder_work=$(mktemp -d "${TMPDIR:-/tmp}/dreamcoder.XXXXXX") trap 'rm -rf "$dreamcoder_work"' EXIT trap 'exit 1' HUP INT TERM } install_macos() { [ "$(uname -m)" = arm64 ] || fail "DreamCoder for macOS needs a Mac with Apple silicon (M1 or later)." dreamcoder_app=/Applications/DreamCoder.app make_work_dir say "Downloading DreamCoder..." curl -fL --progress-bar -o "$dreamcoder_work/DreamCoder.zip" https://www.dreamcoder.ai/downloads/files/private/1.0.11/macos/dreamcoder-1.0.11-macos-arm64.zip say "Unpacking..." ditto -xk "$dreamcoder_work/DreamCoder.zip" "$dreamcoder_work/unpacked" [ -d "$dreamcoder_work/unpacked/DreamCoder.app" ] || fail "The download did not contain DreamCoder.app." if [ -e "$dreamcoder_app" ]; then say "Closing and replacing the DreamCoder already in Applications..." osascript -e 'if application "DreamCoder" is running then tell application "DreamCoder" to quit' >/dev/null 2>&1 || true rm -rf "$dreamcoder_app" fi say "Installing into /Applications..." ditto "$dreamcoder_work/unpacked/DreamCoder.app" "$dreamcoder_app" # macOS may refuse to open an app that carries the download quarantine # mark. This clears the mark from DreamCoder only; a copy that never had # the mark is fine as it is. say "Removing the download quarantine mark..." xattr -dr com.apple.quarantine "$dreamcoder_app" 2>/dev/null || true say "Opening DreamCoder..." open "$dreamcoder_app" } install_linux() { fail "No DreamCoder release for Linux is available right now." } main() { set -eu case "$(uname -s)" in Darwin) install_macos ;; Linux) install_linux ;; *) fail "This installer supports macOS and Debian/Ubuntu only. See "https://www.dreamcoder.ai/downloads ;; esac } main "$@"