blob: f91551d44264f10cbe8bad6852a3aeb8faf338d4 [file] [log] [blame]
Lalit Magantib36a6902018-11-27 17:55:31 +00001#!/bin/bash
Primiano Tucci94c47f02019-12-05 03:13:11 +00002# 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 Magantib36a6902018-11-27 17:55:31 +000016set -e
17
18echo ""
19echo "Downloading latest copy of test data"
20echo ""
Primiano Tuccif7793ef2019-01-10 21:32:45 +000021LATEST_ZIP="$(cat tools/install-build-deps | grep -o 'https://.*/perfetto/test-data-.*.zip')"
22curl -o /tmp/latest-test-data.zip $LATEST_ZIP
Lalit Magantib36a6902018-11-27 17:55:31 +000023
24echo ""
25echo "Extracting test data to temp folder"
26echo ""
Primiano Tuccif7793ef2019-01-10 21:32:45 +000027rm -rf /tmp/latest-test-data 2>/dev/null
Lalit Magantib36a6902018-11-27 17:55:31 +000028unzip /tmp/latest-test-data.zip -d /tmp/latest-test-data
29
30echo ""
31echo "Copying trace to temp folder"
32echo ""
33cp $1 /tmp/latest-test-data
34
35echo ""
36echo "Zipping file back up"
37echo ""
Lalit Magantifd33c222019-01-24 14:42:31 +000038NEW_TEST_DATA="test-data-$(date +%Y%m%d-%H%M%S).zip"
Lalit Magantia3c3e262018-11-29 18:37:04 +000039CWD="$(pwd)"
40cd /tmp/latest-test-data
41zip -r /tmp/$NEW_TEST_DATA *
42cd $CWD
Lalit Magantib36a6902018-11-27 17:55:31 +000043
44echo ""
45echo "Uploading file to Google Cloud"
46echo ""
47gsutil cp /tmp/$NEW_TEST_DATA gs://perfetto/$NEW_TEST_DATA
48
49echo ""
50echo "Setting file to world readable"
51echo ""
52gsutil acl ch -u AllUsers:R gs://perfetto/$NEW_TEST_DATA
53
54echo ""
Primiano Tucci2c761ef2019-01-07 20:20:46 +000055echo "SHA1 of file $NEW_TEST_DATA is"
Primiano Tucci79519d62019-06-24 20:51:04 +010056if which shasum > /dev/null; then
57NEW_SHA=$(shasum /tmp/$NEW_TEST_DATA | cut -c1-40) # Mac OS
Primiano Tucci2c761ef2019-01-07 20:20:46 +000058else
Primiano Tucci79519d62019-06-24 20:51:04 +010059NEW_SHA=$(sha1sum /tmp/$NEW_TEST_DATA | cut -c1-40) # Linux
Primiano Tucci2c761ef2019-01-07 20:20:46 +000060fi
Lalit Magantifd33c222019-01-24 14:42:31 +000061echo $NEW_SHA
Lalit Magantib36a6902018-11-27 17:55:31 +000062
63echo ""
64echo "Cleaning up leftover files"
65echo ""
66rm -r /tmp/latest-test-data
67rm /tmp/latest-test-data.zip
68rm /tmp/$NEW_TEST_DATA
69
70echo ""
Lalit Magantifd33c222019-01-24 14:42:31 +000071echo "Updating tools/install-build-deps"
Lalit Magantib36a6902018-11-27 17:55:31 +000072echo ""
Primiano Tucci79519d62019-06-24 20:51:04 +010073
Isabelle Taylor8b4740b2019-10-25 10:25:24 +010074OLD_SHA=$(cat tools/install-build-deps | grep '/test-data-.*.zip' -A1 | tail -n1 | cut -c10-49)
Primiano Tucci79519d62019-06-24 20:51:04 +010075
76# Cannot easily use sed -i, it has different syntax on Linux vs Mac.
77cat tools/install-build-deps \
Isabelle Taylor8b4740b2019-10-25 10:25:24 +010078 | sed -e "s|/test-data-.*.zip|/$NEW_TEST_DATA|g" \
79 | sed -e "s|$OLD_SHA|$NEW_SHA|g" \
Primiano Tucci79519d62019-06-24 20:51:04 +010080 > tools/install-build-deps.tmp
81
82mv -f tools/install-build-deps.tmp tools/install-build-deps
Raymond Chiubfdfbe92019-06-27 12:27:06 -070083chmod 755 tools/install-build-deps
Lalit Magantifd33c222019-01-24 14:42:31 +000084
85echo "All done!"