blob: 84e0eb50eb0f19cea9eea6e503c984acad678502 [file] [log] [blame]
Primiano Tucci1c752c12018-10-23 09:27:19 +01001#!/bin/bash
2# Copyright (C) 2018 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
16# Builds the current version of catapult, uploads it to GCS and updates the
Primiano Tucci15968b52020-10-28 15:30:40 +010017# pinned SHA256 in install-build-deps.
Primiano Tucci1c752c12018-10-23 09:27:19 +010018
19set -e
20
21PROJECT_ROOT="$(cd -P ${BASH_SOURCE[0]%/*}/..; pwd)"
22
23if [ "$1" == "" ]; then
24 echo "Usage: $0 /path/to/catapult/repo"
25 exit 1
26fi
27
28CATAPULT="$1"
29if [ ! -d "$CATAPULT/.git" ]; then
30 echo "$CATAPULT must point to a valid catapult repo"
31 exit 1
32fi
33
34REVISION=$(git -C "$CATAPULT" rev-parse --short HEAD)
35OUTDIR="$(mktemp -d)"
36echo "Building vulcanized Trace Viewer @ $REVISION into $OUTDIR"
37git -C "$CATAPULT" log -1 | cat
38echo
39set -x
40"$CATAPULT/tracing/bin/generate_about_tracing_contents" --outdir "$OUTDIR"
41ARCHIVE="$OUTDIR/catapult_trace_viewer.tar.gz"
42
43(
44 cd "$OUTDIR"
Primiano Tuccidf7c4022020-03-02 22:58:50 +000045 cat >extra_origin_trials <<EOF
46 <!-- WebComponents V0 origin trial token for https://*.ui.perfetto.dev
47 Expires 1 Feb 2021. https://crbug.com/1021137. -->
48 <meta http-equiv="origin-trial" content="AjGFDFU57Af4e5OJJQd7kmYR0nEiObDCHkev6BBWzhGohACl1ri+pMhaVe9V8dDBaXDkWy4g7WYj3c5GiPwatgIAAABreyJvcmlnaW4iOiJodHRwczovL3VpLnBlcmZldHRvLmRldjo0NDMiLCJmZWF0dXJlIjoiV2ViQ29tcG9uZW50c1YwIiwiZXhwaXJ5IjoxNjEyMjIzOTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0=">
49
50 <!-- WebComponents V0 origin trial token for http://localhost:10000
51 Expires 28 Jan 2021. https://crbug.com/1021137. -->
52 <meta http-equiv="origin-trial" content="AicMEv5glMGL1lq6ZRsxFJj8xlhn3XDYZrHK0/2KreAD/r62vTFjUBOueeMTxWuU1IlRXqCugRFDD7rY45YEgwkAAABTeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjEwMDAwIiwiZmVhdHVyZSI6IldlYkNvbXBvbmVudHNWMCIsImV4cGlyeSI6MTYxMTg0MDczNH0=">
53
54 <!-- WebComponents V0 origin trial token for https://staging-dot-perfetto-ui.appspot.com
55 Expires 1 Feb 2021. https://crbug.com/1021137. -->
56 <meta http-equiv="origin-trial" content="Au1cwnWfBB/GCD22HnNZE93/KamhGDsz8BZbEewICJB2PRtW+E1bobrtZbTZs8q5748uRiKXPvgaut5JOZ8jSw4AAABseyJvcmlnaW4iOiJodHRwczovL3N0YWdpbmctZG90LXBlcmZldHRvLXVpLmFwcHNwb3QuY29tOjQ0MyIsImZlYXR1cmUiOiJXZWJDb21wb25lbnRzVjAiLCJleHBpcnkiOjE2MTIyMjM5OTl9">
57
58 <!-- WebComponents V0 origin trial token for https://storage.googleapis.com/
59 Expires 1 Feb 2021. https://crbug.com/1021137. -->
60 <meta http-equiv="origin-trial" content="AtobKUpdVFIb6cx2Ev0EbAFX4SzLuXPnsnADRA8JV5w4B64q65gz42shquyLLNd2QP9rY22oNGxbatpTO0kd2AIAAABfeyJvcmlnaW4iOiJodHRwczovL3N0b3JhZ2UuZ29vZ2xlYXBpcy5jb206NDQzIiwiZmVhdHVyZSI6IldlYkNvbXBvbmVudHNWMCIsImV4cGlyeSI6MTYxMjIyMzk5OX0=">
61EOF
62
Primiano Tucci1c752c12018-10-23 09:27:19 +010063 mv about_tracing.html catapult_trace_viewer.html
64 mv about_tracing.js catapult_trace_viewer.js
Primiano Tuccidf7c4022020-03-02 22:58:50 +000065 sed -i -e \
66 's|src="tracing.js"|src="catapult_trace_viewer.js"|g' \
Primiano Tucci1c752c12018-10-23 09:27:19 +010067 catapult_trace_viewer.html
Primiano Tuccidf7c4022020-03-02 22:58:50 +000068 sed -i -e '/<head/r extra_origin_trials' catapult_trace_viewer.html
Primiano Tucci1c752c12018-10-23 09:27:19 +010069 tar -zcf "$ARCHIVE" catapult_trace_viewer.{js,html}
70)
71
Primiano Tucci15968b52020-10-28 15:30:40 +010072SHA256CMD='import hashlib; import sys; sha1=hashlib.sha256(); sha1.update(sys.stdin.read()); print(sha1.hexdigest())'
73SHA256=$(python -c "$SHA256CMD" < "$ARCHIVE")
74GCS_TARGET="gs://perfetto/catapult_trace_viewer-$SHA256.tar.gz"
Primiano Tucci1c752c12018-10-23 09:27:19 +010075gsutil cp -n -a public-read "$ARCHIVE" "$GCS_TARGET"
76rm -rf "$OUTDIR"
77
78# Update the reference to the new prebuilt in tools/install-build-deps.
Primiano Tuccidf7c4022020-03-02 22:58:50 +000079sed -i -e \
Primiano Tucci15968b52020-10-28 15:30:40 +010080 "s/^CATAPULT_SHA256 =.*/CATAPULT_SHA256 = '"$SHA256"'/g" \
Primiano Tucci1c752c12018-10-23 09:27:19 +010081 "$PROJECT_ROOT/tools/install-build-deps"
82
Primiano Tucci15968b52020-10-28 15:30:40 +010083"$PROJECT_ROOT/tools/install-build-deps" --ui