git: 2d184465e8bb - main - release: Rework VM package selection using sets

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Mon, 06 Oct 2025 19:40:21 UTC
The branch main has been updated by cperciva:

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

commit 2d184465e8bb77d4620f509b04f19ea22656f28e
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-10-06 05:25:08 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-06 19:40:07 +0000

    release: Rework VM package selection using sets
    
    Filtering the list of packages broke with the introduction of package
    sets, since we excluded FreeBSD-src.* but still included
    FreeBSD-set-src, which transitively included the FreeBSD-src and
    FreeBSD-src-sys packages.  This could be fixed by excluding package
    sets, but that would be fragile, potentially breaking upgrades if
    new packages are introduced.
    
    Instead, start with an explicit set of package sets:
            base, base-dbg
            lib32, lib32-dbg
            kernels, kernels-dbg
            tests
    and filter the package sets; the EC2 "small" and "builder" AMIs
    filter out everything except "base" and "kernels".
    
    Note that using FreeBSD-set-kernels may pose a problem in the future
    if we start shipping packages for multiple differently-configured
    kernels.  That will be addressed if and when that problem arises.
    
    Reviewed by:    ivy
    MFC after:      3 days
    Sponsored by:   https://www.patreon.com/cperciva
    Differential Revision:  https://reviews.freebsd.org/D52922
---
 release/tools/ec2-builder.conf |  2 +-
 release/tools/ec2-small.conf   |  2 +-
 release/tools/vmimage.subr     | 21 ++++++++++-----------
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/release/tools/ec2-builder.conf b/release/tools/ec2-builder.conf
index 36837fd86f9c..a55485fec0cd 100644
--- a/release/tools/ec2-builder.conf
+++ b/release/tools/ec2-builder.conf
@@ -16,7 +16,7 @@ vm_extra_filter_base_packages() {
 	grep -v \
 		-e '.*-dbg$' \
 		-e '.*-lib32$' \
-		-e '^FreeBSD-tests.*'
+		-e '^FreeBSD-set-tests'
 }
 
 # Packages to install into the image we're creating.  In addition to packages
diff --git a/release/tools/ec2-small.conf b/release/tools/ec2-small.conf
index 9b64c215d8a5..acaffbbc0c42 100644
--- a/release/tools/ec2-small.conf
+++ b/release/tools/ec2-small.conf
@@ -19,7 +19,7 @@ vm_extra_filter_base_packages() {
 	grep -v \
 		-e '.*-dbg$' \
 		-e '.*-lib32$' \
-		-e '^FreeBSD-tests.*'
+		-e '^FreeBSD-set-tests'
 }
 
 # Packages to install into the image we're creating.  In addition to packages
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index cae8a113871e..131ebe37db6c 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -70,15 +70,15 @@ vm_copy_base() {
 	return 0
 }
 
-vm_filter_base_packages() {
-	# Reads a list of all base system packages from stdin.
-	# Writes a list of base system packages to install to stdout.
-	grep -v -e '^FreeBSD-src.*' -e '^FreeBSD-kernel.*'
-	# There are several kernel variants available in separate packages.
-	# For VMs it is sufficient to install only the generic kernel.
-	echo "FreeBSD-kernel-man"
-	echo "FreeBSD-kernel-generic"
-	echo "FreeBSD-kernel-generic-dbg"
+vm_base_packages_list() {
+	# Output a list of package sets equivalent to what we get from
+	# "installworld installkernel distribution", aka. the full base
+	# system.
+	for S in base lib32 kernels; do
+		echo FreeBSD-set-$S
+		echo FreeBSD-set-$S-dbg
+	done
+	echo FreeBSD-set-tests
 }
 
 vm_extra_filter_base_packages() {
@@ -99,8 +99,7 @@ vm_install_base() {
 			pkg_cmd="$pkg_cmd -o METALOG=METALOG"
 		fi
 		$pkg_cmd update
-		selected=$($pkg_cmd rquery -U -r FreeBSD-base %n | \
-			vm_filter_base_packages | vm_extra_filter_base_packages)
+		selected=$(vm_base_packages_list | vm_extra_filter_base_packages)
 		$pkg_cmd install -U -r FreeBSD-base $selected
 	else
 		cd ${WORLDDIR} && \