interplane.Get Omega
Read in your language

interplane.io

Source of interplane.io: a Rust generator that renders the page from the protocol repository's public record, deployed hourly from the Spark.

Brought by drakestapleton

branch main Branches Tags History

interplane.io / public / omega-downloads / install-omega-3086ed3ca106.sh

38 lines · 1534 bytes Raw Blame History
1#!/bin/sh
2# Install the matching Omega compiler archive into the current user's home.
3set -eu
4
5die() {
6 printf 'Omega installer: %s\n' "$*" >&2
7 exit 1
8}
9
10[ "$#" -eq 1 ] || die "usage: sh $0 ARCHIVE"
11[ "$(uname -s)" = Linux ] && [ "$(uname -m)" = aarch64 ] ||
12 die 'this compiler requires 64-bit Arm Linux'
13: "${HOME:?set HOME to your home directory}"
14
15bindir=$HOME/.local/bin
16mkdir -p -- "$bindir" || die "could not create $bindir"
17stage=$(mktemp -d "$bindir/.omega-install.XXXXXXXX") || die "could not stage in $bindir"
18trap 'rm -rf -- "$stage"' 0
19trap 'exit 1' 1 2 15
20
21cat -- "$1" > "$stage/archive" || die 'could not read the archive'
22expected=47990e5333737e157faae09d47f9faf3fc87bed58bef7fe8a8fec729a78f3c0a
23actual=$(sha256sum < "$stage/archive")
24[ "${actual%% *}" = "$expected" ] || die 'archive SHA-256 mismatch'
25tar --force-local -xOzf "$stage/archive" omc > "$stage/omc" || die 'could not extract omc'
26expected_compiler=34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3
27actual_compiler=$(sha256sum < "$stage/omc")
28[ "${actual_compiler%% *}" = "$expected_compiler" ] || die 'compiler SHA-256 mismatch'
29chmod 755 "$stage/omc"
30
31# The hard link creates the destination atomically and refuses existing files.
32if ! ln -T -- "$stage/omc" "$bindir/omc"; then
33 if [ -e "$bindir/omc" ] || [ -L "$bindir/omc" ]; then
34 die "could not install at $bindir/omc (an existing file will not be replaced)"
35 fi
36 die "could not create $bindir/omc"
37fi
38printf 'Installed Omega compiler at %s\n' "$bindir/omc"