Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Primiano Tucci | 94c47f0 | 2019-12-05 03:13:11 +0000 | [diff] [blame^] | 2 | # Copyright (C) 2019 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 16 | set -e |
| 17 | |
| 18 | echo "" |
| 19 | echo "Downloading latest copy of test data" |
| 20 | echo "" |
Primiano Tucci | f7793ef | 2019-01-10 21:32:45 +0000 | [diff] [blame] | 21 | LATEST_ZIP="$(cat tools/install-build-deps | grep -o 'https://.*/perfetto/test-data-.*.zip')" |
| 22 | curl -o /tmp/latest-test-data.zip $LATEST_ZIP |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 23 | |
| 24 | echo "" |
| 25 | echo "Extracting test data to temp folder" |
| 26 | echo "" |
Primiano Tucci | f7793ef | 2019-01-10 21:32:45 +0000 | [diff] [blame] | 27 | rm -rf /tmp/latest-test-data 2>/dev/null |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 28 | unzip /tmp/latest-test-data.zip -d /tmp/latest-test-data |
| 29 | |
| 30 | echo "" |
| 31 | echo "Copying trace to temp folder" |
| 32 | echo "" |
| 33 | cp $1 /tmp/latest-test-data |
| 34 | |
| 35 | echo "" |
| 36 | echo "Zipping file back up" |
| 37 | echo "" |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame] | 38 | 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] | 39 | CWD="$(pwd)" |
| 40 | cd /tmp/latest-test-data |
| 41 | zip -r /tmp/$NEW_TEST_DATA * |
| 42 | cd $CWD |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 43 | |
| 44 | echo "" |
| 45 | echo "Uploading file to Google Cloud" |
| 46 | echo "" |
| 47 | gsutil cp /tmp/$NEW_TEST_DATA gs://perfetto/$NEW_TEST_DATA |
| 48 | |
| 49 | echo "" |
| 50 | echo "Setting file to world readable" |
| 51 | echo "" |
| 52 | gsutil acl ch -u AllUsers:R gs://perfetto/$NEW_TEST_DATA |
| 53 | |
| 54 | echo "" |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 55 | echo "SHA1 of file $NEW_TEST_DATA is" |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 56 | if which shasum > /dev/null; then |
| 57 | NEW_SHA=$(shasum /tmp/$NEW_TEST_DATA | cut -c1-40) # Mac OS |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 58 | else |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 59 | NEW_SHA=$(sha1sum /tmp/$NEW_TEST_DATA | cut -c1-40) # Linux |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 60 | fi |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame] | 61 | echo $NEW_SHA |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 62 | |
| 63 | echo "" |
| 64 | echo "Cleaning up leftover files" |
| 65 | echo "" |
| 66 | rm -r /tmp/latest-test-data |
| 67 | rm /tmp/latest-test-data.zip |
| 68 | rm /tmp/$NEW_TEST_DATA |
| 69 | |
| 70 | echo "" |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame] | 71 | echo "Updating tools/install-build-deps" |
Lalit Maganti | b36a690 | 2018-11-27 17:55:31 +0000 | [diff] [blame] | 72 | echo "" |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 73 | |
Isabelle Taylor | 8b4740b | 2019-10-25 10:25:24 +0100 | [diff] [blame] | 74 | 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] | 75 | |
| 76 | # Cannot easily use sed -i, it has different syntax on Linux vs Mac. |
| 77 | cat tools/install-build-deps \ |
Isabelle Taylor | 8b4740b | 2019-10-25 10:25:24 +0100 | [diff] [blame] | 78 | | sed -e "s|/test-data-.*.zip|/$NEW_TEST_DATA|g" \ |
| 79 | | sed -e "s|$OLD_SHA|$NEW_SHA|g" \ |
Primiano Tucci | 79519d6 | 2019-06-24 20:51:04 +0100 | [diff] [blame] | 80 | > tools/install-build-deps.tmp |
| 81 | |
| 82 | mv -f tools/install-build-deps.tmp tools/install-build-deps |
Raymond Chiu | bfdfbe9 | 2019-06-27 12:27:06 -0700 | [diff] [blame] | 83 | chmod 755 tools/install-build-deps |
Lalit Maganti | fd33c22 | 2019-01-24 14:42:31 +0000 | [diff] [blame] | 84 | |
| 85 | echo "All done!" |