Skip to content

Commit b112006

Browse files
committed
sdk: add download_payloads
directly from the flatcar-build-scripts (no modification) Signed-off-by: Mathieu Tortuyaux <[email protected]>
1 parent f37db1f commit b112006

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

data/download_payloads

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
5+
echo "Usage: $0 RELEASE_DESCRIPTORS..."
6+
echo "Example: $0 alpha:1786.0.0 beta:1781.2.0"
7+
echo "Downloads the release update payloads to ARCH-usr/VERSION/ folders."
8+
echo "Expected to be run in .../sdk/src/scripts/data/"
9+
echo "(usually before entering the chroot and running ./generate_payload data/ARCH-usr/VERSION/ keys/)."
10+
exit 1
11+
fi
12+
13+
if [ "$(basename "${PWD}")" != "data" ] || [ "$(basename "$(readlink -f ..)")" != "scripts" ]; then
14+
echo "Expected to be run in .../sdk/src/scripts/data/" >&2
15+
exit 1
16+
fi
17+
18+
# Same as in copy-to-origin.sh and set-symlink.sh
19+
for TUPLE_COL in "$@"; do
20+
IFS=":" read -r -a TUPLE <<< "${TUPLE_COL}"
21+
CHANNEL="${TUPLE[0]}"
22+
VERSION="${TUPLE[1]}"
23+
for ARCH in amd64 arm64; do
24+
echo "Downloading ${CHANNEL} ${VERSION} ${ARCH}"
25+
rm -rf "${ARCH}-usr/${VERSION}"
26+
mkdir -p "${ARCH}-usr/${VERSION}" && cd "${ARCH}-usr/${VERSION}"
27+
BASEURL="https://bincache.flatcar-linux.net/images/${ARCH}/${VERSION}/"
28+
# Note: Don't replace this with 'mapfile -t array < <(curl)' or 'read -r -a array <<< "$(curl)"' because that has no error checking
29+
EXTRA_PAYLOADS=($(curl -H 'Accept: application/json' -fsSL "${BASEURL}" | jq -r ".[].name" | { grep -P '^(oem|flatcar)-.*raw(.sig)?$' || true ; }))
30+
wget "${BASEURL}"{flatcar_production_update.bin.bz2,flatcar_production_update.bin.bz2.sig,flatcar_production_image.vmlinuz,flatcar_production_image.vmlinuz.sig}
31+
for EXTRA_PAYLOAD in "${EXTRA_PAYLOADS[@]}"; do
32+
wget "${BASEURL}${EXTRA_PAYLOAD}"
33+
done
34+
cd ../..
35+
done
36+
done
37+
echo "Success"

0 commit comments

Comments
 (0)