git: 0007de48ce0b - main - Mk/bsd.port.mk: fix install-missing-packages without a tty

Baptiste Daroussin <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.ports
Message-ID <[email protected]>
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0007de48ce0b25666ee0af57aa213dcea1c853df

commit 0007de48ce0b25666ee0af57aa213dcea1c853df
Author:     Baptiste Daroussin <[email protected]>
AuthorDate: 2026-08-17 09:13:00 +0000
Commit:     Baptiste Daroussin <[email protected]>
CommitDate: 2026-08-17 09:15:23 +0000

    Mk/bsd.port.mk: fix install-missing-packages without a tty
    
    install-missing-packages runs xargs with -o, which reopens stdin from
    /dev/tty so that pkg can prompt interactively.  In automated or batch
    runs there is no controlling terminal, so xargs fails with "can't open
    /dev/tty: Device not configured".
    
    Make the -o flag conditional on BATCH: keep the interactive pkg prompt
    outside BATCH, and use pkg install -yA (auto-confirm) inside BATCH.
    
    PR:             267416
    Reported by:    [email protected]
---
 Mk/bsd.port.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index f65ba75dd915..137cc06a6059 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -4414,10 +4414,17 @@ missing-packages:
 	done
 
 # Install missing dependencies from package
+# Preserve the interactive pkg prompt unless running in BATCH mode, in
+# which case -o cannot reopen stdin from /dev/tty and is not wanted.
+.    if defined(BATCH)
+_INSTALL_MISSING_PKGS=	${XARGS} ${PKG_BIN} install -yA
+.    else
+_INSTALL_MISSING_PKGS=	${XARGS} -o ${PKG_BIN} install -A
+.    endif
 install-missing-packages:
 	@_dirs=$$(${MISSING-DEPENDS-LIST}); \
 	${ECHO_CMD} "$${_dirs}" | ${SED} "s%${PORTSDIR}/%%g" | \
-		${SU_CMD} "${XARGS} -o ${PKG_BIN} install -A"
+		${SU_CMD} "${_INSTALL_MISSING_PKGS}"
 
 ################################################################
 # Everything after here are internal targets and really
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.