interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / ipl / build.sh
| 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. |
| 6 | set -u |
| 7 | cd "$(dirname "$0")" || exit 2 |
| 8 | ck() { [ "$(sha256sum "$1" | cut -d' ' -f1)" = "$(sed -n "s/^$2 //p" PIN)" ] || { echo "build: $1 is not PIN's $2" >&2; exit 2; }; } |
| 9 | ck "${1:?OMC}" omc-sha256; ck "${2:?SHA2_OM}" sha2-om-sha256; ck "${3:?CHAIN_OM}" chain-om-sha256 |
| 10 | mkdir -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; } |
| 11 | chmod +x bin/landrec.new bin/chain.new && mv bin/landrec.new bin/landrec && mv bin/chain.new bin/chain || exit 2 |
| 12 | set -- "$1" "$2" "$3" "${4:-}" |
| 13 | if [ -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 ) |
| 17 | else |
| 18 | rm -f bin/snapshot; ( cd bin && sha256sum landrec chain > BUILD.sha256 ) |
| 19 | fi |
| 20 | cat bin/BUILD.sha256 |