1#!/bin/bash 2# Copyright 2020 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# Builds and uploads prebuilts to cloud storage. 7# 8# Note: Only Googlers with access to the crosvm-testing cloud storage bin can 9# upload prebuilts. 10# 11# See README.md for how to uprev the prebuilt version. 12 13set -e 14cd "${0%/*}" 15 16readonly PREBUILT_VERSION="$(cat ./PREBUILT_VERSION)" 17readonly GS_BUCKET="gs://chromeos-localmirror/distfiles" 18readonly GS_PREFIX="${GS_BUCKET}/crosvm-testing" 19 20function prebuilts_exist_error() { 21 echo "Prebuilts of version ${PREBUILT_VERSION} already exist. See README.md" 22 exit 1 23} 24 25function upload() { 26 local arch=$1 27 local remote_bzimage="${GS_PREFIX}-bzimage-${arch}-${PREBUILT_VERSION}" 28 local remote_rootfs="${GS_PREFIX}-rootfs-${arch}-${PREBUILT_VERSION}" 29 30 # Local files 31 local cargo_target=$(cargo metadata --no-deps --format-version 1 | 32 jq -r ".target_directory") 33 local local_bzimage=${cargo_target}/guest_under_test/${arch}/bzImage 34 local local_rootfs=${cargo_target}/guest_under_test/${arch}/rootfs 35 36 echo "Checking if prebuilts already exist." 37 gsutil stat "${remote_bzimage}" && prebuilts_exist_error 38 gsutil stat "${remote_rootfs}" && prebuilts_exist_error 39 40 echo "Building rootfs and kernel." 41 make ARCH=${arch} "${local_bzimage}" "${local_rootfs}" 42 43 echo "Uploading files." 44 gsutil cp -n -a public-read "${local_bzimage}" "${remote_bzimage}" 45 gsutil cp -n -a public-read "${local_rootfs}" "${remote_rootfs}" 46} 47 48upload x86_64 49upload aarch64 50