# Shared helper: run a command inside the roro9stack build container. # With RORO_NO_DOCKER set, the caller is in such a container already (a CI job): the command runs # right here, in the checkout. IMAGE=roro9stack-build ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" [ -n "${RORO_NO_DOCKER:-}" ] || docker build -q -t "$IMAGE" "$ROOT/docker" >/dev/null # The Debug Console token of the developer's device (ADR 0010): made once, kept with the OTA key, never # committed and never compiled in. scripts/flash.sh --debug gives it to a device over USB, and # scripts/rdbg.py answers the device's challenge with it. DEBUG_TOKEN_FILE="$HOME/.config/roro9stack/debug-token" if [ ! -s "$DEBUG_TOKEN_FILE" ]; then mkdir -p "$(dirname "$DEBUG_TOKEN_FILE")" (umask 077 && od -An -tx1 -N16 /dev/urandom | tr -d ' \n' > "$DEBUG_TOKEN_FILE") fi run_in_container() { if [ -n "${RORO_NO_DOCKER:-}" ]; then (cd "$ROOT" && RORO_DEBUG_TOKEN="$(cat "$DEBUG_TOKEN_FILE")" "$@") return fi docker run --rm \ -u "$(id -u):$(id -g)" -e HOME=/tmp \ -e RORO_DEBUG_TOKEN="$(cat "$DEBUG_TOKEN_FILE")" \ -v "$ROOT:/work" \ -v roro9stack-pio:/pio \ "${DOCKER_EXTRA[@]}" \ "$IMAGE" "$@" }