mirror of
https://github.com/commaai/agnos-builder.git
synced 2026-04-06 06:43:53 +08:00
* all * ota * all manif * ab * remove these * hash * userdata * ontheflyisthebest * on the fly * dont need * remove * handle fill * comment * all * all img * rename * read * sparse image * tool * no root * userdata * userdata * need this unfort * fix * fix * nop * remove * nop * this too * ota check * better for push * fix * again * good now
59 lines
1.5 KiB
Bash
Executable File
59 lines
1.5 KiB
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)"
|
|
cd $DIR
|
|
|
|
# Constants
|
|
OTA_DIR="$DIR/../output/ota"
|
|
DATA_ACCOUNT="commadist"
|
|
|
|
# Parse input
|
|
FOUND=0
|
|
if [ "$1" == "production" ]; then
|
|
OTA_JSON="$OTA_DIR/all-partitions.json"
|
|
DATA_CONTAINER="agnosupdate"
|
|
FOUND=1
|
|
fi
|
|
if [ "$1" == "staging" ]; then
|
|
OTA_JSON="$OTA_DIR/all-partitions-staging.json"
|
|
DATA_CONTAINER="agnosupdate-staging"
|
|
FOUND=1
|
|
fi
|
|
|
|
if [ $FOUND == 0 ]; then
|
|
echo "Supply either 'production' or 'staging' as first argument!"
|
|
exit 1
|
|
fi
|
|
|
|
upload_file() {
|
|
local FILE_NAME=$1
|
|
local CLOUD_PATH="https://$DATA_ACCOUNT.blob.core.windows.net/$DATA_CONTAINER/$FILE_NAME"
|
|
|
|
echo "Copying $FILE_NAME to the cloud..."
|
|
azcopy cp --log-level ERROR --overwrite=false $OTA_DIR/$FILE_NAME "$CLOUD_PATH?$DATA_SAS_TOKEN"
|
|
echo " $CLOUD_PATH"
|
|
}
|
|
|
|
process_file() {
|
|
local NAME=$1
|
|
local HASH_RAW=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"$NAME\") | .hash_raw")
|
|
upload_file "$NAME-$HASH_RAW.img.xz"
|
|
if [ -f "$OTA_DIR/$NAME-$HASH_RAW.img" ]; then
|
|
upload_file "$NAME-$HASH_RAW.img"
|
|
fi
|
|
}
|
|
|
|
# Generate token
|
|
echo "Logging in..."
|
|
SAS_EXPIRY=$(date -u '+%Y-%m-%dT%H:%M:%SZ' -d '+1 hour')
|
|
DATA_SAS_TOKEN=$(az storage container generate-sas --as-user --auth-mode login --account-name $DATA_ACCOUNT --name $DATA_CONTAINER --https-only --permissions wr --expiry $SAS_EXPIRY --output tsv)
|
|
|
|
# Liftoff!
|
|
for name in $(cat $OTA_JSON | jq -r ".[] .name"); do
|
|
process_file $name
|
|
done
|
|
|
|
echo "Done!"
|