[Bug 290393] 15.0-BETA4: pkg blocks boot process waiting for console input

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 02 Nov 2025 12:41:30 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=290393

--- Comment #4 from Jimmy Olgeni <olgeni@FreeBSD.org> ---
Made a quick experiment to get some more info. This put it back into shape:

==========
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh
b/usr.sbin/freebsd-update/freebsd-update.sh
index 7815502dba39..85ed026b6aae 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -667,9 +667,15 @@ upgrade_check_kmod_ports() {
        local report
        local w

-       if ! pkg -N 2>/dev/null; then
-               echo "Skipping kernel modules check. pkg(8) not present."
-               return
+       # Check if the real pkg binary exists (not just the bootstrap wrapper)
+       # /usr/sbin/pkg is the bootstrap wrapper, /usr/local/sbin/pkg is the
real pkg
+       if [ ! -x /usr/local/sbin/pkg ]; then
+               echo "pkg is not bootstrapped. Attempting to bootstrap..."
+               if ! env ASSUME_ALWAYS_YES=yes pkg bootstrap >/dev/null 2>&1;
then
+                       echo "Failed to bootstrap pkg. Skipping kernel modules
check."
+                       return
+               fi
+               echo "pkg successfully bootstrapped."
        fi

        # Most modules are in /boot/modules but we should actually look
@@ -1102,13 +1108,23 @@ IDS_check_params () {
 # Return 0 if the system is managed using pkgbase, 1 otherwise.
 check_pkgbase()
 {
-       # Packaged base requires that pkg is bootstrapped.
-       if ! pkg -r ${BASEDIR} -N >/dev/null 2>/dev/null; then
+       # Check if the real pkg binary exists (not just the bootstrap wrapper)
+       # /usr/sbin/pkg is the bootstrap wrapper, /usr/local/sbin/pkg is the
real pkg
+       if [ ! -x "${BASEDIR}/usr/local/sbin/pkg" ]; then
+               # pkg is not bootstrapped, attempt to bootstrap it
non-interactively
+               if ! env ASSUME_ALWAYS_YES=yes pkg -r ${BASEDIR} bootstrap
>/dev/null 2>&1; then
+                       return 1
+               fi
+       fi
+
+       # Verify pkg is functional
+       if ! pkg -N >/dev/null 2>&1; then
                return 1
        fi
+
        # uname(1) is used by pkg to determine ABI, so it should exist.
        # If it comes from a package then this system uses packaged base.
-       if ! pkg -r ${BASEDIR} which /usr/bin/uname >/dev/null; then
+       if ! pkg -r ${BASEDIR} which /usr/bin/uname >/dev/null 2>&1; then
                return 1
        fi
        return 0
==========

Then I found the issue! :D

root@freebsd-15:/usr/sbin # pkg -N
pkg: pkg is not installed
root@freebsd-15:/usr/sbin # pkg -N -r /
pkg: pkg is not installed
root@freebsd-15:/usr/sbin # pkg -r / -N
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]:

-N is not happy about the positioning of -r, so the "pkg -r ${BASEDIR} -N" is
causing the hang.

-- 
You are receiving this mail because:
You are on the CC list for the bug.