Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | echo "" |
| 5 | echo "Downloading latest copy of test data" |
| 6 | echo "" |
Primiano Tucci | f7793ef | 2019-01-10 21:32:45 +0000 | [diff] [blame] | 7 | LATEST_ZIP="$(cat tools/install-build-deps | grep -o 'https://.*/perfetto/test-data-.*.zip')" |
| 8 | curl -o /tmp/latest-test-data.zip $LATEST_ZIP |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 9 | |
| 10 | echo "" |
| 11 | echo "Extracting test data to temp folder" |
| 12 | echo "" |
Primiano Tucci | f7793ef | 2019-01-10 21:32:45 +0000 | [diff] [blame] | 13 | rm -rf /tmp/latest-test-data 2>/dev/null |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 14 | unzip /tmp/latest-test-data.zip -d /tmp/latest-test-data |
| 15 | |
| 16 | echo "" |
| 17 | echo "Copying trace to temp folder" |
| 18 | echo "" |
| 19 | cp $1 /tmp/latest-test-data |
| 20 | |
| 21 | echo "" |
| 22 | echo "Zipping file back up" |
| 23 | echo "" |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame^] | 24 | NEW_TEST_DATA="test-data-$(date +%Y%m%d-%H%M%S).zip" |
Lalit Maganti | a3c3e26 | 2018-11-29 18:37:04 +0000 | [diff] [blame] | 25 | CWD="$(pwd)" |
| 26 | cd /tmp/latest-test-data |
| 27 | zip -r /tmp/$NEW_TEST_DATA * |
| 28 | cd $CWD |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 29 | |
| 30 | echo "" |
| 31 | echo "Uploading file to Google Cloud" |
| 32 | echo "" |
| 33 | gsutil cp /tmp/$NEW_TEST_DATA gs://perfetto/$NEW_TEST_DATA |
| 34 | |
| 35 | echo "" |
| 36 | echo "Setting file to world readable" |
| 37 | echo "" |
| 38 | gsutil acl ch -u AllUsers:R gs://perfetto/$NEW_TEST_DATA |
| 39 | |
| 40 | echo "" |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 41 | echo "SHA1 of file $NEW_TEST_DATA is" |
| 42 | if which shasum; then |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame^] | 43 | NEW_SHA=$(shasum /tmp/$NEW_TEST_DATA) # Mac OS |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 44 | else |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame^] | 45 | NEW_SHA=$(sha1sum /tmp/$NEW_TEST_DATA) # Linux |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 46 | fi |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame^] | 47 | echo $NEW_SHA |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 48 | |
| 49 | echo "" |
| 50 | echo "Cleaning up leftover files" |
| 51 | echo "" |
| 52 | rm -r /tmp/latest-test-data |
| 53 | rm /tmp/latest-test-data.zip |
| 54 | rm /tmp/$NEW_TEST_DATA |
| 55 | |
| 56 | echo "" |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame^] | 57 | echo "Updating tools/install-build-deps" |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 58 | echo "" |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame^] | 59 | OLD_URL="https://\(.*/perfetto\)/test-data-.*.zip" |
| 60 | NEW_URL="https://\1/$NEW_TEST_DATA" |
| 61 | OLD_SHA="\w*" |
| 62 | SED_MAGIC="s|'$OLD_URL',\n\(\s*\)'$OLD_SHA'|'$NEW_URL',\n\2'$NEW_SHA'|g" |
| 63 | sed -i '' -z -e "$SED_MAGIC" tools/install-build-deps |
| 64 | |
| 65 | echo "All done!" |