diff options
Diffstat (limited to 'release/tools/vmimage.subr')
-rw-r--r-- | release/tools/vmimage.subr | 66 |
1 files changed, 54 insertions, 12 deletions
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index 27cca78be6e3..99e1936296e1 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -70,15 +70,20 @@ 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 kernels; do + echo FreeBSD-set-$S + echo FreeBSD-set-$S-dbg + done + case ${TARGET_ARCH} in + amd64 | aarch64 | powerpc64) + echo FreeBSD-set-lib32 + echo FreeBSD-set-lib32-dbg + esac + echo FreeBSD-set-tests } vm_extra_filter_base_packages() { @@ -95,12 +100,11 @@ vm_install_base() { pkg_cmd="pkg --rootdir ${DESTDIR} --repo-conf-dir ${PKGBASE_REPO_DIR} -o ASSUME_ALWAYS_YES=yes -o IGNORE_OSVERSION=yes -o ABI=${PKG_ABI} -o INSTALL_AS_USER=yes " - if -n "${NO_ROOT}" ]; then + if [ -n "${NO_ROOT}" ]; then 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} && \ @@ -256,6 +260,7 @@ vm_extra_pkg_rmcache() { if [ -n "${NO_ROOT}" ]; then ${PKG_CMD} \ -o ASSUME_ALWAYS_YES=yes \ + -o INSTALL_AS_USER=yes \ -r ${DESTDIR} \ clean -y -a else @@ -275,6 +280,43 @@ buildfs() { cat ${DESTDIR}/METALOG.pkg >> ${DESTDIR}/METALOG fi + 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 + case "${VMFS}" in ufs) cd ${DESTDIR} && ${MAKEFS} ${MAKEFSARGS} -o label=rootfs -o version=2 -o softupdates=1 \ |