#!/usr/bin/env bash set -euo pipefail runner=$(realpath "$1") shift cd "$(dirname "$0")/.." worktree=$(pwd) scratch=$(mktemp -d) artifacts=() trap 'rm -f -- "${artifacts[@]}"; rm -rf -- "$scratch"' EXIT export GOFLAGS=-buildvcs=false unset GOCACHE listener="$scratch/listener.go" cat > "$listener" <<'GO' //go:build activationloopback package main import "os" func init() { if len(os.Args) == 2 && os.Args[1] == "agent" { os.Args = append(os.Args, "--http", "127.0.0.1:18080", "--https", "127.0.0.1:18443") } } GO python3 - "$worktree" "$listener" "$scratch/overlay.json" <<'PYJSON' import json,sys with open(sys.argv[3], 'w') as f: json.dump({"Replace": {sys.argv[1]+"/activation_rootrunner_listener.go":sys.argv[2]}}, f) PYJSON for component in console carlos; do artifact=internal/host/activation-$component-runner.bin test ! -e "$artifact" package=. if [ "$component" = console ]; then package=./cmd/console; fi 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" python3 - "$scratch/$component" "$artifact" <<'PY' import shutil,sys with open(sys.argv[1], 'rb') as src, open(sys.argv[2], 'xb') as dst: shutil.copyfileobj(src,dst) PY artifacts+=("$artifact") sha256sum "$artifact" done nice -n 10 python3 -u "$runner" --worktree "$worktree" --pkg ./internal/host --tags rootrunner,activationconsole "$@"