aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2022-08-01 14:32:59 -0700
committerAlistair Delva <adelva@google.com>2022-08-30 12:25:06 -0700
commit6757508604561744160cc6324dceae5c33f300d1 (patch)
tree65acd7baefa6a3e6a19ea81d3da03637042fbb64
parenta47b5e3c051fff22e68d35c0d2b6d901113e5dc9 (diff)
downloadcuttlefish_vmm-6757508604561744160cc6324dceae5c33f300d1.tar.gz
Add support for arm64 GCE
Use "--gce_arch=aarch64 --docker_arch=aarch64" to build arm64 images on a an arm64 host. By default the GCE arch will match the host arch the script is running on, just like the docker arch. You can utilize cross building ('buildx') with "--gce_arch=x86_64 --docker_arch=aarch64" as before, but the other way around doesn't work. Bug: 216827224 Change-Id: I2373e90926dac862648c1a4d00a4d656058c96af
-rwxr-xr-xrebuild.sh24
1 files changed, 22 insertions, 2 deletions
diff --git a/rebuild.sh b/rebuild.sh
index a91f160..26ec41e 100755
--- a/rebuild.sh
+++ b/rebuild.sh
@@ -34,6 +34,7 @@ DEFINE_string docker_uid "${UID}" "Docker-container user ID"
# GCE options
DEFINE_boolean gce false "Build on a GCE instance"
+DEFINE_string gce_arch "$(uname -m)" "Target architecture"
DEFINE_string gce_project "$(gcloud config get-value project)" "Project to use" "p"
DEFINE_string gce_instance "${USER}-build" "Instance name to create for the build" "i"
DEFINE_string gce_user cuttlefish_crosvm_builder "User name to use on GCE when doing the build"
@@ -158,6 +159,25 @@ build_locally_using_docker() {
function build_on_gce() {
check_common_docker_options
+ if [[ "${FLAGS_gce_arch}" != "${FLAGS_docker_arch}" ]]; then
+ echo Docker arch must match gce arch 1>&2
+ fail=1
+ fi
+ local _image_family=""
+ local _machine_type=""
+ case "${FLAGS_gce_arch}" in
+ aarch64)
+ _image_family=debian-11-arm64
+ _machine_type=t2a-standard
+ ;;
+ x86_64)
+ _image_family=debian-11
+ _machine_type=n1-standard
+ ;;
+ *) echo Invalid value ${FLAGS_gce_arch} for --gce_arch 1>&2
+ fail=1
+ ;;
+ esac
if [[ -z "${FLAGS_gce_instance}" ]]; then
echo Must specify instance 1>&2
fail=1
@@ -193,7 +213,7 @@ function build_on_gce() {
"${delete_instances[@]/%/-disk}" \
"${project_zone_flags[@]}" \
--image-project="debian-cloud" \
- --image-family="debian-11"
+ --image-family="${_image_family}"
gcloud compute images create \
"${delete_instances[@]/%/-image}" \
--source-disk "${delete_instances[@]/%/-disk}" \
@@ -203,7 +223,7 @@ function build_on_gce() {
"${project_zone_flags[@]}" \
--image "${delete_instances[@]/%/-image}" \
--boot-disk-size=200GB \
- --machine-type=n1-standard-"${FLAGS_gce_vcpus}" \
+ --machine-type="${_machine_type}-${FLAGS_gce_vcpus}" \
--network-interface=nic-type=GVNIC
wait_for_instance "${FLAGS_gce_instance}" "${project_zone_flags[@]}"