From nobody Mon Jan 5 17:59:07 2026 X-Original-To: dev-commits-src-all@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 4dlMW022Y0z6MpyT 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 4dlMVz6sBQz4B81 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=1767635948; 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=A8jLrSBK8CU8uPRRnBonhblJYkttyYTihNdwOiyrw6lDTrQrKTTO2Yn8JEnzcmwK4rx5Fg UhY1oUoogTfJQTDJxNi1TpZCAPXaSf3AcVvNSiqApYW+HEm5sOQV9YJ0XSHkDrYHlbBmLg zsbx6K6G4uQF01B9OHkYlYcOtwXksOvDM7CG2kwPGKFPQbSqbHXwq70aDQQdF9vGoAQA95 psWE79sERlbmqR9d4U8M/km7D5SjtSf+bvit+aPaB1ilPJ8LMm4YBVM2eaDOfQAGFbfxt9 aw1Zi9rDxJPaemIWNzhl93DwKpVUcoNGlMUnFGRolxaWuC6YW4iNA0MXK6TaMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767635948; 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=kpvMVkvLwWP+o04P46mSii147UMPJArOyQOZRVf1S/5KNjEzE3g/RxwdEWrY0MXxMNjWd1 XFM2lgqvmW7G7gBFl7qBFSqygO3MqmZs6PzAkPJWCE2s2I1xB8cpsyHGoYg6Teg9V28c3s QBDj7ZjLP2p/C08Cw8FLYw+CEdiEaEDfbTgYultrihbu8Y1OPK3wZb2j4WivenQ3dicag/ ZqmMicZsykKZKEdbIjR3A3ADkwsn/YyIjbMTdzzkyRDyNR6Yc0kNS5XSodAxjM6QIJJChE yr5HnxMo6BfEpY/vvYJOrn61ijyUqbr97gZu/eFp14eLth9C+SMeToDJ5NMMqg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767635948; a=rsa-sha256; cv=none; b=EP5H7B0KXjlz8vQUJvT16MVp94Cq4yyXlmoAM7JuP3+nxX/8fBZcOiNmAoJsIminOYiPkn Hop7f1S2p7Rq6DYlGL5BT0EpH9nnwbwFQ4Fq1e9inBqvD4wxrBEM86fDjXWI9nY9KPDLGf G1I3qN0dt0Ujp3TYgphzvdXd2vJsqdpeFxRxkGUxKBiw0QZ5noA3FRMpureWp4l8+goAwF 0UBCIDHFbFFlPMWnabBNkerSFcKm8KNAthydW6LO8trFgZXk4Z1v7zxRklcV4cCygZokKe 0/X4ZlPd62kMNzpuep7rxMJnATLCUu4CwmsXJE+YCPvVO1848CnRgpdDo6ikWw== 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 4dlMVz5HTvzVTW 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 all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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. #