omnet
aien-dev/omnet
Brought by drakestapleton
omnet / integration / e2e / build-clients.sh
| 1 | #!/bin/sh |
| 2 | # Test-only dependency acquisition. Run from any directory: |
| 3 | # GO=/path/to/go GOTOOLCHAIN=auto sh integration/e2e/build-clients.sh |
| 4 | # Builds unmodified tailscale.com v1.102.0 from the checksum-verified Go module. |
| 5 | # The module proxy/checksum database and Go toolchain download require network; |
| 6 | # the lifecycle runner creates an isolated network namespace without egress. |
| 7 | set -eu |
| 8 | ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) |
| 9 | GO=${GO:-go} |
| 10 | OUT=${E2E_BIN_DIR:-"$ROOT/build/e2e"} |
| 11 | mkdir -p "$OUT" |
| 12 | OUT=$(CDPATH= cd -- "$OUT" && pwd) |
| 13 | export GOTOOLCHAIN=${GOTOOLCHAIN:-auto} |
| 14 | export GO111MODULE=on |
| 15 | "$GO" mod download -json tailscale.com@v1.102.0 > "$OUT/tailscale-module.json" |
| 16 | SRC=$(python3 - "$OUT/tailscale-module.json" <<'PY' |
| 17 | import json, sys |
| 18 | m = json.load(open(sys.argv[1])) |
| 19 | if m.get('Error') or m.get('Version') != 'v1.102.0' or not m.get('Sum'): |
| 20 | raise SystemExit('pinned Tailscale module acquisition failed') |
| 21 | origin = m.get('Origin', {}) |
| 22 | if origin and origin.get('Hash') != '35283c95445fb198af1ce708dac05714bdfaa037': |
| 23 | raise SystemExit('unexpected Tailscale v1.102.0 source revision') |
| 24 | print(m['Dir']) |
| 25 | PY |
| 26 | ) |
| 27 | (cd "$SRC" && "$GO" build -trimpath -buildvcs=false -o "$OUT/tailscale" ./cmd/tailscale) |
| 28 | (cd "$SRC" && "$GO" build -trimpath -buildvcs=false -o "$OUT/tailscaled" ./cmd/tailscaled) |
| 29 | "$GO" version -m "$OUT/tailscale" > "$OUT/tailscale.buildinfo" |
| 30 | "$GO" version -m "$OUT/tailscaled" > "$OUT/tailscaled.buildinfo" |
| 31 | python3 - "$OUT" <<'PY' |
| 32 | import hashlib, json, pathlib, sys |
| 33 | out = pathlib.Path(sys.argv[1]) |
| 34 | module = json.loads((out / 'tailscale-module.json').read_text()) |
| 35 | manifest = { |
| 36 | 'version': 'v1.102.0', |
| 37 | 'source_revision': '35283c95445fb198af1ce708dac05714bdfaa037', |
| 38 | 'module_sum': module['Sum'], |
| 39 | 'sha256': {name: hashlib.sha256((out / name).read_bytes()).hexdigest() |
| 40 | for name in ('tailscale', 'tailscaled')}, |
| 41 | } |
| 42 | (out / 'stock-client.json').write_text(json.dumps(manifest, indent=2) + '\n') |
| 43 | PY |
| 44 | printf 'Built stock v1.102.0 clients in %s\n' "$OUT" |