The branch main has been updated by cperciva:

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

commit 012014403bdcb2b3aa7ed3895079a0059204c35f
Author:     Colin Percival <[email protected]>
AuthorDate: 2025-10-19 00:27:07 +0000
Commit:     Colin Percival <[email protected]>
CommitDate: 2025-10-19 16:21:56 +0000

    vmimage.subr: Fix when/where we fix up METALOG
    
    We only need to check for unMETALOGed directories and sort the METALOG
    file if we're using it, i.e. if we're doing a NO_ROOT build.  This
    non-NO_ROOT builds by no longer bogusly writing to /METALOG*.
    
    We only need to add databases (spwd.db etc) to METALOG if we're doing
    a pkgbase-enabled NO_ROOT build; but we should always do this before
    creating the filesystem, not only if we installed extra packages (in
    vm_extra_install_packages, where that code was erroneously placed).
    This fixes non-cloud VM images, which in 15.0-BETA2 shipped without
    password databases.
    
    Reviewed by:    ivy
    MFC after:      3 days
    Sponsored by:   https://www.patreon.com/cperciva
    Differential Revision:  https://reviews.freebsd.org/D53194
---
 release/tools/vmimage.subr | 66 ++++++++++++++++++++++++----------------------
 1 file changed, 35 insertions(+), 31 deletions(-)

diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index 842a808c623e..99e1936296e1 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -213,16 +213,6 @@ 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
@@ -290,28 +280,42 @@ buildfs() {
                cat ${DESTDIR}/METALOG.pkg >> ${DESTDIR}/METALOG
        fi
 
-       # Check for any directories in the staging tree which weren't
-       # recorded in METALOG, and record them now.  This is a quick hack
-       # to avoid creating unusable VM images and should go away once
-       # the bugs which produce such unlogged directories are gone.
-       grep type=dir ${DESTDIR}/METALOG |
-           cut -f 1 -d ' ' |
-           sort -u > ${DESTDIR}/METALOG.dirs
-       ( cd ${DESTDIR} && find . -type d ) |
-           sort |
-           comm -23 - ${DESTDIR}/METALOG.dirs > ${DESTDIR}/METALOG.missingdirs
-       if [ -s ${DESTDIR}/METALOG.missingdirs ]; then
-               echo "WARNING: Directories exist but were not in METALOG"
-               cat ${DESTDIR}/METALOG.missingdirs
+       if [ -n "${NO_ROOT}" ]; then
+               # Check for any directories in the staging tree which weren't
+               # recorded in METALOG, and record them now.  This is a quick 
hack
+               # to avoid creating unusable VM images and should go away once
+               # the bugs which produce such unlogged directories are gone.
+               grep type=dir ${DESTDIR}/METALOG |
+                   cut -f 1 -d ' ' |
+                   sort -u > ${DESTDIR}/METALOG.dirs
+               ( cd ${DESTDIR} && find . -type d ) |
+                   sort |
+                   comm -23 - ${DESTDIR}/METALOG.dirs > 
${DESTDIR}/METALOG.missingdirs
+               if [ -s ${DESTDIR}/METALOG.missingdirs ]; then
+                       echo "WARNING: Directories exist but were not in 
METALOG"
+                       cat ${DESTDIR}/METALOG.missingdirs
+               fi
+               while read DIR; do
+                       metalog_add_data ${DIR}
+               done < ${DESTDIR}/METALOG.missingdirs
+
+               if [ -z "${NOPKGBASE}" ]; then
+                       # 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
+               fi
+
+               # Sort METALOG file; makefs produces directories with 000 
permissions
+               # if their contents are seen before the directories themselves.
+               env -i LC_COLLATE=C sort -u ${DESTDIR}/METALOG > 
${DESTDIR}/METALOG.sorted
+               mv ${DESTDIR}/METALOG.sorted ${DESTDIR}/METALOG
        fi
-       while read DIR; do
-               metalog_add_data ${DIR}
-       done < ${DESTDIR}/METALOG.missingdirs
-
-       # Sort METALOG file; makefs produces directories with 000 permissions
-       # if their contents are seen before the directories themselves.
-       env -i LC_COLLATE=C sort -u ${DESTDIR}/METALOG > 
${DESTDIR}/METALOG.sorted
-       mv ${DESTDIR}/METALOG.sorted ${DESTDIR}/METALOG
 
        case "${VMFS}" in
        ufs)

Reply via email to