From nobody Mon Jan 5 17:59:07 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dlMW022Ybz6MqQt for ; Mon, 05 Jan 2026 17:59:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dlMVz6HQRz4BrN for ; Mon, 05 Jan 2026 17:59:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767635947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iJcLvT7e7s+Emn+EAmpBlzs3Z6RB4nBb7YHXEuPRGgE=; b=KpUfw44JyCfBr+rTyeBuJkgI0dMzEfGZrgCsdTOWU2YLLR6HLSiaj9EFV2dE0cFieZqRNq jQjv9YTATT8eCbSSeIuUc2BSG3eF8mr9QGRepxwdLDRzJaX69ZoberbRhzAUM26EUKW3NG R3clXbxh1FA02556v51JqatF+tNe+MtxIAJsT27qmoWWh1rfgq3MvsfUh2dG0aXULMLAFv pnOwHocR8jWEB7q7OwNqUCzTEtH8597bhhBF8cky7uORVboAXVy0sUqmrSB0k+tas71F+1 912FcjDhz4TS8dtsOClC01N59Lk50X9i9vsN1HZXybBnEkbLtFazs5w3cKez6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767635947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iJcLvT7e7s+Emn+EAmpBlzs3Z6RB4nBb7YHXEuPRGgE=; b=THBDHLJTOhonycSxmX76m7HMFXJMJVabGzgPjKG4Nr6UUAcWhRpXfSxdkOQYq/bv+gce4X 8CUv9FV0RWxVNVcORA0UikQXW0XKtX9grp7ifiaIexSNCvZ2ek3IDoEyiWxwsEqtu5qQ+n 8GJs8vyUHEWsqCSAcub3S3tPkzgvQ18fa3OUT64Q7IXobyn4X4vQ37oLLmsyW5dVBM7G7U j+cxcVN1nqTLDnjPkNpZqQxaMey/PxqM8jWyyOsjyBIG9sFniopTUfBXfCXpgq5cYHHlrz ejxa5Ie6vmgohU6PTjdZKLjwmCHecSy/zKXlvacQhhSNo7Rl4FDiL9rpxmHLuQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767635947; a=rsa-sha256; cv=none; b=YSG6Nngvia2L29yVmvCdZEh+z6Y0McPChTihm3m1+SZvWtX7VK2nCP+9oPQpSz98oLkzoO bUqcKzop1Kt2k3jwXHJO3X5sD6nIAnI22IlloW0255bzYWUxpdRj7zW9nS8Ug3fAzeFjMd r244zvkbl4o2DiJpZ4fAtq5WBxZSAUswpSDssXWEX+ezmI1ZBHIGJ+UOrbYdlJMnKnm1UZ hQW9bWAIFtWXfUXr4KnZOIYVN5QKzNjt14BN6XTWPMW3vdXJapbxFIBjXnGD8GLUR0+S5C Fberq30wA2e3ZW/7MbKhgn2sTSL0/f1DTfBNlH2YbXwIjCwU0CVlBNqfQoWRbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dlMVz5GLtzWH6 for ; Mon, 05 Jan 2026 17:59:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32a44 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 05 Jan 2026 17:59:07 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lexi Winter Subject: git: 89c017d06870 - main - Makefile.inc1: Allow safe installkernel with pkgbase List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ivy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 89c017d068704c2bc3da9cb22f43da17a9ce8c24 Auto-Submitted: auto-generated Date: Mon, 05 Jan 2026 17:59:07 +0000 Message-Id: <695bfbeb.32a44.fb6c48b@gitrepo.freebsd.org> The branch main has been updated by ivy: URL: https://cgit.FreeBSD.org/src/commit/?id=89c017d068704c2bc3da9cb22f43da17a9ce8c24 commit 89c017d068704c2bc3da9cb22f43da17a9ce8c24 Author: Lexi Winter AuthorDate: 2026-01-05 17:39:47 +0000 Commit: Lexi Winter CommitDate: 2026-01-05 17:39:47 +0000 Makefile.inc1: Allow safe installkernel with pkgbase Commit 74a6bb524e5b added a check to install{world,kernel} to avoid people accidentally running this on pkgbase systems and leaving their system broken. This had two issues: (1) The warning was not sufficiently scary, leading people to think this was safe to do as long as they set DESTDIR=/. (2) The installkernel check was too strict, and prevented installing kernels that don't conflict with packaged kernels. Fix (1) by rewording the warning to be scarier, and while here, add two new variables (ALLOW_PKGBASE_INSTALL{WORLD,KERNEL}) which could be set in /etc/make.conf for people who want to break their systems by default. Fix (2) by improving the installkernel check to see if the kernel(s) we're actually installing are packaged. This means a new kernel can be installed to /boot/kernel as long as there's no packaged kernel installed there. This check understands INSTKERNNAME, so if there is a packaged kernel in /boot/kernel, the new kernel can still be installed using INSTKERNNAME=testkernel (or whatever). MFC after: 2 weeks Reported by: christos, jhb, others Reviewed by: emaste, christos (previous version) Sponsored by: https://www.patreon.com/bsdivy Differential Revision: https://reviews.freebsd.org/D54346 --- Makefile.inc1 | 83 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index a6181b78125b..b8f59686784d 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1356,28 +1356,6 @@ __installcheck_DESTDIR: .PHONY .endif .endif -# -# Don't allow installworld or installkernel on a pkgbase system. This avoids -# accidentally updating a pkgbase system with install{world,kernel}, causing -# the installed system to become out of date with the package database. -# -# Skip the check if DESTDIR is defined on the assumption the user knows what -# they're doing. This means the check can be disabled for the running system -# using DESTDIR=/. -# -.if !make(distributeworld) && !defined(DESTDIR) -_installcheck_world: __installcheck_PKG -_installcheck_kernel: __installcheck_PKG -__installcheck_PKG: .PHONY -.if exists(${LOCALBASE}/sbin/pkg-static) - @if ${LOCALBASE}/sbin/pkg-static info -e ${PKG_NAME_PREFIX}-runtime; then \ - echo >&2 "ERROR: This target should not be used on a system installed from packages." ; \ - echo >&2 " To override this check, set DESTDIR=/."; \ - false; \ - fi -.endif -.endif - .if !defined(DB_FROM_SRC) # # Check for missing UIDs/GIDs. @@ -1873,6 +1851,67 @@ INSTALLEXTRAKERNELS= ${BUILDKERNELS:[2..-1]} .endif .endif +# +# Don't allow installworld or installkernel on a pkgbase system. This avoids +# accidentally updating a pkgbase system with install{world,kernel}, causing +# the installed system to become out of date with the package database. +# +# Skip the check if DESTDIR is defined on the assumption the user knows what +# they're doing. This means the check can be disabled for the running system +# using DESTDIR=/. +# +# People who want to disable this check permanently may set two variables in +# /etc/make.conf, ALLOW_PKGBASE_INSTALLKERNEL and ALLOW_PKGBASE_INSTALLWORLD, +# to disable these checks. That doesn't stop this from breaking your system, +# it just stops make from warning about it. +# +.if !make(distributeworld) && !defined(DESTDIR) + +. if !defined(ALLOW_PKGBASE_INSTALLKERNEL) && exists(${LOCALBASE}/sbin/pkg-static) +# For installkernel, we check if this specific kernel was installed by pkg. +# This means people can continue to use installkernel for non-packaged +# kernels, which is useful for development. + +_installcheck_kernel: __installcheck_kernel_pkgbase +__installcheck_kernel_pkgbase: .PHONY +. for _kernel in ${NO_INSTALLKERNEL:D:U${INSTKERNNAME}} \ + ${INSTALLEXTRAKERNELS:S/^/${INSTKERNNAME}./} + @if ${LOCALBASE}/sbin/pkg-static which /boot/${_kernel}/kernel \ + >/dev/null 2>&1; then \ + echo >&2 "ERROR: The kernel at /boot/${_kernel} was installed from packages." ; \ + echo >&2 " A packaged kernel should never be updated using installkernel;" ; \ + echo >&2 " this will cause the package database to become out of sync with" ; \ + echo >&2 " the live system state. Either uninstall the packaged kernel," ; \ + echo >&2 " or install this kernel to a different path using INSTKERNNAME." ; \ + echo >&2 "" ; \ + echo >&2 " If you understand the risks and wish to proceed anyway, you may" ; \ + echo >&2 " set ALLOW_PKGBASE_INSTALLKERNEL=yes to override this safety check." ; \ + echo >&2 " After doing so, you should not use the pkg(8) utility until you" ; \ + echo >&2 " have resolved the inconsistency between the installed system and" ; \ + echo >&2 " the package database." ; \ + false; \ + fi +. endfor +. endif # !defined(ALLOW_PKGBASE_INSTALLKERNEL) && exists(pkg-static) + +. if !defined(ALLOW_PKGBASE_INSTALLWORLD) && exists(${LOCALBASE}/sbin/pkg-static) +_installcheck_world: __installcheck_world_pkgbase +__installcheck_world_pkgbase: .PHONY + @if ${LOCALBASE}/sbin/pkg-static info -e ${PKG_NAME_PREFIX}-runtime; then \ + echo >&2 "ERROR: This target should never be used on a system installed from packages;" ; \ + echo >&2 " doing so will cause the package database to become out of sync with" ; \ + echo >&2 " the live system state." ; \ + echo >&2 "" ; \ + echo >&2 " If you understand the risks and wish to proceed anyway, you may" ; \ + echo >&2 " set ALLOW_PKGBASE_INSTALLWORLD=yes to override this safety check." ; \ + echo >&2 " After doing so, you should not use the pkg(8) utility until you" ; \ + echo >&2 " have resolved the inconsistency between the installed system and" ; \ + echo >&2 " the package database." ; \ + false; \ + fi +. endif # !defined(ALLOW_PKGBASE_INSTALLWORLD) && exists(pkg-static) +.endif # !make(distributeworld) && !defined(DESTDIR) + # # installkernel, etc. #