Retry pinned BusyBox fetches (#554)
This commit is contained in:
+26
-7
@@ -22,15 +22,34 @@ qemu_get_busybox() {
|
||||
echo "FATAL: no pinned sha256 for busybox (expected $sha_file): refusing to build from an unverified binary" >&2
|
||||
exit 1
|
||||
}
|
||||
if [ ! -f "$BB" ]; then
|
||||
qemu_log "downloading $BB_URL"
|
||||
curl --retry 3 --retry-delay 5 --retry-connrefused -fSL "$BB_URL" -o "$BB"
|
||||
fi
|
||||
local want got
|
||||
want="$(cat "$sha_file")"
|
||||
got="$(sha256sum "$BB" | awk '{print $1}')"
|
||||
[ "$want" = "$got" ] || { echo "busybox sha256 mismatch: want $want got $got" >&2; exit 1; }
|
||||
qemu_log "busybox sha256 verified"
|
||||
if [ -f "$BB" ]; then
|
||||
got="$(sha256sum "$BB" | awk '{print $1}')"
|
||||
if [ "$want" = "$got" ]; then
|
||||
qemu_log "busybox sha256 verified"
|
||||
return
|
||||
fi
|
||||
qemu_log "cached busybox failed verification; fetching a clean copy"
|
||||
fi
|
||||
|
||||
local attempt tmp="${BB}.download.$$"
|
||||
rm -f "$tmp"
|
||||
for attempt in 1 2 3; do
|
||||
qemu_log "downloading $BB_URL (attempt $attempt/3)"
|
||||
if curl --retry 3 --retry-delay 5 --retry-connrefused -fSL "$BB_URL" -o "$tmp"; then
|
||||
got="$(sha256sum "$tmp" | awk '{print $1}')"
|
||||
if [ "$want" = "$got" ]; then
|
||||
mv -f "$tmp" "$BB"
|
||||
qemu_log "busybox sha256 verified"
|
||||
return
|
||||
fi
|
||||
echo "busybox sha256 mismatch on attempt $attempt: want $want got $got" >&2
|
||||
fi
|
||||
rm -f "$tmp"
|
||||
done
|
||||
echo "FATAL: could not fetch pinned busybox after 3 verified attempts" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Stage the shared rootfs skeleton (qemu/rootfs/ + busybox) into $1.
|
||||
|
||||
Reference in New Issue
Block a user