git: dbe26fafc618 - releng/15.0 - vmimage.subr: Log pkg/local.sqlite if pkgbase

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

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

commit dbe26fafc6185ef3de2f2cb7034c129e6554f6de
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-11-15 21:29:25 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-11-16 03:11:14 +0000

    vmimage.subr: Log pkg/local.sqlite if pkgbase
    
    We were doing this in vm_extra_install_packages but VM images without
    any extra packages installed would not get this installed.  This
    results in a pkgbase system which thinks it doesn't have any packages
    installed (even though all the files are right there).
    
    Add a "metalog_add_data ./var/db/pkg/local.sqlite" call to the pkgbase
    install code path, and make the call from vm_extra_install_packages
    conditional on !PKGBASE.
    
    Approved by:    re (cperciva)
    Reported by:    Michael Dexter
    MFC after:      immediately (needed for 15.0-RC1)
    
    (cherry picked from commit 10a4f2d016dccb5cfa03800bebc09a9b421c4df7)
    (cherry picked from commit 6b15dc234dc56cd65f07063c1f933c214c477120)
---
 release/tools/vmimage.subr | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index 92f00f9cf7c3..482d279e5987 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -106,6 +106,7 @@ vm_install_base() {
 		$pkg_cmd update
 		selected=$(vm_base_packages_list | vm_extra_filter_base_packages)
 		$pkg_cmd install -U -r FreeBSD-base $selected
+		metalog_add_data ./var/db/pkg/local.sqlite
 	else
 		cd ${WORLDDIR} && \
 			make DESTDIR=${DESTDIR} ${INSTALLOPTS} \
@@ -219,7 +220,9 @@ vm_extra_install_packages() {
 		    -o PKG_DBDIR=${DESTDIR}/var/db/pkg \
 		    -r ${DESTDIR} \
 		    autoremove
-		metalog_add_data ./var/db/pkg/local.sqlite
+		if [ -n "${NOPKGBASE}" ]; then
+			metalog_add_data ./var/db/pkg/local.sqlite
+		fi
 	else
 		if [ -n "${WITHOUT_QEMU}" ]; then
 			return 0