Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omnet/blob/main/integration/headscale/build.sh # omnet aien-dev/omnet Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omnet / integration / headscale / build.sh` 36 lines ยท 1379 bytes Raw Blame History 1 #!/bin/sh 2 set -eu 3 here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) 4 root=$(CDPATH= cd -- "$here/../.." && pwd) 5 . "$here/headscale.pin" 6 go=${GO:-go} 7 go=$(command -v "$go") 8 case "$go" in /*) ;; *) go=$(pwd)/$go ;; esac 9 PATH=$(dirname -- "$go"):$PATH 10 GOTOOLCHAIN=$HEADSCALE_GO_TOOLCHAIN 11 export PATH GOTOOLCHAIN 12 if [ "${HEADSCALE_STOCK:-0}" = 1 ] && [ -z "${HEADSCALE_OUTPUT:-}" ]; then 13 printf '%s\n' 'HEADSCALE_STOCK=1 needs an explicit HEADSCALE_OUTPUT (never the default build/headscale)' >&2 14 exit 2 15 fi 16 out=${HEADSCALE_OUTPUT:-$root/build/headscale} 17 case "$out" in /*) ;; *) out=$(pwd)/$out ;; esac 18 work=$(mktemp -d "${TMPDIR:-/tmp}/omnet-headscale-build.XXXXXX") 19 trap 'rm -rf -- "$work"' EXIT HUP INT TERM 20 git clone --quiet --depth 1 --branch "$HEADSCALE_VERSION" "$HEADSCALE_URL" "$work/source" 21 actual=$(git -C "$work/source" rev-parse HEAD) 22 if [ "$actual" != "$HEADSCALE_COMMIT" ]; then 23 printf '%s\n' 'Headscale tag no longer matches pinned commit' >&2 24 exit 1 25 fi 26 # HEADSCALE_STOCK=1 builds the same pinned commit without the patch. Test-only: 27 # the runbook rehearsal uses it as the "before" server and the rollback target. 28 if [ "${HEADSCALE_STOCK:-0}" != 1 ]; then 29 git -C "$work/source" apply "$here/headscale.patch" 30 fi 31 mkdir -p -- "$(dirname -- "$out")" 32 ( 33 cd -- "$work/source" 34 "$go" build -trimpath -o "$out" ./cmd/headscale 35 ) 36 printf '%s\n' "$out"