]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
lib/oe/kernel: Move python functions from linux-kernel-base to library code
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 29 Jul 2026 21:39:29 +0000 (22:39 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 3 Aug 2026 17:04:08 +0000 (18:04 +0100)
This means get_kernelXXX needs to become oe.kernel.get_XXX and means we can
clear linux-kernel-base to allow it to be removed, starting to simplify the
file structure.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/kernel.bbclass
meta/classes-recipe/kernelsrc.bbclass
meta/classes-recipe/linux-kernel-base.bbclass
meta/lib/oe/__init__.py
meta/lib/oe/kernel.py [new file with mode: 0644]
meta/recipes-kernel/linux/linux-yocto-fitimage.bb
meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb

index 91248467befc5e00e55ea7e71bc078c53a2b517c..aeaec8ccbd461d0590bd4e5d8a56f0d1fe9c0337 100644 (file)
@@ -233,7 +233,7 @@ KERNEL_DTBVENDORED ?= "0"
 #
 # configuration
 #
-KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}"
+KERNEL_VERSION = "${@oe.kernel.get_version_headers('${B}')}"
 
 # kernels are generally machine specific
 PACKAGE_ARCH = "${MACHINE_ARCH}"
@@ -643,7 +643,7 @@ KERNEL_LOCALVERSION ??= ""
 #
 # Note: This class saves the value of localversion to a file
 # so other recipes like make-mod-scripts can restore it via the
-# helper function get_kernellocalversion_file
+# helper function oe.kernel.get_localversion_file
 export LOCALVERSION = "${KERNEL_LOCALVERSION}"
 
 kernel_do_configure() {
index 933618429899b40c1f2a73d8727285c84d6a1563..b105fc159907af724e56aa0148309d56dd2037b9 100644 (file)
@@ -10,8 +10,8 @@ deltask do_unpack
 do_patch[depends] += "virtual/kernel:do_shared_workdir"
 do_patch[noexec] = "1"
 do_package[depends] += "virtual/kernel:do_populate_sysroot"
-KERNEL_VERSION = "${@get_kernelversion_file("${STAGING_KERNEL_BUILDDIR}")}"
-LOCAL_VERSION = "${@get_kernellocalversion_file("${STAGING_KERNEL_BUILDDIR}")}"
+KERNEL_VERSION = "${@oe.kernel.get_version_file("${STAGING_KERNEL_BUILDDIR}")}"
+LOCAL_VERSION = "${@oe.kernel.get_localversion_file("${STAGING_KERNEL_BUILDDIR}")}"
 
 inherit linux-kernel-base
 
index 76d8b4d45136a3a746a4cd8c11c6b736e65a3832..566b2c96ba704d04373b4aa110adf5131b167799 100644 (file)
@@ -4,52 +4,6 @@
 # SPDX-License-Identifier: MIT
 #
 
-# parse kernel ABI version out of <linux/version.h>
-def get_kernelversion_headers(p):
-    import re
-
-    fn = p + '/include/linux/utsrelease.h'
-    if not os.path.isfile(fn):
-        # after 2.6.33-rc1
-        fn = p + '/include/generated/utsrelease.h'
-    if not os.path.isfile(fn):
-        fn = p + '/include/linux/version.h'
-
-    try:
-        f = open(fn, 'r')
-    except IOError:
-        return None
-
-    l = f.readlines()
-    f.close()
-    r = re.compile("#define UTS_RELEASE \"(.*)\"")
-    for s in l:
-        m = r.match(s)
-        if m:
-            return m.group(1)
-    return None
-
-
-def get_kernelversion_file(p):
-    fn = p + '/kernel-abiversion'
-
-    try:
-        with open(fn, 'r') as f:
-            return f.readlines()[0].strip()
-    except IOError:
-        return None
-
-def get_kernellocalversion_file(p):
-    fn = p + '/kernel-localversion'
-
-    try:
-        with open(fn, 'r') as f:
-            return f.readlines()[0].strip()
-    except IOError:
-        return ""
-
-    return ""
-
 export KBUILD_BUILD_VERSION = "1"
 export KBUILD_BUILD_USER ?= "oe-user"
 export KBUILD_BUILD_HOST ?= "oe-host"
index 13d887a4aad76e15562dec5f5932a36bae2fcf3c..faa9987c8ca9ebd746b35f92c1a567eb13a08db3 100644 (file)
@@ -12,4 +12,4 @@ __path__ = extend_path(__path__, __name__)
 BBIMPORTS = ["qa", "data", "path", "utils", "types", "package", "packagedata", \
              "packagegroup", "sstatesig", "lsb", "cachedpath", "license", "qemu", \
              "reproducible", "rust", "buildcfg", "go", "spdx30_tasks", "spdx_common", \
-             "cve_check", "tune", "classextend", "purl"]
+             "cve_check", "tune", "classextend", "purl", "kernel"]
diff --git a/meta/lib/oe/kernel.py b/meta/lib/oe/kernel.py
new file mode 100644 (file)
index 0000000..421debe
--- /dev/null
@@ -0,0 +1,51 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+import re
+
+# parse kernel ABI version out of <linux/version.h>
+def get_version_headers(p):
+    fn = p + '/include/linux/utsrelease.h'
+    if not os.path.isfile(fn):
+        # after 2.6.33-rc1
+        fn = p + '/include/generated/utsrelease.h'
+    if not os.path.isfile(fn):
+        fn = p + '/include/linux/version.h'
+
+    try:
+        f = open(fn, 'r')
+    except IOError:
+        return None
+
+    l = f.readlines()
+    f.close()
+    r = re.compile("#define UTS_RELEASE \"(.*)\"")
+    for s in l:
+        m = r.match(s)
+        if m:
+            return m.group(1)
+    return None
+
+
+def get_version_file(p):
+    fn = p + '/kernel-abiversion'
+
+    try:
+        with open(fn, 'r') as f:
+            return f.readlines()[0].strip()
+    except IOError:
+        return None
+
+def get_localversion_file(p):
+    fn = p + '/kernel-localversion'
+
+    try:
+        with open(fn, 'r') as f:
+            return f.readlines()[0].strip()
+    except IOError:
+        return ""
+
+    return ""
index 4dcffb62094d904ece9915d78386c41cab20afe4..75dbcb2af5c61e515736ac6c2068dac77f4301ed 100644 (file)
@@ -10,4 +10,4 @@ inherit linux-kernel-base kernel-fit-image
 
 # Set the version of this recipe to the version of the included kernel
 # (without taking the long way around via PV)
-PKGV = "${@get_kernelversion_file("${STAGING_KERNEL_BUILDDIR}")}"
+PKGV = "${@oe.kernel.get_version_file("${STAGING_KERNEL_BUILDDIR}")}"
index 338a50de916f72718308680b1794305883280b6c..ab984f4bcfead6c6963023d01e3deb79e84d8e0a 100644 (file)
@@ -24,7 +24,7 @@ DEPENDS += "virtual/cross-cc virtual/cross-binutils"
 EXTRA_OEMAKE = " HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}""
 EXTRA_OEMAKE += " HOSTCXX="${BUILD_CXX} ${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}" CROSS_COMPILE=${TARGET_PREFIX}"
 
-KERNEL_LOCALVERSION = "${@get_kernellocalversion_file("${STAGING_KERNEL_BUILDDIR}")}"
+KERNEL_LOCALVERSION = "${@oe.kernel.get_localversion_file("${STAGING_KERNEL_BUILDDIR}")}"
 export LOCALVERSION = "${KERNEL_LOCALVERSION}"
 
 # Build some host tools under work-shared.  CC, LD, and AR are probably