interplane.Get Omega
Read in your language

sovereign-intelligence

Front door to Drake Stapleton's sovereign stack.

Brought by drakestapleton

branch main Branches Tags History

sovereign-intelligence / portable-pack / install

38 lines · 1650 bytes Raw Blame History
1#!/bin/sh
2set -eu
3umask 077
4root=$(CDPATH='' cd -P "$(dirname "$0")" && pwd)
5[ "$(uname -s)/$(uname -m)" = Linux/aarch64 ] || { echo 'This preview requires ARM64 Linux.' >&2; exit 2; }
6(cd "$root" && sha256sum --quiet -c PACK.sha256)
7"$root/round40/model" --help >/dev/null
8parent=$HOME/.local/share/sovereign-intelligence
9bin=$HOME/.local/bin
10mkdir -p "$parent" "$bin"
11exec 9>"$parent/install.lock"
12flock -x 9
13id=$(sha256sum "$root/PACK.sha256" | cut -d' ' -f1)
14dest=$parent/$id
15if [ -e "$bin/si-pack" ] || [ -L "$bin/si-pack" ]; then
16 [ "$(readlink "$bin/si-pack")" = "$parent/current/si-pack" ] || { echo 'An existing si-pack command belongs to another installation.' >&2; exit 1; }
17fi
18if [ -e "$parent/current" ] && [ ! -L "$parent/current" ]; then
19 echo 'The current path is already in use.' >&2; exit 1
20fi
21stage=$(mktemp -d "$parent/.staging.XXXXXXXX")
22trap 'rm -rf -- "$stage"' EXIT
23if [ -d "$dest" ]; then
24 cmp "$root/PACK.sha256" "$dest/PACK.sha256"
25 (cd "$dest" && sha256sum --quiet -c PACK.sha256)
26else
27 cp -a -- "$root/." "$stage/payload"
28 (cd "$stage/payload" && sha256sum --quiet -c PACK.sha256)
29fi
30git clone --quiet "$root/foundation.bundle" "$stage/foundation"
31git -C "$stage/foundation" checkout --quiet --detach 8be4c26c3b89bfbe72157344c0e3c76884f55e9e
32sh "$stage/foundation/install.sh"
33if [ ! -d "$dest" ]; then mv -T "$stage/payload" "$dest"; fi
34ln -s "$id" "$stage/current"
35mv -Tf "$stage/current" "$parent/current"
36if [ ! -L "$bin/si-pack" ]; then ln -s "$parent/current/si-pack" "$bin/si-pack"; fi
37"$bin/si-pack" verify
38printf 'Installed %s\nRun %s/demo using: %s demo\n' "$id" "$dest/round40" "$bin/si-pack"