1#!/bin/bash 2# Copyright 2020 The ChromiumOS Authors 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_PREFIX="gs://crosvm/integration_tests/guest" 18 19function prebuilts_exist_error() { 20 echo "Prebuilts of version ${PREBUILT_VERSION} already exist. See README.md" 21 exit 1 22} 23 24function upload() { 25 local arch=$1 26 local remote_bzimage="${GS_PREFIX}-bzimage-${arch}-${PREBUILT_VERSION}" 27 local remote_rootfs="${GS_PREFIX}-rootfs-${arch}-${PREBUILT_VERSION}" 28 29 # Local files 30 local cargo_target=$(cargo metadata --no-deps --format-version 1 | 31 jq -r ".target_directory") 32 local local_bzimage=${cargo_target}/guest_under_test/${arch}/bzImage 33 local local_rootfs=${cargo_target}/guest_under_test/${arch}/rootfs 34 35 echo "Checking if prebuilts already exist." 36 gsutil stat "${remote_bzimage}" && prebuilts_exist_error 37 gsutil stat "${remote_rootfs}" && prebuilts_exist_error 38 39 echo "Building rootfs and kernel." 40 make ARCH=${arch} "${local_bzimage}" "${local_rootfs}" 41 42 echo "Uploading files." 43 gsutil cp -n "${local_bzimage}" "${remote_bzimage}" 44 gsutil cp -n "${local_rootfs}" "${remote_rootfs}" 45} 46 47upload x86_64 48upload aarch64 49