[07/27] linux-module: Migrate to a bbclasss

Message ID b54cc658f81da9891c9829a5b9a70e9bd49d394c.1762170735.git.jan.kiszka@siemens.com
State Under Review
Headers show
Series [01/27] linux-custom: Drop redundant template inheritance | expand

Commit Message

Jan Kiszka Nov. 3, 2025, 11:51 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

"inherit linux-module" is shorter and a more common pattern compared to
OE/yocto. Keep the original .inc file as transitional helper, issuing a
warning when it's used with a migration suggestion.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../linux-module.bbclass}                     |  3 +-
 meta/recipes-kernel/linux-module/module.inc   | 85 ++-----------------
 2 files changed, 7 insertions(+), 81 deletions(-)
 copy meta/{recipes-kernel/linux-module/module.inc => classes-recipe/linux-module.bbclass} (97%)

Patch

diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/classes-recipe/linux-module.bbclass
similarity index 97%
copy from meta/recipes-kernel/linux-module/module.inc
copy to meta/classes-recipe/linux-module.bbclass
index d2a41766..57a5cf41 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/classes-recipe/linux-module.bbclass
@@ -5,8 +5,6 @@ 
 #
 # SPDX-License-Identifier: MIT
 
-FILESPATH:append := ":${FILE_DIRNAME}/files"
-
 DESCRIPTION ?= "Custom kernel module ${PN}"
 MAINTAINER ?= "isar-users <isar-users@googlegroups.com>"
 
@@ -35,6 +33,7 @@  DEB_BUILD_PROFILES += "${@'pkg.signwith' if bb.utils.to_boolean(d.getVar('KERNEL
 DEPENDS += "${@'module-signer secure-boot-secrets' if bb.utils.to_boolean(d.getVar('KERNEL_MODULE_SIGNATURES')) else ''}"
 DEBIAN_BUILD_DEPENDS .= "${@', module-signer, secure-boot-secrets' if bb.utils.to_boolean(d.getVar('KERNEL_MODULE_SIGNATURES')) else ''}"
 
+FILESPATH:append = ":${LAYERDIR_core}/recipes-kernel/linux-module/files"
 SRC_URI += "file://debian/"
 
 AUTOLOAD ?= ""
diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index d2a41766..52541a29 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -1,86 +1,13 @@ 
-# Custom kernel module recipe include
+# Transitional include for linux-module.bbclass
 #
 # This software is a part of ISAR.
-# Copyright (c) Siemens AG, 2018
+# Copyright (c) Siemens AG, 2025
 #
 # SPDX-License-Identifier: MIT
 
-FILESPATH:append := ":${FILE_DIRNAME}/files"
+inherit linux-module
 
-DESCRIPTION ?= "Custom kernel module ${PN}"
-MAINTAINER ?= "isar-users <isar-users@googlegroups.com>"
-
-KERNEL_NAME ?= ""
-# directory with KBuild file (M=${MODULE_DIR})
-MODULE_DIR ?= "$(PWD)"
-
-PN .= "-${KERNEL_NAME}"
-
-KERNEL_IMAGE_PKG ??= "linux-image-${KERNEL_NAME}"
-KERNEL_HEADERS_PKG ??= "linux-headers-${KERNEL_NAME}"
-DEPENDS += "${KERNEL_HEADERS_PKG}-native"
-DEBIAN_BUILD_DEPENDS = "${KERNEL_HEADERS_PKG}"
-# Do not generate debug symbols packages, as not supported for modules
-DEB_BUILD_OPTIONS += "noautodbgsym"
-
-SIGNATURE_KEYFILE ??= "/usr/share/secure-boot-secrets/secure-boot.key"
-SIGNATURE_CERTFILE ??= "/usr/share/secure-boot-secrets/secure-boot.pem"
-SIGNATURE_HASHFN ??= "sha256"
-SIGNATURE_SIGNWITH ??= "/usr/bin/sign-module.sh"
-
-KERNEL_MODULE_SIGNATURES ??= ""
-
-# Define signing profile and dependencies if KERNEL_MODULE_SIGNATURES is set to "1"
-DEB_BUILD_PROFILES += "${@'pkg.signwith' if bb.utils.to_boolean(d.getVar('KERNEL_MODULE_SIGNATURES')) else ''}"
-DEPENDS += "${@'module-signer secure-boot-secrets' if bb.utils.to_boolean(d.getVar('KERNEL_MODULE_SIGNATURES')) else ''}"
-DEBIAN_BUILD_DEPENDS .= "${@', module-signer, secure-boot-secrets' if bb.utils.to_boolean(d.getVar('KERNEL_MODULE_SIGNATURES')) else ''}"
-
-SRC_URI += "file://debian/"
-
-AUTOLOAD ?= ""
-
-# Cross-compilation is not supported for the default Debian kernels.
-# For example, package with kernel headers for ARM:
-#   linux-headers-armmp
-# has hard dependencies from linux-compiler-gcc-4.8-arm, what
-# conflicts with the host binaries.
-python() {
-    if d.getVar('KERNEL_NAME') in d.getVar('DISTRO_KERNELS').split():
-        d.setVar('ISAR_CROSS_COMPILE', '0')
-}
-
-inherit dpkg
-inherit per-kernel
-
-TEMPLATE_FILES = "debian/control.tmpl \
-                  debian/rules.tmpl"
-TEMPLATE_VARS += " \
-    KERNEL_NAME \
-    KERNEL_TYPE \
-    KERNEL_IMAGE_PKG \
-    KERNEL_HEADERS_PKG \
-    KCFLAGS \
-    KAFLAGS \
-    MODULE_DIR \
-    DEBIAN_BUILD_DEPENDS \
-    SIGNATURE_KEYFILE \
-    SIGNATURE_CERTFILE \
-    SIGNATURE_HASHFN \
-    SIGNATURE_SIGNWITH \
-    PN \
-    DEBIAN_COMPAT"
-
-# Add custom cflags to the kernel build
-KCFLAGS ?= "-fdebug-prefix-map=${CURDIR}=. -fmacro-prefix-map=${CURDIR}=."
-KAFLAGS ?= "-fdebug-prefix-map=${CURDIR}=."
-
-do_prepare_build() {
-    rm -rf ${S}/debian
-    cp -r ${WORKDIR}/debian ${S}/
-
-    deb_add_changelog
-
-    for module in ${AUTOLOAD}; do
-        echo "echo $module >> /etc/modules" >> ${S}/debian/postinst
-    done
+do_warn_custom_inc() {
+    bbwarn "Please migrate from \"require recipes-kernel/linux-module/module.inc\" to \"inherit linux-module\""
 }
+addtask warn_custom_inc before do_unpack