Date: Thu, 29 Jan 2026 17:03:34 +0000 From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 54e006369c9a - main - release: Remove not-NO_ROOT cases Message-ID: <697b92e6.417d7.5fe8d0b9@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=54e006369c9aab4f3a22f026eb6924c0f9cafda8 commit 54e006369c9aab4f3a22f026eb6924c0f9cafda8 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2025-12-11 17:16:53 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2026-01-29 17:03:20 +0000 release: Remove not-NO_ROOT cases We always use NO_ROOT for release artifact builds, so remove the alternate code paths. For the first step we set NO_ROOT unconditionally in cases that invoke submakes, and turn NO_ROOT being unset into an error in lover-level targets so that we can catch potential out-of-tree build scripts (or missed in-tree cases) that expect to run not-NO_ROOT builds. The second step will be to remove those entirely. Reviewed by: cperciva Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54179 --- release/release.sh | 4 +- release/scripts/pkg-stage.sh | 14 +--- release/tools/azure.conf | 13 +-- release/tools/ec2.conf | 8 +- release/tools/vagrant.conf | 10 +-- release/tools/vmimage.subr | 192 ++++++++++++++++++------------------------- 6 files changed, 92 insertions(+), 149 deletions(-) diff --git a/release/release.sh b/release/release.sh index f0226e4cd3c5..480d6b34f191 100755 --- a/release/release.sh +++ b/release/release.sh @@ -200,9 +200,7 @@ env_check() { WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \ WITH_CLOUDWARE=${WITH_CLOUDWARE} WITH_OCIIMAGES=${WITH_OCIIMAGES} \ XZ_THREADS=${XZ_THREADS} NOPKGBASE=${NOPKGBASE}" - if [ -n "${NO_ROOT}" ]; then - RELEASE_RMAKEFLAGS="${RELEASE_RMAKEFLAGS} NO_ROOT=1 WITHOUT_QEMU=1" - fi + RELEASE_RMAKEFLAGS="${RELEASE_RMAKEFLAGS} NO_ROOT=1 WITHOUT_QEMU=1" return 0 } # env_check() diff --git a/release/scripts/pkg-stage.sh b/release/scripts/pkg-stage.sh index b64fe5e5f1e5..d06fc9dd1d41 100755 --- a/release/scripts/pkg-stage.sh +++ b/release/scripts/pkg-stage.sh @@ -4,8 +4,6 @@ set -e -unset NO_ROOT - export ASSUME_ALWAYS_YES="YES" export PKG_DBDIR="/tmp/pkg" export PERMISSIVE="YES" @@ -53,15 +51,13 @@ usage() while getopts N opt; do case "$opt" in - N) NO_ROOT=1 ;; + N) ;; *) usage ;; esac done PKG_ARGS="-d --rootdir ${ROOTDIR}" -if [ $NO_ROOT ]; then - PKG_ARGS="$PKG_ARGS -o INSTALL_AS_USER=1" -fi +PKG_ARGS="$PKG_ARGS -o INSTALL_AS_USER=1" PKGCMD="/usr/sbin/pkg ${PKG_ARGS}" if [ ! -x /usr/local/sbin/pkg ]; then @@ -110,10 +106,8 @@ ln -s ../All/$(${PKGCMD} rquery %n-%v pkg).pkg ${LATEST_DIR}/pkg.pkg ${PKGCMD} repo ${PKG_REPODIR} -if [ $NO_ROOT ]; then - mtree -c -p $ROOTDIR | mtree -C -k type,mode,link,size | \ - grep '^./packages[/ ]' >> $ROOTDIR/METALOG -fi +mtree -c -p $ROOTDIR | mtree -C -k type,mode,link,size | \ + grep '^./packages[/ ]' >> $ROOTDIR/METALOG # Always exit '0', even if pkg(8) complains about conflicts. exit 0 diff --git a/release/tools/azure.conf b/release/tools/azure.conf index 4fa6ba4d924d..7a4f0b5027cf 100644 --- a/release/tools/azure.conf +++ b/release/tools/azure.conf @@ -34,17 +34,8 @@ vm_extra_pre_umount() { # builds this is unnecessary as pkg will not be installed to # begin with. if [ -z "${NO_ROOT}" ]; then - mount -t devfs devfs ${DESTDIR}/dev - - # The firstboot_pkgs rc.d script will download the repository - # catalogue and install or update pkg when the instance first - # launches, so these files would just be replaced anyway; removing - # them from the image allows it to boot faster. - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ - /usr/sbin/pkg delete -f -y pkg - umount ${DESTDIR}/dev - rm -r ${DESTDIR}/var/db/pkg/repos/FreeBSD-ports - rm -r ${DESTDIR}/var/db/pkg/repos/FreeBSD-ports-kmods + echo "ERROR: NO_ROOT not set" >&2 + exit 1 fi pw -R ${DESTDIR} usermod root -h - diff --git a/release/tools/ec2.conf b/release/tools/ec2.conf index 335db6cca93a..744ac24a3f0f 100644 --- a/release/tools/ec2.conf +++ b/release/tools/ec2.conf @@ -26,12 +26,8 @@ ec2_common() { # unprivileged builds this is unnecessary as pkg will not be # installed to begin with. if [ -z "${NO_ROOT}" ]; then - mount -t devfs devfs ${DESTDIR}/dev - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ - /usr/sbin/pkg delete -f -y pkg - umount ${DESTDIR}/dev - rm -r ${DESTDIR}/var/db/pkg/repos/FreeBSD-ports - rm -r ${DESTDIR}/var/db/pkg/repos/FreeBSD-ports-kmods + echo "ERROR: NO_ROOT not set" >&2 + exit 1 fi # Turn off IPv6 Duplicate Address Detection; the EC2 networking diff --git a/release/tools/vagrant.conf b/release/tools/vagrant.conf index 37eff7a899ab..f14a9e8cb6fc 100644 --- a/release/tools/vagrant.conf +++ b/release/tools/vagrant.conf @@ -15,14 +15,8 @@ export VM_RC_LIST="firstboot_freebsd_update firstboot_pkgs growfs" vagrant_common () { if [ -z "${NO_ROOT}" ]; then - # The firstboot_pkgs rc.d script will download the repository - # catalogue and install or update pkg when the instance first - # launches, so these files would just be replaced anyway; - # removing them from the image allows it to boot faster. - pkg -c ${DESTDIR} clean -y -a - pkg -c ${DESTDIR} delete -f -y pkg - rm -r ${DESTDIR}/var/db/pkg/repos/FreeBSD-ports - rm -r ${DESTDIR}/var/db/pkg/repos/FreeBSD-ports-kmods + echo "ERROR: NO_ROOT not set" >&2 + exit 1 fi # Vagrant instances use DHCP to get their network configuration. diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index f7fc9906c049..3975e94913c9 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -41,21 +41,19 @@ cleanup() { metalog_add_data() { local file mode type - if [ -n "${NO_ROOT}" ]; then - file=$1 - if [ -f ${DESTDIR}/${file} ]; then - type=file - mode=${2:-0644} - elif [ -d ${DESTDIR}/${file} ]; then - type=dir - mode=${2:-0755} - else - echo "metalog_add_data: ${file} not found" >&2 - return 1 - fi - echo "${file} type=${type} uname=root gname=wheel mode=${mode}" >> \ - ${DESTDIR}/METALOG + file=$1 + if [ -f ${DESTDIR}/${file} ]; then + type=file + mode=${2:-0644} + elif [ -d ${DESTDIR}/${file} ]; then + type=dir + mode=${2:-0755} + else + echo "metalog_add_data: ${file} not found" >&2 + return 1 fi + echo "${file} type=${type} uname=root gname=wheel mode=${mode}" >> \ + ${DESTDIR}/METALOG } vm_create_base() { @@ -103,9 +101,7 @@ vm_install_base() { pkg_cmd="${PKG_CMD} --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 - pkg_cmd="$pkg_cmd -o METALOG=METALOG" - fi + pkg_cmd="$pkg_cmd -o METALOG=METALOG" $pkg_cmd update selected=$(vm_base_packages_list | vm_extra_filter_base_packages) $pkg_cmd install -U -r FreeBSD-base $selected @@ -126,14 +122,12 @@ vm_install_base() { etcupdate extract -B \ -M "TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}" \ -s ${WORLDDIR} -d ${DESTDIR}/var/db/etcupdate \ - -L /dev/stdout ${NO_ROOT:+-N} - if [ -n "${NO_ROOT}" ]; then - # Reroot etcupdate's internal METALOG to the whole tree - sed -n 's,^\.,./var/db/etcupdate/current,p' \ - ${DESTDIR}/var/db/etcupdate/current/METALOG | \ - env -i LC_COLLATE=C sort >> ${DESTDIR}/METALOG - rm ${DESTDIR}/var/db/etcupdate/current/METALOG - fi + -L /dev/stdout -N + # Reroot etcupdate's internal METALOG to the whole tree + sed -n 's,^\.,./var/db/etcupdate/current,p' \ + ${DESTDIR}/var/db/etcupdate/current/METALOG | \ + env -i LC_COLLATE=C sort >> ${DESTDIR}/METALOG + rm ${DESTDIR}/var/db/etcupdate/current/METALOG echo '# Custom /etc/fstab for FreeBSD VM images' \ > ${DESTDIR}/etc/fstab @@ -209,40 +203,25 @@ vm_extra_install_packages() { if [ -z "${VM_EXTRA_PACKAGES}" ]; then return 0 fi - if [ -n "${NO_ROOT}" ]; then - for pkg in ${VM_EXTRA_PACKAGES}; do - INSTALL_AS_USER=yes \ - ${PKG_CMD} \ - -o ABI=${PKG_ABI} \ - -o METALOG=${DESTDIR}/METALOG.pkg \ - -o REPOS_DIR=${PKG_REPOS_DIR} \ - -o PKG_DBDIR=${DESTDIR}/var/db/pkg \ - -r ${DESTDIR} \ - install -y -r ${PKG_REPO_NAME} $pkg - done + for pkg in ${VM_EXTRA_PACKAGES}; do INSTALL_AS_USER=yes \ - ${PKG_CMD} \ + ${PKG_CMD} \ -o ABI=${PKG_ABI} \ + -o METALOG=${DESTDIR}/METALOG.pkg \ -o REPOS_DIR=${PKG_REPOS_DIR} \ -o PKG_DBDIR=${DESTDIR}/var/db/pkg \ -r ${DESTDIR} \ - autoremove -y - if [ -n "${NOPKGBASE}" ]; then - metalog_add_data ./var/db/pkg/local.sqlite - fi - else - if [ -n "${WITHOUT_QEMU}" ]; then - return 0 - fi - - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ - /usr/sbin/pkg bootstrap -y - for p in ${VM_EXTRA_PACKAGES}; do - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ - /usr/sbin/pkg install -y ${p} - done - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ - /usr/sbin/pkg autoremove -y + install -y -r ${PKG_REPO_NAME} $pkg + done + INSTALL_AS_USER=yes \ + ${PKG_CMD} \ + -o ABI=${PKG_ABI} \ + -o REPOS_DIR=${PKG_REPOS_DIR} \ + -o PKG_DBDIR=${DESTDIR}/var/db/pkg \ + -r ${DESTDIR} \ + autoremove -y + if [ -n "${NOPKGBASE}" ]; then + metalog_add_data ./var/db/pkg/local.sqlite fi return 0 @@ -276,18 +255,11 @@ vm_emulation_cleanup() { } 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 - if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ - /usr/local/sbin/pkg clean -y -a - fi - fi + ${PKG_CMD} \ + -o ASSUME_ALWAYS_YES=yes \ + -o INSTALL_AS_USER=yes \ + -r ${DESTDIR} \ + clean -y -a return 0 } @@ -306,57 +278,55 @@ buildfs() { done < ${DESTDIR}/METALOG.pkg 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 + # 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 "${MISSING_METALOGS}" ]; then - # Hack to allow VM configurations to add files which - # weren't being added to METALOG appropriately. This - # is mainly a workaround for the @sample bug and it - # should go away before FreeBSD 15.1 ships. - for P in ${MISSING_METALOGS}; do - metalog_add_data ${P} - done - fi + 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 + if [ -n "${MISSING_METALOGS}" ]; then + # Hack to allow VM configurations to add files which + # weren't being added to METALOG appropriately. This + # is mainly a workaround for the @sample bug and it + # should go away before FreeBSD 15.1 ships. + for P in ${MISSING_METALOGS}; do + metalog_add_data ${P} + done 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 + case "${VMFS}" in ufs) cd ${DESTDIR} && ${MAKEFS} ${MAKEFSARGS} -o label=rootfs -o version=2 -o softupdates=1 \ - ${VMBASE} .${NO_ROOT:+/METALOG} + ${VMBASE} ./METALOG ;; zfs) cd ${DESTDIR} && ${MAKEFS} -t zfs ${MAKEFSARGS} \ @@ -376,7 +346,7 @@ buildfs() { -o fs=zroot/var/log\;setuid=off\;exec=off \ -o fs=zroot/var/mail\;atime=on \ -o fs=zroot/var/tmp\;setuid=off \ - ${VMBASE} .${NO_ROOT:+/METALOG} + ${VMBASE} ./METALOG ;; *) echo "Unexpected VMFS value '${VMFS}'"home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?697b92e6.417d7.5fe8d0b9>
