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
interplane.io / public / omega-downloads / install-omega-3086ed3ca106.sh
| 1 | #!/bin/sh |
| 2 | # Install the matching Omega compiler archive into the current user's home. |
| 3 | set -eu |
| 4 | |
| 5 | die() { |
| 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 | |
| 15 | bindir=$HOME/.local/bin |
| 16 | mkdir -p -- "$bindir" || die "could not create $bindir" |
| 17 | stage=$(mktemp -d "$bindir/.omega-install.XXXXXXXX") || die "could not stage in $bindir" |
| 18 | trap 'rm -rf -- "$stage"' 0 |
| 19 | trap 'exit 1' 1 2 15 |
| 20 | |
| 21 | cat -- "$1" > "$stage/archive" || die 'could not read the archive' |
| 22 | expected=47990e5333737e157faae09d47f9faf3fc87bed58bef7fe8a8fec729a78f3c0a |
| 23 | actual=$(sha256sum < "$stage/archive") |
| 24 | [ "${actual%% *}" = "$expected" ] || die 'archive SHA-256 mismatch' |
| 25 | tar --force-local -xOzf "$stage/archive" omc > "$stage/omc" || die 'could not extract omc' |
| 26 | expected_compiler=34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3 |
| 27 | actual_compiler=$(sha256sum < "$stage/omc") |
| 28 | [ "${actual_compiler%% *}" = "$expected_compiler" ] || die 'compiler SHA-256 mismatch' |
| 29 | chmod 755 "$stage/omc" |
| 30 | |
| 31 | # The hard link creates the destination atomically and refuses existing files. |
| 32 | if ! 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" |
| 37 | fi |
| 38 | printf 'Installed Omega compiler at %s\n' "$bindir/omc" |