Openembedded Core Discussions
 help / color / mirror / Atom feed
From: bruce.ashfield@gmail.com
To: Richard Purdie <richard.purdie@linuxfoundation.org>,
	Adrian Freihofer <adrian.freihofer@siemens.com>
Cc: openembedded-core@lists.openembedded.org
Subject: [OE-core][RFC PATCH 05/08] kernel-devsrc: optionally version the package
Date: Fri,  6 Nov 2026 12:32:32 -0500	[thread overview]
Message-ID: <20261106173235.4155305-6-bruce.ashfield@gmail.com> (raw)
In-Reply-To: <20261106173235.4155305-1-bruce.ashfield@gmail.com>

From: Bruce Ashfield <bruce.ashfield@gmail.com>

kernel-devsrc is one package name for every kernel version, so the trees
of two kernel versions can't be installed side by side (an upgrade
replaces the old one).

The tree itself is already versioned (/lib/modules/<version>/build), only
the /usr/src/kernel link is shared. So add KERNELDEV_VERSIONED_PACKAGE.
When it is "1", the tree is packaged as kernel-devsrc-<version>, and
kernel-devsrc keeps only the link and depends on the version it points
at, the way the kernel's kernel-image and kernel-modules packages depend
on their versioned packages.

The link stays a packaged file, so installing or upgrading kernel-devsrc
moves it with no postinst or postrm, and nothing has to run at rootfs
time. The debug info always records /usr/src/kernel, so the link pointing
at the current kernel is what debuggers expect; an older version installed
directly is reached through its own /lib/modules/<version>/source.
Anything that looks for kernel-devsrc by name (OEHasPackage in the
kernelmodule and stap runtime tests, IMAGE_INSTALL, the SDK) still finds
it.

The 'build' RDEPENDS go on the versioned package too, so a tree installed
on its own still has what it needs to build modules.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
 meta/recipes-kernel/linux/kernel-devsrc.bb | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 46337bd79b..c2021002d4 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -59,6 +59,14 @@ KERNELDEV_SOURCE_SPINE ?= "block certs crypto fs include init io_uring ipc kerne
 
 KERNEL_BUILD_ROOT = "${nonarch_base_libdir}/modules/"
 
+# Set to "1" to package the tree as kernel-devsrc-<kernel version>, so the
+# trees of two kernel versions can be installed side by side. kernel-devsrc
+# then only holds the /usr/src/kernel link and depends on the version it
+# points at, like the kernel's own kernel-image/kernel-modules packages.
+# Installing or upgrading kernel-devsrc moves the link to that version, and
+# anything that looks for kernel-devsrc by name still finds it.
+KERNELDEV_VERSIONED_PACKAGE ?= ""
+
 # The 'build' level: what is needed to build out of tree modules against the
 # kernel ('make scripts prepare' on target), and what kernel-devsrc has
 # always contained.
@@ -566,6 +574,15 @@ do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
 
 FILES:${PN} = "${KERNEL_BUILD_ROOT} ${KERNEL_SRC_PATH} /usr/src/kernel-source-*.tar.bz2"
 
+# The versioned tree (KERNELDEV_VERSIONED_PACKAGE). It is ahead of ${PN} in
+# PACKAGES, so it takes everything but the /usr/src/kernel link.
+PACKAGES =+ "${@'${PN}-tree' if d.getVar('KERNELDEV_VERSIONED_PACKAGE') == '1' else ''}"
+PKG:${PN}-tree = "${PN}-${@legitimize_package_name(d.getVar('KERNEL_VERSION') or '')}"
+FILES:${PN}-tree = "${KERNEL_BUILD_ROOT} /usr/src/kernel-source-*.tar.bz2"
+RDEPENDS:${PN}-tree = "${@bb.utils.contains('PACKAGECONFIG', 'build', '${KERNELDEV_BUILD_RDEPENDS}', '', d)}"
+SKIP_FILEDEPS:${PN}-tree = "${SKIP_FILEDEPS:${PN}}"
+RDEPENDS:${PN} += "${@'${PN}-tree (= ${EXTENDPKGV})' if d.getVar('KERNELDEV_VERSIONED_PACKAGE') == '1' else ''}"
+
 # Added to RDEPENDS:${PN} by the 'build' PACKAGECONFIG
 KERNELDEV_BUILD_RDEPENDS = "bc python3-core flex bison ${TCLIBC}-utils gawk"
 # 4.15+ needs these next two RDEPENDS
-- 
2.43.0


  parent reply	other threads:[~2026-11-06 17:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 17:32 [OE-core][RFC PATCH 0/8] enhance kernel -devsrc output options bruce.ashfield
2026-11-06 17:32 ` [OE-core][RFC PATCH 01/08] kernel.bbclass: map the kernel build directory to KERNEL_SRC_PATH bruce.ashfield
2026-11-06 17:32 ` [OE-core][RFC PATCH 02/08] kernel.bbclass: stage a manifest of the source files the build read bruce.ashfield
2026-11-06 17:32 ` [OE-core][RFC PATCH 03/08] kernel-devsrc: add build and source PACKAGECONFIG levels bruce.ashfield
2026-11-06 17:32 ` [OE-core][RFC PATCH 04/08] kernel-devsrc: add full and tarball " bruce.ashfield
2026-11-06 17:32 ` bruce.ashfield [this message]
2026-11-06 17:32 ` [OE-core][RFC PATCH 06/08] kernel-devsrc: skip the recipe if no PACKAGECONFIG level is set bruce.ashfield
2026-11-06 17:32 ` [OE-core][RFC PATCH 07/08] rootfs: don't carry debug rootfs postinst registrations into the image bruce.ashfield
2026-11-06 17:32 ` [OE-core][RFC PATCH 08/08] rootfs: fail if an IMAGE_INSTALL_DEBUGFS package can't be installed bruce.ashfield
2026-11-06 19:08 ` [OE-core][RFC PATCH 0/8] enhance kernel -devsrc output options Richard Purdie
2026-11-06 20:20   ` bruce.ashfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106173235.4155305-6-bruce.ashfield@gmail.com \
    --to=bruce.ashfield@gmail.com \
    --cc=adrian.freihofer@siemens.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox