git: 2650d01ba0c3 - main - GCE: Copy /usr/{src,ports} directly

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Mon, 02 Nov 2026 02:16:44 UTC
The branch main has been updated by cperciva:

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

commit 2650d01ba0c388fb1fe77ce2a7d40faf8f76a0b7
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2026-10-19 01:14:57 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-11-02 02:16:23 +0000

    GCE: Copy /usr/{src,ports} directly
    
    Distribution sets are going away, so we can't extract those into GCE
    images for all-source-code-included compliance purposes.
    
    Differential Revision:  https://reviews.freebsd.org/D60944
---
 release/Makefile.vm    |  7 -------
 release/tools/gce.conf | 48 +++++++++++++++++++++++-------------------------
 2 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/release/Makefile.vm b/release/Makefile.vm
index 13b6d993d07d..187e0937800e 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -127,13 +127,6 @@ ${_CW:tu}${_FS:tu}${_FMT:tu}IMAGE=	${_CW:tl}.${_FS}.${_FMT}
 cw-${_CW:tl}-${_FS}-${_FMT}: cw-ec2-base-${_FS}-${_FMT}
 .endif
 
-# Special handling: GCE images ingest src.txz and ports.txz and expect them
-# to be in the /ftp/ directory.  Note: This will need to be reworked before
-# distribution sets go away!
-.if ${_CW} == GCE
-cw-${_CW:tl}-${_FS}-${_FMT}: ftp
-.endif
-
 cw-${_CW:tl}-${_FS}-${_FMT}: ${QEMUTGT} ${PKGBASE_REPO_DIR}
 	mkdir -p ${.OBJDIR}/${.TARGET}
 	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} SWAPSIZE=${SWAPSIZE} \
diff --git a/release/tools/gce.conf b/release/tools/gce.conf
index 938672ac92e0..079fcc7cc43d 100644
--- a/release/tools/gce.conf
+++ b/release/tools/gce.conf
@@ -105,31 +105,29 @@ debug.trace_on_panic=1
 debug.debugger_on_panic=0
 EOF
 
-	# To meet GCE marketplace requirements, extract the src.txz and
-	# ports.txz distributions to the target virtual machine disk image
-	# and fetch the sources for the third-party software installed on
-	# the image.
-	if [ -e "${DESTDIR}/../ftp/src.txz" ]; then
-		tar fxJ ${DESTDIR}/../ftp/src.txz -C ${DESTDIR}
-		( cd ${DESTDIR} && find ./usr/src ) |
-		    while read P; do
-			metalog_add_data ${P}
-		    done
-	fi
-	if [ -e "${DESTDIR}/../ftp/ports.txz" ]; then
-		tar fxJ ${DESTDIR}/../ftp/ports.txz -C ${DESTDIR}
-		_INSTALLED_PACKAGES=$(pkg -r ${DESTDIR} info -o -q -a | grep -v ^base/)
-		for PACKAGE in ${_INSTALLED_PACKAGES}; do
-			make -C ${DESTDIR}/usr/ports/${PACKAGE} fetch \
-			    DISTDIR=${DESTDIR}/usr/ports/distfiles \
-			    DISABLE_VULNERABILITIES=YES \
-			    I_DONT_CARE_IF_MY_BUILDS_TARGET_THE_WRONG_RELEASE=YES
-		done
-		( cd ${DESTDIR} && find ./usr/ports ) |
-		    while read P; do
-			metalog_add_data ${P}
-		    done
-	fi
+	# To meet GCE marketplace requirements, copy the src and ports trees
+	# to the target virtual machine disk image and fetch the sources for
+	# the third-party software installed on the image.
+	mkdir -p ${DESTDIR}/usr/src
+	tar -cf- -C ${WORLDDIR} --exclude .svn --exclude .git --exclude .got \
+	    --exclude .zfs --exclude ^release/obj --exclude ^release/dist . |
+	    tar -xf- -C ${DESTDIR}/usr/src
+	mkdir -p ${DESTDIR}/usr/ports
+	tar -cf- -C ${PORTSDIR} --exclude .svn --exclude .git --exclude .got \
+	    --exclude ^distfiles --exclude ^packages --exclude '^INDEX*' \
+	    --exclude work . |
+	    tar -xf- -C ${DESTDIR}/usr/ports
+	_INSTALLED_PACKAGES=$(pkg -r ${DESTDIR} info -o -q -a | grep -v ^base/)
+	for PACKAGE in ${_INSTALLED_PACKAGES}; do
+		make -C ${DESTDIR}/usr/ports/${PACKAGE} fetch \
+		    DISTDIR=${DESTDIR}/usr/ports/distfiles \
+		    DISABLE_VULNERABILITIES=YES \
+		    I_DONT_CARE_IF_MY_BUILDS_TARGET_THE_WRONG_RELEASE=YES
+	done
+	( cd ${DESTDIR} && find ./usr/src ./usr/ports ) |
+	    while read P; do
+		metalog_add_data ${P}
+	    done
 
 	## XXX: Verify this is needed.  I do not see this requirement
 	## in the docs, and it impairs the ability to boot-test a copy