diff --git a/Makefile.inc1 b/Makefile.inc1 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -2146,10 +2146,12 @@ ${_+_}@cd ${.CURDIR}; \ ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld -stage-packages-kernel: .PHONY - @mkdir -p ${KSTAGEDIR} +${KSTAGEDIR}: + @mkdir -p "${KSTAGEDIR}" + +stage-packages-kernel: ${KSTAGEDIR} .PHONY ${_+_}@cd ${.CURDIR}; \ - ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel + ${MAKE} DESTDIR=${KSTAGEDIR} NO_INSTALLKERNEL=yes -DNO_ROOT stagekernel stage-packages-source: .PHONY @mkdir -p ${SSTAGEDIR}; @@ -2308,14 +2310,11 @@ || exit 1; \ done -_default_flavor= -default -.if make(*package*) && exists(${KSTAGEDIR}/kernel.meta) -. if ${MK_DEBUG_FILES} != "no" -_debug=-dbg -. endif - +# Create DTBs for systems that use them, mainly ARM. These are always +# installed in /boot/dtb rather than a kernel-specific directory, so +# we just take the files from the first kernel we built. create-dtb-package: .PHONY - @if [ -f ${KSTAGEDIR}/${DISTDIR}/dtb.plist ]; then \ +.if exists(${KSTAGEDIR}/kernel.${BUILDKERNELS:[1]}/dtb.plist) ${SRCDIR}/release/packages/generate-ucl.lua \ PKGNAME "dtb" \ PKGGENNAME "dtb" \ @@ -2325,102 +2324,91 @@ PKG_WWW "${PKG_WWW}" \ UCLFILES "${SRCDIR}/release/packages/ucl" \ ${SRCDIR}/release/packages/template.ucl \ - ${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \ + ${KSTAGEDIR}/kernel.${BUILDKERNELS:[1]}/dtb.ucl awk -F\" ' \ /name/ { printf("===> Creating %s-", $$2); next } \ /version/ {print $$2; next } ' \ - ${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \ + ${KSTAGEDIR}/kernel.${BUILDKERNELS:[1]}/dtb.ucl ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \ -o OSVERSION="${SRCRELDATE}" \ create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \ - -M ${KSTAGEDIR}/${DISTDIR}/dtb.ucl \ - -p ${KSTAGEDIR}/${DISTDIR}/dtb.plist \ - -r ${KSTAGEDIR}/${DISTDIR} \ - -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} ; \ - fi + -M ${KSTAGEDIR}/kernel.${BUILDKERNELS:[1]}/dtb.ucl \ + -p ${KSTAGEDIR}/kernel.${BUILDKERNELS:[1]}/dtb.plist \ + -r ${KSTAGEDIR}/kernel.${BUILDKERNELS:[1]} \ + -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} +.endif # exists(dtb.plist) + +create-kernel-packages: .PHONY real-create-kernel-packages create-dtb-package +real-create-kernel-packages: .PHONY +.ORDER: real-create-kernel-packages create-dtb-package + +.for _kernel in ${BUILDKERNELS} +# Generate the UCL plist for a kernel. This produces UCL for both the +# kernel package itself and its companion -dbg package. +create-kernel-plist-${_kernel}: .PHONY + rm -f ${KSTAGEDIR}/kernel.${_kernel}/kernel.plist + rm -f ${KSTAGEDIR}/kernel.${_kernel}/kernel-dbg.plist + cd ${KSTAGEDIR}/kernel.${_kernel} && \ + ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.${_kernel}.meta | \ + awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk -v kernel=yes -create-kernel-packages: .PHONY create-kernel-flavored-packages create-dtb-package -create-kernel-flavored-packages: .PHONY -.ORDER: create-kernel-flavored-packages create-dtb-package - -. for flavor in "" ${_debug} -create-kernel-flavored-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} -create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY - @cd ${KSTAGEDIR}/${DISTDIR} ; \ - ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.meta | \ - awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ - -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \ +# Build a package for a single kernel, which has already been installed +# into ${KSTAGEDIR}/kernel.${_kernel}. +real-create-kernel-packages: real-create-kernel-packages-${_kernel} +real-create-kernel-packages-${_kernel}: create-kernel-plist-${_kernel} ${SRCDIR}/release/packages/generate-ucl.lua \ - PKGNAME "kernel-${INSTALLKERNEL:tl}${flavor}" \ + PKGNAME "kernel-${_kernel:tl}" \ PKGGENNAME "kernel" \ VERSION "${PKG_VERSION}" \ - KERNELDIR "kernel" \ - KERNEL_NAME "${INSTALLKERNEL}" \ - KERNEL_FLAVOR "${flavor}" \ + KERNEL_NAME "${_kernel}" \ + KERNELDIR "kernel.${_kernel}" \ PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ PKG_MAINTAINER "${PKG_MAINTAINER}" \ PKG_WWW "${PKG_WWW}" \ UCLFILES "${SRCDIR}/release/packages/ucl" \ ${SRCDIR}/release/packages/template.ucl \ - ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ + ${KSTAGEDIR}/kernel.${_kernel}/kernel.ucl awk -F\" ' \ - /name/ { printf("===> Creating %s-", $$2); next } \ - /version/ {print $$2; next } ' \ - ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ + /^name/ { printf("===> Creating %s-", $$2); next } \ + /^version/ {print $$2; next } ' \ + ${KSTAGEDIR}/kernel.${_kernel}/kernel.ucl ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \ -o OSVERSION="${SRCRELDATE}" \ create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \ - -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \ - -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \ - -r ${KSTAGEDIR}/${DISTDIR} \ + -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.ucl \ + -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.plist \ + -r ${KSTAGEDIR}/kernel.${_kernel} \ -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} -. endfor -.else -create-kernel-packages: .PHONY -.endif -.if !empty(INSTALLEXTRAKERNELS) -.for _kernel in ${INSTALLEXTRAKERNELS} -. if exists(${KSTAGEDIR}/kernel.${_kernel}.meta) -. if ${MK_DEBUG_FILES} != "no" -_debug=-dbg -. endif -. for flavor in "" ${_debug} -create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel} -create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY - @cd ${KSTAGEDIR}/kernel.${_kernel} ; \ - ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.${_kernel}.meta | \ - awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ - -v kernel=yes -v _kernconf=${_kernel} ; \ +.if ${MK_DEBUG_FILES} != "no" +# Build the -dbg package which contains the debugging symbols for the kernel. +real-create-kernel-packages: real-create-kernel-packages-${_kernel}-dbg +real-create-kernel-packages-${_kernel}-dbg: create-kernel-plist-${_kernel} ${SRCDIR}/release/packages/generate-ucl.lua \ - PKGNAME "kernel-${_kernel:tl}${flavor}" \ - PKGGENNAME "kernel" \ - FORCEINCLUDE "kernel${flavor}" \ + PKGNAME "kernel-${_kernel:tl}-dbg" \ + PKGGENNAME "kernel-dbg" \ VERSION "${PKG_VERSION}" \ - KERNEL_NAME "${_kernel:tl}" \ - KERNEL_FLAVOR "${flavor}" \ + KERNEL_NAME "${_kernel}" \ KERNELDIR "kernel.${_kernel}" \ PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ PKG_MAINTAINER "${PKG_MAINTAINER}" \ PKG_WWW "${PKG_WWW}" \ UCLFILES "${SRCDIR}/release/packages/ucl" \ ${SRCDIR}/release/packages/template.ucl \ - ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \ + ${KSTAGEDIR}/kernel.${_kernel}/kernel-dbg.ucl; \ awk -F\" ' \ /name/ { printf("===> Creating %s-", $$2); next } \ /version/ {print $$2; next } ' \ - ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \ + ${KSTAGEDIR}/kernel.${_kernel}/kernel-dbg.ucl ; \ ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \ -o OSVERSION="${SRCRELDATE}" \ create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \ - -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \ - -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \ + -M ${KSTAGEDIR}/kernel.${_kernel}/kernel-dbg.ucl \ + -p ${KSTAGEDIR}/kernel.${_kernel}/kernel-dbg.plist \ -r ${KSTAGEDIR}/kernel.${_kernel} \ -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} -. endfor -. endif -. endfor -.endif +.endif # ${MK_DEBUG_FILES} != "no" +.endfor # _kernel in ${BUILDKERNELS} sign-packages: .PHONY ${_+_}@cd ${.CURDIR}; \ diff --git a/UPDATING b/UPDATING --- a/UPDATING +++ b/UPDATING @@ -27,6 +27,20 @@ world, or to merely disable the most expensive debugging functionality at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20260106: + Packaged kernels will now always be installed in /boot/kernel.NAME, + rather than the first built kernel (usually GENERIC) being installed + in /boot/kernel. To avoid breaking existing bootloader configurations, + a symlink will be maintained at /boot/kernel pointing to an installed + kernel. After updating, you may want to check that the symlink looks + correct, and/or update explicitly set "kernel" in /boot/loader.conf. + + For powerpc64le users, the symlink will not be created since /boot + is a FAT filesystem. Instead, you MUST edit /boot/etc/kboot.conf + to update the kernel filename. + + This change only affects pkgbase users. + 20260106: Zstd has moved to the new "zstd" package. If you have set-minimal installed, this package will be installed automatically, otherwise diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist --- a/etc/mtree/BSD.root.dist +++ b/etc/mtree/BSD.root.dist @@ -26,8 +26,6 @@ .. images .. - kernel - .. loader.conf.d .. lua diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -843,6 +843,10 @@ .. .. .. + pkg + triggers + .. + .. security .. sendmail diff --git a/release/Makefile b/release/Makefile --- a/release/Makefile +++ b/release/Makefile @@ -62,6 +62,12 @@ # installed on the target system, since fwget is supposed to handle that. RELEASE_MEDIA_EXTRA_PACKAGES?= wifi-firmware-kmod-release +# The default kernel to boot. This must be a kernel that was built as +# part of the package repository being installed on the media. +RELEASE_MEDIA_KERNEL?= kernel.GENERIC +RELEASE_MEDIA_KERNEL.powerpc64?= kernel.GENERIC64 +RELEASE_MEDIA_KERNEL.powerpc64le?= kernel.GENERIC64LE + WORLDDIR?= ${.CURDIR:H} PORTSDIR?= /usr/ports @@ -303,6 +309,7 @@ . error INSTALL_SYSTEM_MEDIATYPE must be defined . endif +_INSTALL_SYSTEM_KERNEL=${RELEASE_MEDIA_KERNEL.${TARGET_ARCH}:U${RELEASE_MEDIA_KERNEL}} _INSTALL_SYSTEM_SETS=${RELEASE_MEDIA_SETS.${INSTALL_SYSTEM_MEDIATYPE}:U${RELEASE_MEDIA_SETS}} _INSTALL_SYSTEM_PKG=\ ${PKG_CMD} \ @@ -323,6 +330,9 @@ ${RELEASE_MEDIA_PACKAGES:S/^/${PKG_NAME_PREFIX}-/} ${_INSTALL_SYSTEM_PKG} clean -ay + # Make sure loader can find the kernel to boot. + echo 'kernel="${_INSTALL_SYSTEM_KERNEL}"' >>"${INSTALL_SYSTEM_ROOT}/boot/loader.conf" + # These files are created in post-install scripts and pkg doesn't # currently support adding those to METALOG, so we need to do that # ourselves. diff --git a/release/packages/generate-ucl.lua b/release/packages/generate-ucl.lua --- a/release/packages/generate-ucl.lua +++ b/release/packages/generate-ucl.lua @@ -111,7 +111,7 @@ if pkgname:match("%-lib$") ~= nil then return false end - if pkggenname == "kernel" then + if pkggenname == "kernel" or pkggenname == "kernel-dbg" then return false end diff --git a/release/packages/ucl/kernel-all.ucl b/release/packages/ucl/kernel-all.ucl --- a/release/packages/ucl/kernel-all.ucl +++ b/release/packages/ucl/kernel-all.ucl @@ -1,9 +1,21 @@ -comment = "FreeBSD ${KERNEL_NAME} Kernel ${KERNEL_FLAVOR}" +comment = "FreeBSD ${KERNEL_NAME} kernel" desc = < + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +comment = "Kernel packaging support" + +desc = < diff --git a/share/pkg/kernel-link.ucl b/share/pkg/kernel-link.ucl new file mode 100644 --- /dev/null +++ b/share/pkg/kernel-link.ucl @@ -0,0 +1,197 @@ +/* + * SPDX-License-Identifier: ISC + * + * Copyright (c) 2025 Lexi Winter + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Kernel package handling. We maintain /boot/kernel as a symlink to + * an installed kernel as follows: + * + * (1) If /boot/kernel is a non-empty directory, do nothing. We assume + * the user is managing the default kernel themselves. + * + * (2) If /boot/kernel is an empty directory, remove it. This can happen + * when switching from old-style kernel naming to the new kernel.NAME + * style, and we need to handle this case to avoid breaking the system. + * + * If we are still running at this point, then /boot/kernel either does + * not exist, or is a symlink. + * + * (3) If it is a symlink, and the symlink target exists, do nothing. + * This allows the user to manually change which kernel the symlink + * points at. + * + * (4) If it doesn't exist, or it's a symlink and the symlink target + * doesn't exist, create it as a symlink to an installed kernel. + */ + +path_glob: [ + "/boot/kernel.*", +] + +trigger: { + type: lua + sandbox: false + script: <