1*6dbdd20aSAndroid Build Coastguard Worker#!/bin/bash 2*6dbdd20aSAndroid Build Coastguard Worker# Copyright (C) 2018 The Android Open Source Project 3*6dbdd20aSAndroid Build Coastguard Worker# 4*6dbdd20aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 5*6dbdd20aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 6*6dbdd20aSAndroid Build Coastguard Worker# You may obtain a copy of the License at 7*6dbdd20aSAndroid Build Coastguard Worker# 8*6dbdd20aSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 9*6dbdd20aSAndroid Build Coastguard Worker# 10*6dbdd20aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 11*6dbdd20aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 12*6dbdd20aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*6dbdd20aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 14*6dbdd20aSAndroid Build Coastguard Worker# limitations under the License. 15*6dbdd20aSAndroid Build Coastguard Worker 16*6dbdd20aSAndroid Build Coastguard Worker# Builds the current version of catapult, uploads it to GCS and updates the 17*6dbdd20aSAndroid Build Coastguard Worker# pinned SHA256 in install-build-deps. 18*6dbdd20aSAndroid Build Coastguard Worker 19*6dbdd20aSAndroid Build Coastguard Workerset -e 20*6dbdd20aSAndroid Build Coastguard Worker 21*6dbdd20aSAndroid Build Coastguard WorkerPROJECT_ROOT="$(cd -P ${BASH_SOURCE[0]%/*}/..; pwd)" 22*6dbdd20aSAndroid Build Coastguard Worker 23*6dbdd20aSAndroid Build Coastguard Workerif [ "$1" == "" ]; then 24*6dbdd20aSAndroid Build Coastguard Worker echo "Usage: $0 /path/to/catapult/repo" 25*6dbdd20aSAndroid Build Coastguard Worker exit 1 26*6dbdd20aSAndroid Build Coastguard Workerfi 27*6dbdd20aSAndroid Build Coastguard Worker 28*6dbdd20aSAndroid Build Coastguard WorkerCATAPULT="$1" 29*6dbdd20aSAndroid Build Coastguard Workerif [ ! -d "$CATAPULT/.git" ]; then 30*6dbdd20aSAndroid Build Coastguard Worker echo "$CATAPULT must point to a valid catapult repo" 31*6dbdd20aSAndroid Build Coastguard Worker exit 1 32*6dbdd20aSAndroid Build Coastguard Workerfi 33*6dbdd20aSAndroid Build Coastguard Worker 34*6dbdd20aSAndroid Build Coastguard WorkerREVISION=$(git -C "$CATAPULT" rev-parse --short HEAD) 35*6dbdd20aSAndroid Build Coastguard WorkerOUTDIR="$(mktemp -d)" 36*6dbdd20aSAndroid Build Coastguard Workerecho "Building vulcanized Trace Viewer @ $REVISION into $OUTDIR" 37*6dbdd20aSAndroid Build Coastguard Workergit -C "$CATAPULT" log -1 | cat 38*6dbdd20aSAndroid Build Coastguard Workerecho 39*6dbdd20aSAndroid Build Coastguard Workerset -x 40*6dbdd20aSAndroid Build Coastguard Worker"$CATAPULT/tracing/bin/generate_about_tracing_contents" --outdir "$OUTDIR" 41*6dbdd20aSAndroid Build Coastguard WorkerARCHIVE="$OUTDIR/catapult_trace_viewer.tar.gz" 42*6dbdd20aSAndroid Build Coastguard Worker 43*6dbdd20aSAndroid Build Coastguard Worker( 44*6dbdd20aSAndroid Build Coastguard Worker cd "$OUTDIR" 45*6dbdd20aSAndroid Build Coastguard Worker cat >extra_origin_trials <<EOF 46*6dbdd20aSAndroid Build Coastguard Worker <!-- WebComponents V0 origin trial token for https://*.ui.perfetto.dev 47*6dbdd20aSAndroid Build Coastguard Worker Expires 1 Feb 2021. https://crbug.com/1021137. --> 48*6dbdd20aSAndroid Build Coastguard Worker <meta http-equiv="origin-trial" content="AjGFDFU57Af4e5OJJQd7kmYR0nEiObDCHkev6BBWzhGohACl1ri+pMhaVe9V8dDBaXDkWy4g7WYj3c5GiPwatgIAAABreyJvcmlnaW4iOiJodHRwczovL3VpLnBlcmZldHRvLmRldjo0NDMiLCJmZWF0dXJlIjoiV2ViQ29tcG9uZW50c1YwIiwiZXhwaXJ5IjoxNjEyMjIzOTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0="> 49*6dbdd20aSAndroid Build Coastguard Worker 50*6dbdd20aSAndroid Build Coastguard Worker <!-- WebComponents V0 origin trial token for http://localhost:10000 51*6dbdd20aSAndroid Build Coastguard Worker Expires 28 Jan 2021. https://crbug.com/1021137. --> 52*6dbdd20aSAndroid Build Coastguard Worker <meta http-equiv="origin-trial" content="AicMEv5glMGL1lq6ZRsxFJj8xlhn3XDYZrHK0/2KreAD/r62vTFjUBOueeMTxWuU1IlRXqCugRFDD7rY45YEgwkAAABTeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjEwMDAwIiwiZmVhdHVyZSI6IldlYkNvbXBvbmVudHNWMCIsImV4cGlyeSI6MTYxMTg0MDczNH0="> 53*6dbdd20aSAndroid Build Coastguard Worker 54*6dbdd20aSAndroid Build Coastguard Worker <!-- WebComponents V0 origin trial token for https://staging-dot-perfetto-ui.appspot.com 55*6dbdd20aSAndroid Build Coastguard Worker Expires 1 Feb 2021. https://crbug.com/1021137. --> 56*6dbdd20aSAndroid Build Coastguard Worker <meta http-equiv="origin-trial" content="Au1cwnWfBB/GCD22HnNZE93/KamhGDsz8BZbEewICJB2PRtW+E1bobrtZbTZs8q5748uRiKXPvgaut5JOZ8jSw4AAABseyJvcmlnaW4iOiJodHRwczovL3N0YWdpbmctZG90LXBlcmZldHRvLXVpLmFwcHNwb3QuY29tOjQ0MyIsImZlYXR1cmUiOiJXZWJDb21wb25lbnRzVjAiLCJleHBpcnkiOjE2MTIyMjM5OTl9"> 57*6dbdd20aSAndroid Build Coastguard Worker 58*6dbdd20aSAndroid Build Coastguard Worker <!-- WebComponents V0 origin trial token for https://storage.googleapis.com/ 59*6dbdd20aSAndroid Build Coastguard Worker Expires 1 Feb 2021. https://crbug.com/1021137. --> 60*6dbdd20aSAndroid Build Coastguard Worker <meta http-equiv="origin-trial" content="AtobKUpdVFIb6cx2Ev0EbAFX4SzLuXPnsnADRA8JV5w4B64q65gz42shquyLLNd2QP9rY22oNGxbatpTO0kd2AIAAABfeyJvcmlnaW4iOiJodHRwczovL3N0b3JhZ2UuZ29vZ2xlYXBpcy5jb206NDQzIiwiZmVhdHVyZSI6IldlYkNvbXBvbmVudHNWMCIsImV4cGlyeSI6MTYxMjIyMzk5OX0="> 61*6dbdd20aSAndroid Build Coastguard WorkerEOF 62*6dbdd20aSAndroid Build Coastguard Worker 63*6dbdd20aSAndroid Build Coastguard Worker mv about_tracing.html catapult_trace_viewer.html 64*6dbdd20aSAndroid Build Coastguard Worker mv about_tracing.js catapult_trace_viewer.js 65*6dbdd20aSAndroid Build Coastguard Worker sed -i -e \ 66*6dbdd20aSAndroid Build Coastguard Worker 's|src="tracing.js"|src="catapult_trace_viewer.js"|g' \ 67*6dbdd20aSAndroid Build Coastguard Worker catapult_trace_viewer.html 68*6dbdd20aSAndroid Build Coastguard Worker sed -i -e '/<head/r extra_origin_trials' catapult_trace_viewer.html 69*6dbdd20aSAndroid Build Coastguard Worker tar -zcf "$ARCHIVE" catapult_trace_viewer.{js,html} 70*6dbdd20aSAndroid Build Coastguard Worker) 71*6dbdd20aSAndroid Build Coastguard Worker 72*6dbdd20aSAndroid Build Coastguard WorkerSHA256CMD='import hashlib; import sys; sha1=hashlib.sha256(); sha1.update(sys.stdin.read()); print(sha1.hexdigest())' 73*6dbdd20aSAndroid Build Coastguard WorkerSHA256=$(python -c "$SHA256CMD" < "$ARCHIVE") 74*6dbdd20aSAndroid Build Coastguard WorkerGCS_TARGET="gs://perfetto/catapult_trace_viewer-$SHA256.tar.gz" 75*6dbdd20aSAndroid Build Coastguard Workergsutil cp -n -a public-read "$ARCHIVE" "$GCS_TARGET" 76*6dbdd20aSAndroid Build Coastguard Workerrm -rf "$OUTDIR" 77*6dbdd20aSAndroid Build Coastguard Worker 78*6dbdd20aSAndroid Build Coastguard Worker# Update the reference to the new prebuilt in tools/install-build-deps. 79*6dbdd20aSAndroid Build Coastguard Workersed -i -e \ 80*6dbdd20aSAndroid Build Coastguard Worker "s/^CATAPULT_SHA256 =.*/CATAPULT_SHA256 = '"$SHA256"'/g" \ 81*6dbdd20aSAndroid Build Coastguard Worker "$PROJECT_ROOT/tools/install-build-deps" 82*6dbdd20aSAndroid Build Coastguard Worker 83*6dbdd20aSAndroid Build Coastguard Worker"$PROJECT_ROOT/tools/install-build-deps" --ui 84