#!/bin/sh # Ridgun installer (www-ridgun FR-DL-003), written by https://ridgun.com/install.sh for Ridgun 1.0.9. # # curl -fsSL https://ridgun.com/install.sh | sh # # Downloads, into a temporary folder, what omni needs: the release for this system, the newest libs and the index. # It checks the release against its SHA256SUMS before running anything from it, then hands over to `omni setup`, # which checks every signature with the release key built into omni (ADR-0004) and installs ridgunc, stable and omni # in ~/.local/bin and the standard libraries in ~/.local/lib/ridgun (it keeps its own copy in ~/.omni). Nothing is # installed if a check fails. Nothing else on the system is touched. set -eu version='1.0.9' base='https://ridgun.com' files='x86_64-linux ridgun-1.0.9-x86_64-linux.tar.gz arm64-linux ridgun-1.0.9-arm64-linux.tar.gz x86_64-macos ridgun-1.0.9-x86_64-macos.tar.gz arm64-macos ridgun-1.0.9-arm64-macos.tar.gz x86_64-windows ridgun-1.0.9-x86_64-windows.tar.gz arm64-windows ridgun-1.0.9-arm64-windows.tar.gz' say() { printf 'ridgun: %s\n' "$*"; } fail() { printf 'ridgun: %s\n' "$*" >&2; exit 1; } [ -n "$version" ] || fail "no Ridgun release is published yet: see $base/download" case "$(uname -s)" in Linux) os=linux ;; Darwin) os=macos ;; MINGW* | MSYS* | CYGWIN*) os=windows ;; *) os=$(uname -s | tr 'A-Z' 'a-z') ;; esac case "$(uname -m)" in x86_64 | amd64) arch=x86_64 ;; aarch64 | arm64) arch=arm64 ;; *) arch=$(uname -m) ;; esac target="$arch-$os" # Git Bash, MSYS2 and Cygwin on Windows: the programs end in .exe (PowerShell has install.ps1). exe="" [ "$os" = windows ] && exe=".exe" file=$(printf '%s\n' "$files" | awk -v t="$target" '$1 == t { print $2; exit }') [ -n "$file" ] || fail "Ridgun $version has no download for $target yet: see $base/download" if command -v curl >/dev/null 2>&1; then get() { curl -fsSL -o "$2" "$1"; } elif command -v wget >/dev/null 2>&1; then get() { wget -q -O "$2" "$1"; } else fail "needs curl or wget" fi # macOS has shasum, not always sha256sum. if command -v sha256sum >/dev/null 2>&1; then sums_ok() { sha256sum -c --status; } elif command -v shasum >/dev/null 2>&1; then sums_ok() { shasum -a 256 -c --status; } else fail "needs sha256sum or shasum" fi # The temporary folder is laid out like $base/downloads, so omni reads it as its mirror. tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT cd "$tmp" # A release folder: one file with its SHA256SUMS and their signature. get_release() { mkdir -p "$1" get "$base/downloads/$1/$2" "$1/$2" || fail "could not download $2" get "$base/downloads/$1/SHA256SUMS" "$1/SHA256SUMS" || fail "could not download the SHA256SUMS of $2" get "$base/downloads/$1/SHA256SUMS.minisig" "$1/SHA256SUMS.minisig" || fail "could not download the signature of $2" } say "downloading Ridgun $version for $target" get "$base/downloads/index.tsv" index.tsv || fail "could not download the index of releases" get_release "$version" "$file" (cd "$version" && grep " $file\$" SHA256SUMS | sums_ok) || fail "the checksum of $file does not match: nothing installed" # The newest libs in the index (columns: product, version, target, path). libs=$(awk -F '\t' '$1 == "libs" { split($2, v, "."); k = v[1] * 1000000 + v[2] * 1000 + v[3]; if (k >= best) { best = k; p = $4 } } END { print p }' index.tsv) [ -n "$libs" ] || fail "the index has no standard libraries (libs)" say "downloading the standard libraries ($(basename "$libs" .tar.gz))" get_release "$(dirname "$libs")" "$(basename "$libs")" tar -xzf "$version/$file" [ -x "ridgun-$version/bin/omni$exe" ] || fail "this release has no omni: see $base/download" # omni.exe is a Windows program: it reads the folder as a Windows path. mirror="$tmp" [ "$os" = windows ] && command -v cygpath >/dev/null 2>&1 && mirror=$(cygpath -w "$tmp") OMNI_DOWNLOADS_MIRROR="$mirror" "./ridgun-$version/bin/omni$exe" setup "$target" || fail "omni setup failed: nothing more was installed" dest="$HOME/.local/bin" case ":$PATH:" in *":$dest:"*) "$dest/ridgunc$exe" --version ;; *) case "${SHELL:-}" in *zsh) profile="~/.zprofile" ;; *) [ "$os" = windows ] && profile="~/.bashrc" || profile="~/.profile" ;; esac say "add $dest to your PATH: echo 'export PATH=\"$dest:\$PATH\"' >> $profile" ;; esac say "add a library to a project with: omni install ; install a package's programs with: omni install -g (see $base/packages)"