diff mbox series

[1/2] package: introduce PACKAGE_BASENAME for consistent kernel -src naming

Message ID 20260921215300.582692-2-adrian.freihofer@siemens.com
State New
Headers show
Series Fix kernel complementary package installation | expand

Commit Message

AdrianF Sept. 21, 2026, 9:50 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

populate_packages() always names the auto-generated -src package after
PN. kernel.bbclass instead names all its other sub-packages
(kernel-dbg, kernel-dev, kernel-modules, ...) after KERNEL_PACKAGE_NAME,
so the kernel recipe ended up with a lone -src package (linux-yocto-src)
that did not match the rest of the kernel-* family (e.g. kernel-dbg).

The complementary package install logic (oe-pkgdata-util) cannot find
packages that are not named after PN (${PN}-src, ${PN}-dbg, etc). For
the kernel recipe this meant linux-yocto-src was picked up, but
kernel-dbg, kernel-dev, etc. were not, which was inconsistent.

This commit introduces a generic PACKAGE_BASENAME variable
(default "${PN}") that a recipe/bbclass can override to declare the base
name its sub-packages should share. populate_packages() now uses it for
-src naming, and kernel.bbclass sets it to "${KERNEL_PACKAGE_NAME}". As
a result the kernel packages are now named kernel-dbg, kernel-src and so
on.
Changing the kernel's -src package to kernel-src also means this package
is longer found either by the complementary package installation and not
installed anymore.

If kernel packages should be installed via complementary package install
logic is left for a follow up commit. This commit only aligns the
package naming also for the -src package.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 meta/classes-recipe/kernel.bbclass | 3 +++
 meta/conf/bitbake.conf             | 6 ++++++
 meta/lib/oe/package.py             | 4 +++-
 3 files changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index 0a6d754108..16745557f7 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -679,6 +679,9 @@  EXPORT_FUNCTIONS do_compile do_transform_kernel do_transform_bundled_initramfs d
 # kernel-base becomes kernel-${KERNEL_VERSION}
 # kernel-image becomes kernel-image-${KERNEL_VERSION}
 PACKAGES = "${KERNEL_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules ${KERNEL_PACKAGE_NAME}-dbg"
+# Keep the auto-generated -src package (see populate_packages() in oe/package.py) named,
+# and resolvable by tools like oe-pkgdata-util, consistently with the rest of the kernel-* family.
+PACKAGE_BASENAME = "${KERNEL_PACKAGE_NAME}"
 FILES:${PN} = ""
 FILES:${KERNEL_PACKAGE_NAME}-base = "${KERNEL_MODULE_INSTALL_PREFIX}/modules.order ${KERNEL_MODULE_INSTALL_PREFIX}/modules.builtin ${KERNEL_MODULE_INSTALL_PREFIX}/modules.builtin.modinfo"
 FILES:${KERNEL_PACKAGE_NAME}-image = ""
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index d353a7cd2c..f82ee0f039 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -334,6 +334,12 @@  SOLIBSDEV:mingw32 = ".dll"
 
 PACKAGE_DEBUG_SPLIT_STYLE ?= "debug-with-srcpkg"
 
+# The base name recipe sub-packages (-dbg, -dev, -src etc.) are derived from.
+# Recipes/bbclasses that name their packages after something other than PN
+# (e.g. kernel.bbclass and KERNEL_PACKAGE_NAME) should override this so that
+# tooling (e.g. oe-pkgdata-util) can still map generic package globs to them.
+PACKAGE_BASENAME ??= "${PN}"
+
 PACKAGE_BEFORE_PN ?= ""
 PACKAGES = "${PN}-src ${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
 PACKAGES_DYNAMIC = "^${PN}-locale-.*"
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index b7030643d2..4afd047905 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -1391,7 +1391,9 @@  def populate_packages(d):
     # If debug-with-srcpkg mode is enabled then add the source package if it
     # doesn't exist and add the source file contents to the source package.
     if split_source_package:
-        src_package_name = ('%s-src' % d.getVar('PN'))
+        # PACKAGE_BASENAME lets bbclasses (e.g. kernel.bbclass via KERNEL_PACKAGE_NAME)
+        # that name their other sub-packages differently from PN keep -src consistent with them.
+        src_package_name = ('%s-src' % (d.getVar('PACKAGE_BASENAME') or pn))
         if not src_package_name in packages:
             packages.append(src_package_name)
         d.setVar('FILES:%s' % src_package_name, '/usr/src/debug')