mirror of
https://github.com/commaai/agnos-builder.git
synced 2026-04-06 06:43:53 +08:00
44 lines
877 B
Bash
Executable File
44 lines
877 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Make sure we're in the correct directory
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
|
|
|
# Constants
|
|
OUTPUT_DIR="$DIR/../output"
|
|
|
|
if [ "$1" == "" ]; then
|
|
echo "Supply the URL to the OTA JSON as first argument!"
|
|
exit 1
|
|
fi
|
|
|
|
OTA_JSON=$(mktemp)
|
|
wget $1 -O $OTA_JSON
|
|
|
|
mkdir -p $OUTPUT_DIR
|
|
cd $OUTPUT_DIR
|
|
|
|
download_image() {
|
|
local name=$1
|
|
local alt=${2:-""}
|
|
|
|
local url=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"$name\") | $alt.url")
|
|
if [ "$url" == "null" ]; then
|
|
return
|
|
fi
|
|
|
|
local hash_raw=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"$name\") | .hash_raw")
|
|
local file_name=$(basename $url .xz)
|
|
file_name=${file_name//-$hash_raw/}
|
|
|
|
echo "Downloading $file_name..."
|
|
curl $url | xz -d > $file_name
|
|
}
|
|
|
|
for name in boot system; do
|
|
download_image $name
|
|
download_image $name ".alt"
|
|
done
|
|
|
|
echo "Done!"
|