mirror of
https://git.freebsd.org/src.git
synced 2026-01-16 23:02:24 +00:00
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
This commit is contained in:
parent
bcdef9d68a
commit
012014403b
1 changed files with 35 additions and 31 deletions
|
|
@ -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
|
||||
fi
|
||||
while read DIR; do
|
||||
metalog_add_data ${DIR}
|
||||
done < ${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
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
case "${VMFS}" in
|
||||
ufs)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue