-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flash extra.json
manifest
#165
Closed
Closed
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
f9320a6
optimize system image
incognitojam deda4ea
tool path
incognitojam 07cf8be
cleanup script
incognitojam 9758d8f
fix
incognitojam eadc225
.
incognitojam 259addc
extras script
incognitojam 66ddae5
cleanup
incognitojam 8c4ffdf
fix
incognitojam 1981231
remove
incognitojam 1d46372
OTA_DIR
incognitojam a34157a
bash is easier
incognitojam c4135a4
TODO
incognitojam 0137907
checksum
incognitojam cc64f40
fix
incognitojam a91a7be
fixes
incognitojam 288cf53
.
incognitojam d920b1d
cleanup
incognitojam 12c577b
more fixes
incognitojam d395fa1
extras
incognitojam acdc83e
cleanup
incognitojam 354bc1e
system size is weird
incognitojam d3f44aa
cleanup
incognitojam 9d7a403
push
incognitojam 8af8d4f
calculate optimized hash
incognitojam 8efc6a6
cleanup
incognitojam fa1ad25
Merge remote-tracking branch 'origin/master' into agnos-extra
incognitojam 2a80242
cleanup
incognitojam 8dd26f6
better
incognitojam ec75b98
.
incognitojam 94e1e81
more cleanup
incognitojam 5d6b75a
fixes
incognitojam c6a2583
add -optimized suffix to file name
incognitojam 7d95523
fixes
incognitojam a2399bd
cleanup
incognitojam a3a1223
CI
incognitojam c97d7ad
mv
incognitojam 903f0e7
.
incognitojam 456b6d7
consistent
incognitojam 9430673
remove TODO
incognitojam 34de4ce
cleaner
incognitojam 8159d16
Merge remote-tracking branch 'origin/master' into agnos-extra
incognitojam 4403c5e
not quite long enough
incognitojam 5ab471c
less
incognitojam 58b3dae
name
incognitojam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash -e | ||
|
||
# Make sure we're in the correct directory | ||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" | ||
cd $DIR | ||
|
||
# Constants | ||
OTA_OUTPUT_DIR="$DIR/../output/ota" | ||
|
||
source $DIR/upload.sh | ||
|
||
# Liftoff! | ||
for NAME in $(cat $EXTRA_JSON | jq -r '.[] | .name'); do | ||
local HASH_RAW=$(cat $EXTRA_JSON | jq -r ".[] | select(.name == \"$NAME\") | .hash_raw") | ||
local SPARSE=$(cat $EXTRA_JSON | jq -r ".[] | select(.name == \"$NAME\") | .sparse") | ||
|
||
if [ "$SPARSE" == "true" ]; then | ||
upload_file "$NAME-$HASH_RAW-optimized.img.gz" | ||
else | ||
upload_file "$NAME-$HASH_RAW.img.gz" | ||
fi | ||
done | ||
|
||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#!/bin/bash -e | ||
|
||
# Make sure we're in the correct directory | ||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" | ||
cd $DIR | ||
|
||
# Constants | ||
ROOT="$DIR/../" | ||
OUTPUT_DIR="$ROOT/output" | ||
OTA_OUTPUT_DIR="$OUTPUT_DIR/ota" | ||
TOOLS_DIR="$DIR/../tools" | ||
|
||
AGNOS_UPDATE_URL=${AGNOS_UPDATE_URL:-https://commadist.azureedge.net/agnosupdate} | ||
AGNOS_STAGING_UPDATE_URL=${AGNOS_STAGING_UPDATE_URL:-https://commadist.azureedge.net/agnosupdate-staging} | ||
OTA_JSON="$OTA_OUTPUT_DIR/ota.json" | ||
EXTRA_JSON="$OTA_OUTPUT_DIR/extra.json" | ||
EXTRA_STAGING_JSON="$OTA_OUTPUT_DIR/extra-staging.json" | ||
|
||
process_file() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like this file has a ton of duplication |
||
local NAME=$1 | ||
echo "Processing $NAME..." | ||
|
||
local IMAGE_CONFIG=$(cat $OTA_JSON | jq -r ".[] | select(.name == \"$NAME\")") | ||
local URL=$(echo $IMAGE_CONFIG | jq -r ".url") | ||
local HASH=$(echo $IMAGE_CONFIG | jq -r ".hash") | ||
local HASH_RAW=$(echo $IMAGE_CONFIG | jq -r ".hash_raw") | ||
local SPARSE=$(echo $IMAGE_CONFIG | jq -r ".sparse") | ||
local FULL_CHECK=$(echo $IMAGE_CONFIG | jq -r ".full_check") | ||
local HAS_AB=$(echo $IMAGE_CONFIG | jq -r ".has_ab") | ||
|
||
local FILE_NAME=$NAME-$HASH_RAW.img | ||
local IMAGE_FILE=$OTA_OUTPUT_DIR/$FILE_NAME | ||
if [ ! -f $IMAGE_FILE ]; then | ||
local XZ_FILE=$IMAGE_FILE.xz | ||
echo " downloading..." | ||
wget -O $XZ_FILE $URL &> /dev/null | ||
|
||
echo " decompressing..." | ||
xz --decompress --stdout $XZ_FILE > $IMAGE_FILE | ||
fi | ||
|
||
echo " hashing..." | ||
local ACTUAL_HASH=$(sha256sum $IMAGE_FILE | cut -c 1-64) | ||
if [ $ACTUAL_HASH != $HASH ]; then | ||
echo "$NAME hash mismatch!" >&2 | ||
echo " Expected: $HASH" >&2 | ||
echo " Actual: $ACTUAL_HASH" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ $SPARSE == "true" ]; then | ||
local OPTIMIZED_IMAGE_FILE=${IMAGE_FILE%.img}-optimized.img | ||
if [ ! -f $OPTIMIZED_IMAGE_FILE ]; then | ||
echo " optimizing..." | ||
$TOOLS_DIR/simg2dontcare.py $IMAGE_FILE $OPTIMIZED_IMAGE_FILE | ||
fi | ||
IMAGE_FILE=$OPTIMIZED_IMAGE_FILE | ||
FILE_NAME=${FILE_NAME%.img}-optimized.img | ||
HASH=$(sha256sum $IMAGE_FILE | cut -c 1-64) | ||
fi | ||
|
||
local GZ_FILE_NAME=$FILE_NAME.gz | ||
local GZ_FILE=$OTA_OUTPUT_DIR/$GZ_FILE_NAME | ||
if [ ! -f $GZ_FILE ]; then | ||
echo " compressing..." | ||
gzip -c $IMAGE_FILE > $GZ_FILE | ||
fi | ||
|
||
local SIZE=$(wc -c < $IMAGE_FILE) | ||
cat <<EOF | tee -a $EXTRA_JSON $EXTRA_STAGING_JSON > /dev/null | ||
{ | ||
"name": "$NAME", | ||
"hash": "$HASH", | ||
"hash_raw": "$HASH_RAW", | ||
"size": $SIZE, | ||
"sparse": $SPARSE, | ||
"full_check": $FULL_CHECK, | ||
"has_ab": $HAS_AB, | ||
EOF | ||
|
||
cat <<EOF >> $EXTRA_JSON | ||
"url": "$AGNOS_UPDATE_URL/$GZ_FILE_NAME" | ||
EOF | ||
cat <<EOF >> $EXTRA_STAGING_JSON | ||
"url": "$AGNOS_STAGING_UPDATE_URL/$GZ_FILE_NAME" | ||
EOF | ||
|
||
cat <<EOF | tee -a $EXTRA_JSON $EXTRA_STAGING_JSON > /dev/null | ||
}, | ||
EOF | ||
} | ||
|
||
cd $ROOT | ||
mkdir -p $OTA_OUTPUT_DIR | ||
|
||
# If given a manifest URL, download and use that | ||
if [ ! -z "$1" ]; then | ||
OTA_JSON=$(mktemp) | ||
echo "Using provided manifest..." | ||
wget -O $OTA_JSON $1 &> /dev/null | ||
else | ||
OTA_JSON=$(mktemp) | ||
echo "Using master AGNOS manifest..." | ||
wget -O $OTA_JSON https://raw.githubusercontent.com/commaai/openpilot/master/system/hardware/tici/agnos.json &> /dev/null | ||
fi | ||
|
||
echo "[" > $EXTRA_JSON | ||
echo "[" > $EXTRA_STAGING_JSON | ||
|
||
for NAME in $(cat $OTA_JSON | jq -r '.[] | .name'); do | ||
process_file $NAME | ||
done | ||
|
||
# remove trailing comma | ||
sed -i "$ s/.$//" $EXTRA_JSON $EXTRA_STAGING_JSON | ||
|
||
echo "]" >> $EXTRA_JSON | ||
echo "]" >> $EXTRA_STAGING_JSON | ||
|
||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
if [ -z "$OTA_OUTPUT_DIR" ]; then | ||
echo "OTA_OUTPUT_DIR is not set!" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Constants | ||
DATA_ACCOUNT="commadist" | ||
|
||
# Parse input | ||
FOUND=0 | ||
if [ "$1" == "production" ]; then | ||
OTA_JSON="$OTA_OUTPUT_DIR/ota.json" | ||
EXTRA_JSON="$OTA_OUTPUT_DIR/extra.json" | ||
DATA_CONTAINER="agnosupdate" | ||
FOUND=1 | ||
fi | ||
if [ "$1" == "staging" ]; then | ||
OTA_JSON="$OTA_OUTPUT_DIR/ota-staging.json" | ||
EXTRA_JSON="$OTA_OUTPUT_DIR/extra-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 --overwrite=false $OTA_OUTPUT_DIR/$FILE_NAME "$CLOUD_PATH?$DATA_SAS_TOKEN" | ||
echo " $CLOUD_PATH" | ||
} | ||
|
||
# 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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimized is kind of a misnomer here - it's just "special". maybe call it "skipped-chunks"