diff --git a/Makefile.inc1 b/Makefile.inc1 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -2097,10 +2097,40 @@ ${_+_}@cd ${.CURDIR}; \ ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld +${KSTAGEDIR}: + @mkdir -p "${KSTAGEDIR}" + +# stage-packages-kernel: For each kernel defined in ${BUILDKERNELS} (which is +# ultimately derived from ${KERNCONF}), install the kernel into ${KSTAGEDIR} +# as "kernel.NAME". This is adapted from the distributekernel target, with +# some changes specific to the packaged kernel. In particular, we never +# install a kernel called "kernel" here. stage-packages-kernel: .PHONY - @mkdir -p ${KSTAGEDIR} + +.for _kernel in ${BUILDKERNELS} +stage-packages-kernel: stage-packages-kernel-${_kernel} +# Run this in a separate subshell to ensure -DNO_ROOT is in effect. +stage-packages-kernel-${_kernel}: ${KSTAGEDIR} .PHONY ${_+_}@cd ${.CURDIR}; \ - ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel + ${MAKE} -f Makefile.inc1 -DNO_ROOT \ + DESTDIR=${KSTAGEDIR}/kernel.${_kernel} \ + METALOG=${KSTAGEDIR}/kernel.${_kernel}.premeta \ + STAGE_KERNEL=${_kernel} \ + real-stage-packages-kernel +.endfor # _kernel in ${BUILDKERNELS} + +real-stage-packages-kernel: .PHONY + rm -f ${KSTAGEDIR}/kernel.${STAGE_KERNEL}.premeta + ${_+_}cd ${KRNLOBJDIR}/${STAGE_KERNEL}; \ + ${IMAKEENV} ${IMAKE_INSTALL} ${IMAKE_MTREE} PATH=${TMPPATH:Q} \ + ${MAKE} \ + KERNEL=${INSTKERNNAME}.${STAGE_KERNEL} \ + DISTBASE=/kernel.${STAGE_KERNEL} \ + install + echo "#${MTREE_MAGIC}" > ${KSTAGEDIR}/kernel.${STAGE_KERNEL}.meta + sed -e "s|^./kernel.${STAGE_KERNEL}|.|" \ + ${KSTAGEDIR}/kernel.${STAGE_KERNEL}.premeta | \ + ${METALOG_SORT_CMD} >> ${KSTAGEDIR}/kernel.${STAGE_KERNEL}.meta stage-packages-source: .PHONY @mkdir -p ${SSTAGEDIR}; @@ -2259,14 +2289,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" \ @@ -2276,102 +2303,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 ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes" -. for _kernel in ${BUILDKERNELS:[2..-1]} -. 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".) +20251218: + 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. + 20251212: Timeouts for SCSI bus probing have been drastically reduced. They are now tuneables that can be set in the boot loader should you have a 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/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: <