carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env bash
2set -euo pipefail
3test "$#" -ge 1
4runner=$(realpath "$1")
5shift
6cd "$(dirname "$0")/.."
7worktree=$(pwd)
8artifact=internal/host/plan14-console-runner.bin
9woodstar_artifact=internal/host/plan14-woodstar-runner.bin
10test ! -e "$artifact"
11test ! -e "$woodstar_artifact"
12scratch=$(mktemp -d)
13owned_artifacts=()
14trap 'rm -f -- "${owned_artifacts[@]}"; rm -rf -- "$scratch"' EXIT
15stage_artifact() {
16 python3 - "$1" "$2" <<'PYTHON'
17import os, shutil, sys
18with open(sys.argv[1], "rb") as source, open(sys.argv[2], "xb") as target:
19 try:
20 shutil.copyfileobj(source, target)
21 except BaseException:
22 os.unlink(sys.argv[2])
23 raise
24PYTHON
25 owned_artifacts+=("$2")
26}
27export GOFLAGS=-buildvcs=false
28unset GOCACHE
29GOOS=linux GOARCH=arm64 CGO_ENABLED=0 nice -n 10 go build -o "$scratch/console" ./cmd/console
30stage_artifact "$scratch/console" "$artifact"
31tags=rootrunner,realconsole
32sha256sum "$artifact"
33if [ -n "${PLAN14_WOODSTAR_SOURCE:-}" ]; then
34 mkdir "$scratch/woodstar"
35 git -C "$PLAN14_WOODSTAR_SOURCE" rev-parse HEAD
36 git -C "$PLAN14_WOODSTAR_SOURCE" archive HEAD go.mod go.sum cmd internal | tar -x -C "$scratch/woodstar"
37 (cd "$scratch/woodstar" && GOOS=linux GOARCH=arm64 CGO_ENABLED=0 nice -n 10 go build -mod=readonly -o "$scratch/unfurl" ./cmd/unfurl)
38 stage_artifact "$scratch/unfurl" "$woodstar_artifact"
39 sha256sum "$woodstar_artifact"
40 tags=$tags,realwoodstar
41fi
42nice -n 10 python3 -u "$runner" --worktree "$worktree" --pkg ./internal/host --tags "$tags" "$@"
43