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
This commit is contained in:
Ed Maste
2025-12-11 12:16:53 -05:00
parent 5a73302608
commit 54e006369c
6 changed files with 94 additions and 151 deletions
+1 -3
View File
@@ -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()
+4 -10
View File
@@ -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
+2 -11
View File
@@ -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 -
+2 -6
View File
@@ -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
+2 -8
View File
@@ -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.
+83 -113
View File
@@ -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
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
# 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
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}'"