blob: 6472ffdd9d6305ad4f321f11d917415a4feaf001 [file] [log] [blame]
Lalit Magantib36a6902018-11-27 17:55:31 +00001#!/bin/bash
2set -e
3
4echo ""
5echo "Downloading latest copy of test data"
6echo ""
Primiano Tuccif7793ef2019-01-10 21:32:45 +00007LATEST_ZIP="$(cat tools/install-build-deps | grep -o 'https://.*/perfetto/test-data-.*.zip')"
8curl -o /tmp/latest-test-data.zip $LATEST_ZIP
Lalit Magantib36a6902018-11-27 17:55:31 +00009
10echo ""
11echo "Extracting test data to temp folder"
12echo ""
Primiano Tuccif7793ef2019-01-10 21:32:45 +000013rm -rf /tmp/latest-test-data 2>/dev/null
Lalit Magantib36a6902018-11-27 17:55:31 +000014unzip /tmp/latest-test-data.zip -d /tmp/latest-test-data
15
16echo ""
17echo "Copying trace to temp folder"
18echo ""
19cp $1 /tmp/latest-test-data
20
21echo ""
22echo "Zipping file back up"
23echo ""
Lalit Magantifd33c222019-01-24 14:42:31 +000024NEW_TEST_DATA="test-data-$(date +%Y%m%d-%H%M%S).zip"
Lalit Magantia3c3e262018-11-29 18:37:04 +000025CWD="$(pwd)"
26cd /tmp/latest-test-data
27zip -r /tmp/$NEW_TEST_DATA *
28cd $CWD
Lalit Magantib36a6902018-11-27 17:55:31 +000029
30echo ""
31echo "Uploading file to Google Cloud"
32echo ""
33gsutil cp /tmp/$NEW_TEST_DATA gs://perfetto/$NEW_TEST_DATA
34
35echo ""
36echo "Setting file to world readable"
37echo ""
38gsutil acl ch -u AllUsers:R gs://perfetto/$NEW_TEST_DATA
39
40echo ""
Primiano Tucci2c761ef2019-01-07 20:20:46 +000041echo "SHA1 of file $NEW_TEST_DATA is"
42if which shasum; then
Lalit Magantifd33c222019-01-24 14:42:31 +000043NEW_SHA=$(shasum /tmp/$NEW_TEST_DATA) # Mac OS
Primiano Tucci2c761ef2019-01-07 20:20:46 +000044else
Lalit Magantifd33c222019-01-24 14:42:31 +000045NEW_SHA=$(sha1sum /tmp/$NEW_TEST_DATA) # Linux
Primiano Tucci2c761ef2019-01-07 20:20:46 +000046fi
Lalit Magantifd33c222019-01-24 14:42:31 +000047echo $NEW_SHA
Lalit Magantib36a6902018-11-27 17:55:31 +000048
49echo ""
50echo "Cleaning up leftover files"
51echo ""
52rm -r /tmp/latest-test-data
53rm /tmp/latest-test-data.zip
54rm /tmp/$NEW_TEST_DATA
55
56echo ""
Lalit Magantifd33c222019-01-24 14:42:31 +000057echo "Updating tools/install-build-deps"
Lalit Magantib36a6902018-11-27 17:55:31 +000058echo ""
Lalit Magantifd33c222019-01-24 14:42:31 +000059OLD_URL="https://\(.*/perfetto\)/test-data-.*.zip"
60NEW_URL="https://\1/$NEW_TEST_DATA"
61OLD_SHA="\w*"
62SED_MAGIC="s|'$OLD_URL',\n\(\s*\)'$OLD_SHA'|'$NEW_URL',\n\2'$NEW_SHA'|g"
63sed -i '' -z -e "$SED_MAGIC" tools/install-build-deps
64
65echo "All done!"