mirror of
https://github.com/commaai/agnos-builder.git
synced 2026-04-06 14:53:54 +08:00
* no internal * Update README.md * testing * rm private submodules * do this the normal way now * rm agnos-firmware * add size * fix mac * files
43 lines
865 B
Bash
Executable File
43 lines
865 B
Bash
Executable File
#!/bin/bash -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!"
|