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
3runner=$(realpath "$1")
4shift
5cd "$(dirname "$0")/.."
6worktree=$(pwd)
7scratch=$(mktemp -d)
8artifacts=()
9trap 'rm -f -- "${artifacts[@]}"; rm -rf -- "$scratch"' EXIT
10export GOFLAGS=-buildvcs=false
11unset GOCACHE
12listener="$scratch/listener.go"
13cat > "$listener" <<'GO'
14//go:build activationloopback
15
16package main
17
18import "os"
19
20func init() {
21 if len(os.Args) == 2 && os.Args[1] == "agent" {
22 os.Args = append(os.Args, "--http", "127.0.0.1:18080", "--https", "127.0.0.1:18443")
23 }
24}
25GO
26python3 - "$worktree" "$listener" "$scratch/overlay.json" <<'PYJSON'
27import json,sys
28with open(sys.argv[3], 'w') as f:
29 json.dump({"Replace": {sys.argv[1]+"/activation_rootrunner_listener.go":sys.argv[2]}}, f)
30PYJSON
31for component in console carlos; do
32 artifact=internal/host/activation-$component-runner.bin
33 test ! -e "$artifact"
34 package=.
35 if [ "$component" = console ]; then package=./cmd/console; fi
36 GOOS=linux GOARCH=arm64 CGO_ENABLED=0 nice -n 10 go build -overlay "$scratch/overlay.json" -tags activationloopback -ldflags '-X github.com/carlosframework/platform/internal/version.Build=v1.0.0' -o "$scratch/$component" "$package"
37 python3 - "$scratch/$component" "$artifact" <<'PY'
38import shutil,sys
39with open(sys.argv[1], 'rb') as src, open(sys.argv[2], 'xb') as dst:
40 shutil.copyfileobj(src,dst)
41PY
42 artifacts+=("$artifact")
43 sha256sum "$artifact"
44done
45nice -n 10 python3 -u "$runner" --worktree "$worktree" --pkg ./internal/host --tags rootrunner,activationconsole "$@"
46