diff mbox series

[2/2] oe-pkgdata-util: use PACKAGE_BASENAME for glob PN-substitution fallback

Message ID 20260921215300.582692-3-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>

Fix the complementary package install logic (oe-pkgdata-util) for
packages which have PACKAGE_BASENAME != PN  (only the kernel).

Add PACKAGE_BASENAME to PKGDATA_VARS so it is recorded in pkgdata like
any other per-package field, and have glob() read it (falling back to
PN, for pkgdata not yet regenerated with the new field) instead of PN
alone.

With this change the kernel -dbg and -src packages are automatically
added to the rootfs-dbg if the kernel is installed in the rootfs.
Removing this kernel packages is possible by
  PACKAGE_EXCLUDE_COMPLEMENTARY += "kernel-*"

Adding the kernel-dbg, -src packges for systems where the kernel is not
installed into the rootfs is possible via IMAGE_INSTALL_DEBUGFS.

Not sure, if there could be a more systaibable fix which would remove
KERNEL_PACKAGE_NAME from the kernel and not need this extra complexity
in the packaging code.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 meta/classes-global/package.bbclass | 2 +-
 scripts/oe-pkgdata-util             | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
index e21350a06f..4ead147cd3 100644
--- a/meta/classes-global/package.bbclass
+++ b/meta/classes-global/package.bbclass
@@ -385,7 +385,7 @@  EXPORT_FUNCTIONS package_name_hook
 
 PKGDESTWORK = "${WORKDIR}/pkgdata"
 
-PKGDATA_VARS = "PN PE PV PR PKGE PKGV PKGR LICENSE DESCRIPTION SUMMARY RDEPENDS RPROVIDES RRECOMMENDS RSUGGESTS RREPLACES RCONFLICTS SECTION PKG ALLOW_EMPTY FILES CONFFILES FILES_INFO PACKAGE_ADD_METADATA pkg_postinst pkg_postrm pkg_preinst pkg_prerm"
+PKGDATA_VARS = "PN PE PV PR PKGE PKGV PKGR LICENSE DESCRIPTION SUMMARY RDEPENDS RPROVIDES RRECOMMENDS RSUGGESTS RREPLACES RCONFLICTS SECTION PKG ALLOW_EMPTY FILES CONFFILES FILES_INFO PACKAGE_ADD_METADATA PACKAGE_BASENAME pkg_postinst pkg_postrm pkg_preinst pkg_prerm"
 
 python emit_pkgdata() {
     import oe.packagedata
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index acefae24f3..466086f009 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -86,11 +86,16 @@  def glob(args):
                 return os.path.join(args.pkgdata_dir, "runtime", pkgn)
             def readpn(pkgdata_file):
                 pn = ""
+                basename = ""
                 with open(pkgdata_file, 'r') as f:
                     for line in f:
                         if line.startswith("PN:"):
                             pn = line.split(': ')[1].rstrip()
-                return pn
+                        elif line.startswith("PACKAGE_BASENAME:"):
+                            basename = line.split(': ')[1].rstrip()
+                # PACKAGE_BASENAME lets a recipe (e.g. via kernel.bbclass's
+                # KERNEL_PACKAGE_NAME) name its sub-packages differently from PN
+                return basename or pn
             def readrenamed(pkgdata_file):
                 renamed = ""
                 pn = os.path.basename(pkgdata_file)