interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / ipl / build.sh

20 lines · 1361 bytes Raw Blame History
1#!/bin/sh
2# build.sh OMC SHA2_OM CHAIN_OM [SNAPSHOT_OM]: build bin/landrec and bin/chain, and bin/snapshot when
3# its source is given (the import instrument needs it), with the pinned compiler and sources.
4# Refuses any compiler or source file whose sha256 is not PIN's. Writes bin/BUILD.sha256, the digests
5# of what it built, which tools/import-radicle.sh checks before it runs anything. Invocation glue only.
6set -u
7cd "$(dirname "$0")" || exit 2
8ck() { [ "$(sha256sum "$1" | cut -d' ' -f1)" = "$(sed -n "s/^$2 //p" PIN)" ] || { echo "build: $1 is not PIN's $2" >&2; exit 2; }; }
9ck "${1:?OMC}" omc-sha256; ck "${2:?SHA2_OM}" sha2-om-sha256; ck "${3:?CHAIN_OM}" chain-om-sha256
10mkdir -p bin && "$1" < om/landrec.om > bin/landrec.new && { printf 'om2\n'; cat "$2" "$3"; } | "$1" > bin/chain.new || { echo "build: compile failed" >&2; exit 2; }
11chmod +x bin/landrec.new bin/chain.new && mv bin/landrec.new bin/landrec && mv bin/chain.new bin/chain || exit 2
12set -- "$1" "$2" "$3" "${4:-}"
13if [ -n "$4" ]; then
14 ck "$4" snapshot-om-sha256
15 "$1" < "$4" > bin/snapshot.new && chmod +x bin/snapshot.new && mv bin/snapshot.new bin/snapshot || { echo "build: snapshot did not compile" >&2; exit 2; }
16 ( cd bin && sha256sum landrec chain snapshot > BUILD.sha256 )
17else
18 rm -f bin/snapshot; ( cd bin && sha256sum landrec chain > BUILD.sha256 )
19fi
20cat bin/BUILD.sha256