git: b1303ed6369d - releng/15.0 - vmimage.subr: metalog_add generated databases

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Sat, 11 Oct 2025 00:05:37 UTC
The branch releng/15.0 has been updated by cperciva:

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

commit b1303ed6369d92cb19667b71ad60ca282c1b6441
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-10-10 22:01:38 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-11 00:05:16 +0000

    vmimage.subr: metalog_add generated databases
    
    The files /etc/login.conf.db, /etc/passwd, /etc/pwd.db, /etc/spwd.db,
    and /var/db/services.db are generated at install time.  When VM images
    are built using installworld, there is Makefile code which emits the
    necessary METALOG lines; but the pkgbase triggers do not do this.  This
    resulted in VM images which lacked these essential database files.
    
    VM images are currently the only place where this matters, since this
    issue is specific to non-root image builds uusing pkgbase.  (In some
    point in the future we will start building release ISO iamges from
    pkgbase, at which point it will be a problem there as well.)
    
    The long-term solution for this is probably to teach the relevant
    database-creating tools to emit METALOG lines; but for now, just log
    the necessary files from vmimage.subr.
    
    Approved by:    re (cperciva)
    Reviewed by:    dch
    MFC after:      5 minutes
    Sponsored by:   https://www.patreon.com/cperciva
    Differential Revision:  https://reviews.freebsd.org/D53034
    
    (cherry picked from commit 6081365c27e68707ad25c98159e364ee90fcf5db)
    (cherry picked from commit b3c5c7d6f10433497fe66447a22e6184a8e1341f)
---
 release/tools/vmimage.subr | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index 067eb5ea48a8..15c4dd53e70b 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -213,6 +213,16 @@ vm_extra_install_packages() {
 			    install -y -r ${PKG_REPO_NAME} $pkg
 		done
 		metalog_add_data ./var/db/pkg/local.sqlite
+
+		# Add some database files which are created by pkg triggers;
+		# at some point in the future the tools which create these
+		# files should probably learn how to record them in METALOG
+		# (which would simplify no-root installworld as well).
+		metalog_add_data ./etc/login.conf.db
+		metalog_add_data ./etc/passwd
+		metalog_add_data ./etc/pwd.db
+		metalog_add_data ./etc/spwd.db 600
+		metalog_add_data ./var/db/services.db
 	else
 		if [ -n "${WITHOUT_QEMU}" ]; then
 			return 0