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" |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 42 | if which shasum > /dev/null; then |
| 43 | NEW_SHA=$(shasum /tmp/$NEW_TEST_DATA | cut -c1-40) # Mac OS |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 44 | else |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 45 | NEW_SHA=$(sha1sum /tmp/$NEW_TEST_DATA | cut -c1-40) # 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 "" |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 59 | |
Isabelle Taylor | 8b4740b | 2019-10-25 10:25:24 +0100 | [diff] [blame^] | 60 | OLD_SHA=$(cat tools/install-build-deps | grep '/test-data-.*.zip' -A1 | tail -n1 | cut -c10-49) |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 61 | |
| 62 | # Cannot easily use sed -i, it has different syntax on Linux vs Mac. |
| 63 | cat tools/install-build-deps \ |
Isabelle Taylor | 8b4740b | 2019-10-25 10:25:24 +0100 | [diff] [blame^] | 64 | | sed -e "s|/test-data-.*.zip|/$NEW_TEST_DATA|g" \ |
| 65 | | sed -e "s|$OLD_SHA|$NEW_SHA|g" \ |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 66 | > tools/install-build-deps.tmp |
| 67 | |
| 68 | mv -f tools/install-build-deps.tmp tools/install-build-deps |
Raymond Chiu | bfdfbe9 | 2019-06-27 12:27:06 -0700 | [diff] [blame] | 69 | chmod 755 tools/install-build-deps |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame] | 70 | |
| 71 | echo "All done!" |