Files
bfe-core1106-sdk/build/fetch-kernel-tarball.sh
T
BFE EngineeringandClaude Opus 5.5 44b96074ed
ci / kernel-symbols (push) Successful in 7m23s
ci / bench (pull_request) Successful in 31s
ci / mcdc (pull_request) Successful in 38s
ci / patches-apply (pull_request) Successful in 59s
ci / kernel-symbols (pull_request) Successful in 5m20s
ci / bench (push) Successful in 34s
ci / patches-apply (push) Successful in 1m6s
ci / qemu-tools (push) Successful in 2m37s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / qemu-tools (pull_request) Successful in 2m46s
ci / test (push) Successful in 40s
ci / mcdc (push) Successful in 33s
ci / test (pull_request) Successful in 43s
ci / quality (push) Successful in 1m56s
ci / badges (push) Skipped
ci / quality (pull_request) Successful in 1m27s
ci / badges (pull_request) Skipped
qemu, build: bound the busybox and kernel fetches
qemu_get_busybox and fetch-kernel-tarball.sh ran curl with no connect
timeout, stall limit or total cap. A server that answered and then went
silent held the flare-edge QEMU UI gate build job until its 30 minute
timeout, with no retry (flare-edge #1588, run 7391 job 63953).

- qemu/lib.sh: each attempt gives up below 1 KiB/s for 20 s, or after
  60 s in all; curl retries once, the 3-attempt loop stays. Limits are
  overridable through BB_FETCH_* for the tests.
- build/fetch-kernel-tarball.sh: 20 s connect timeout, abort below
  10 KiB/s for 30 s, 600 s cap. The download lands in a temp file and is
  renamed on success, so a failed fetch no longer leaves a partial
  tarball that the next run takes as present and rejects on its sha256.
- Tests: busybox-fetch.sh serves a stalling local HTTP endpoint to the
  real curl (hung for the full 60 s guard before, fails in about 9 s
  after); new tests/fetch-kernel-tarball suite (bounded argv, no partial
  file, refetch after a failure, reuse of a matching tarball; 6 of 9
  checks red before). Both wired into CI and shellcheck.

Refs blueflare/flare-edge#1588

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
2026-10-23 00:23:47 -06:00

40 lines
1.7 KiB
Bash

#!/usr/bin/env bash
# Fetch (with retries) and sha256-verify the pristine kernel tarball into $1.
# Single source of truth for the URL + verification used by build-kernel.sh
# and both CI jobs (patches-apply, kernel-build): a KVER bump edits this file
# and build-kernel.sh only. FAILS CLOSED: a missing pin refuses to proceed.
#
# Usage: fetch-kernel-tarball.sh <destination-path>
set -euo pipefail
KVER=6.18.46
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # build/
SHA_FILE="$HERE/linux-$KVER.tar.xz.sha256"
URL="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-$KVER.tar.xz"
TB="${1:?usage: fetch-kernel-tarball.sh <destination-path>}"
# Pin first: a forgotten pin on a KVER bump should refuse BEFORE burning a
# 140MB download it will then reject anyway.
[ -f "$SHA_FILE" ] || {
echo "FATAL: no pinned sha256 for linux-$KVER (expected $SHA_FILE): refusing an unverified tarball" >&2
exit 1
}
if [ ! -f "$TB" ]; then
echo "== downloading $URL"
# Bounded (#1588): a connection that opens and then stalls gives up after
# 30 s below 10 KiB/s and is retried, instead of holding the job until its
# own timeout. The download lands beside $TB and is renamed only when curl
# succeeds, so a failed fetch never leaves a partial tarball that the next
# run would take as present and then reject on its sha256.
tmp="$TB.download.$$"
trap 'rm -f "$tmp"' EXIT
curl --retry 2 --retry-delay 5 --retry-connrefused --connect-timeout 20 \
--speed-limit 10240 --speed-time 30 --max-time 600 -fSL "$URL" -o "$tmp"
mv -f "$tmp" "$TB"
fi
want="$(cat "$SHA_FILE")"
got="$(sha256sum "$TB" | awk '{print $1}')"
[ "$want" = "$got" ] || { echo "FATAL: tarball sha256 mismatch: want $want got $got" >&2; exit 1; }
echo "== tarball sha256 verified: $TB"