git: 53a3d4760eb9 - main - etcupdate: Warn if the tree hasn't been built

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Mon, 22 Jun 2026 19:00:01 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=53a3d4760eb90c89bf04636c957511882d7f347d

commit 53a3d4760eb90c89bf04636c957511882d7f347d
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-06-22 18:59:18 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-22 18:59:41 +0000

    etcupdate: Warn if the tree hasn't been built
    
    Warn the user before trying `make installetc` if etcupdate was invoked
    without -b (or with -B) and it appears that `make buildetc` hasn't
    already been run (which usually happens as part of `make buildworld`).
    
    MFC after:      1 week
    Reviewed by:    jhb
    Differential Revision:  https://reviews.freebsd.org/D57504
---
 usr.sbin/etcupdate/etcupdate.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh
index 404ad434da00..4743e81a1562 100755
--- a/usr.sbin/etcupdate/etcupdate.sh
+++ b/usr.sbin/etcupdate/etcupdate.sh
@@ -200,6 +200,7 @@ build_tree()
 
 	log "Building tree at $1 with $make"
 
+	exec 4>&2
 	exec >&3 2>&1
 
 	mkdir -p $1/usr/obj
@@ -216,7 +217,16 @@ build_tree()
 	else
 		(
 			cd $SRCDIR || exit 1
-			if ! [ -n "$nobuild" ]; then
+			if [ -n "$nobuild" ]; then
+				# Check for prior build
+				objdir=$($make -V .OBJDIR)
+				if ! [ -f "${objdir}/${BUILD_SENTINEL}" ]; then
+					cat <<EOF >&4
+Build sentinel not found in object directory, did you forget to make
+buildworld or pass -b to etcupdate?
+EOF
+				fi
+			else
 				export MAKEOBJDIRPREFIX=$destdir/usr/obj
 				if [ -n "$($make -V.ALLTARGETS:Mbuildetc)" ]; then
 					$make buildetc || exit 1
@@ -1900,6 +1910,9 @@ EDITOR=${EDITOR:-/usr/bin/vi}
 # Files that need to be updated before installworld.
 PREWORLD_FILES="etc/master.passwd etc/group"
 
+# A file we know the build produces in the object directory.
+BUILD_SENTINEL=etc/termcap/termcap.small
+
 # Handle command-specific argument processing such as complaining
 # about unsupported options.  Since the configuration file is always
 # included, do not complain about extra command line arguments that