From d25cab249602cece07547f4f4e2abc1c3760dd1b Mon Sep 17 00:00:00 2001 From: zeb Date: Sat, 14 Nov 2026 22:38:05 -0800 Subject: [PATCH] fix dash/POSIX + busybox-curl incompatibilities: no ${@:2} in authgit (dash), curl -f instead of -w, INDEX read before truncate, explicit ifs (set -e) --- .gitea/workflows/build.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 889b89a..d24c126 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -49,9 +49,13 @@ jobs: # token via git's env config, not argv (house pattern); # GIT_TERMINAL_PROMPT=0 => a 401 fails fast instead of hanging on a prompt; # `timeout` => a stalled connection fails fast instead of hanging forever - authgit() { timeout "$1" env GIT_TERMINAL_PROMPT=0 GIT_CONFIG_COUNT=1 \ - GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0="Authorization: token ***" \ - git "${@:2}"; } + # POSIX-safe (dash): first arg = timeout seconds, rest = git args + authgit() { + at="$1"; shift + timeout "$at" env GIT_TERMINAL_PROMPT=0 GIT_CONFIG_COUNT=1 \ + GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0="Authorization: token ***" \ + git "$@" + } W="$(mktemp -d /tmp/agentbuilds.XXXXXX)" trap 'st=$(cat /tmp/agentbuilds-status 2>/dev/null); [ -n "$st" ] || echo failed > /tmp/agentbuilds-status; rm -rf "$W"' EXIT rm -f /tmp/agentbuilds-status /tmp/agentbuilds-published @@ -118,9 +122,11 @@ jobs: mkdir -p "dist/$VER" cp "$W/dist"/tacticalagent-* "dist/$VER"/ cp "$W/dist/SHA256SUMS" "dist/$VER/" + # read old index before the redirect below truncates it + if [ -f dist/INDEX ]; then OLDIDX="$(grep -v '^#' dist/INDEX || true)"; else OLDIDX=""; fi { echo "# agent-builds: published versions (the per-version branch is the git ref used in raw URLs)" - [ -f dist/INDEX ] && grep -v '^#' dist/INDEX + if [ -n "$OLDIDX" ]; then printf '%s\n' "$OLDIDX"; fi printf '%s %s\n' "$VER" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" } > dist/INDEX git add -A @@ -133,11 +139,14 @@ jobs: authgit 180 push origin "$VER" # --- verify exactly what agents will do: anonymous raw fetch (per-version branch) --- + # busybox curl has no -w: use -f (exit 22 on HTTP >=400) as the pass/fail signal for f in "$W/dist"/tacticalagent-*; do n="$(basename "$f")" - code="$(curl -s -m 30 -o /dev/null -w '%{http_code}' "$API/$REPO/raw/branch/$VER/dist/$VER/$n")" - if [ "$code" != "200" ]; then - echo "RAW FETCH FAILED: $n -> HTTP $code" + if curl -sf -m 30 -o /dev/null "$API/$REPO/raw/branch/$VER/dist/$VER/$n"; then + echo "raw 200: $n" + else + rc=$? + echo "RAW FETCH FAILED: $n (curl exit $rc: 22=HTTP error, 28=timeout, 6=DNS)" exit 1 fi done