Download this file
| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | runner=$(realpath "$1") |
| 4 | shift |
| 5 | cd "$(dirname "$0")/.." |
| 6 | worktree=$(pwd) |
| 7 | scratch=$(mktemp -d) |
| 8 | artifacts=() |
| 9 | trap 'rm -f -- "${artifacts[@]}"; rm -rf -- "$scratch"' EXIT |
| 10 | export GOFLAGS=-buildvcs=false |
| 11 | unset GOCACHE |
| 12 | listener="$scratch/listener.go" |
| 13 | cat > "$listener" <<'GO' |
| 14 | //go:build activationloopback |
| 15 | |
| 16 | package main |
| 17 | |
| 18 | import "os" |
| 19 | |
| 20 | func 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 | } |
| 25 | GO |
| 26 | python3 - "$worktree" "$listener" "$scratch/overlay.json" <<'PYJSON' |
| 27 | import json,sys |
| 28 | with open(sys.argv[3], 'w') as f: |
| 29 | json.dump({"Replace": {sys.argv[1]+"/activation_rootrunner_listener.go":sys.argv[2]}}, f) |
| 30 | PYJSON |
| 31 | for 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' |
| 38 | import shutil,sys |
| 39 | with open(sys.argv[1], 'rb') as src, open(sys.argv[2], 'xb') as dst: |
| 40 | shutil.copyfileobj(src,dst) |
| 41 | PY |
| 42 | artifacts+=("$artifact") |
| 43 | sha256sum "$artifact" |
| 44 | done |
| 45 | nice -n 10 python3 -u "$runner" --worktree "$worktree" --pkg ./internal/host --tags rootrunner,activationconsole "$@" |
| 46 | |