git: c0a98d7f9daf - releng/15.0 - GCE: Specify the architecture of images

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Sun, 16 Nov 2025 03:12:02 UTC
The branch releng/15.0 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=c0a98d7f9dafbb52a533ba7ef3df51895141b2b5

commit c0a98d7f9dafbb52a533ba7ef3df51895141b2b5
Author:     Andrew Jorgensen <ajorgens@google.com>
AuthorDate: 2025-11-14 18:06:52 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-11-16 03:11:07 +0000

    GCE: Specify the architecture of images
    
    Without a specified architecture, a user can attempt to create an
    arm64 instance with an amd64 image or vice versa. With the change
    the API will prevent that mismatch.
    
    Approved by:    re (cperciva)
    
    (cherry picked from commit 0a8ecca4e3156bcd4ebbfcb24d968e67a3a09434)
    (cherry picked from commit 93769d225fddad4bc56f4edf543de45d8b666734)
---
 release/Makefile.gce | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/release/Makefile.gce b/release/Makefile.gce
index a6d09de468c0..21df4ddbc3f5 100644
--- a/release/Makefile.gce
+++ b/release/Makefile.gce
@@ -15,6 +15,14 @@ CLEANFILES+=		${GCE_UPLOAD_TGTS}
 GCE_BUCKET?=
 GCE_LICENSE?=
 
+.if ${TARGET_ARCH} == "amd64"
+GCE_ARCH=		X86_64
+.elif ${TARGET_ARCH} == "aarch64"
+GCE_ARCH=		ARM64
+.else
+.error "Unsupported TARGET_ARCH for GCE: ${TARGET_ARCH}. Must be amd64 or aarch64."
+.endif
+
 .if !defined(GCE_FAMILY) || empty(GCE_FAMILY)
 GCE_FAMILY=		${TYPE:tl}-${REVISION:S,.,-,}-${TARGET}
 .endif
@@ -74,6 +82,7 @@ gce-do-upload-${_FS}:
 	/usr/local/bin/gsutil cp ${.OBJDIR}/${GCE_TARGET_${_FS}}.tar.gz \
 		gs://${GCE_BUCKET}/
 	/usr/local/bin/gcloud compute images create ${GCE_TARGET_${_FS}} \
+		--architecture=${GCE_ARCH} \
 		--family=${GCE_FAMILY}-${_FS}${GCE_FAMILY_SUFX} ${GCE_LICENSE} \
 		--guest-os-features=GVNIC,UEFI_COMPATIBLE \
 		--source-uri gs://${GCE_BUCKET}/${GCE_TARGET_${_FS}}.tar.gz