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 <[email protected]> --- meta/classes-recipe/kernel.bbclass | 4 +- meta/classes-recipe/kernelsrc.bbclass | 4 +- meta/classes-recipe/linux-kernel-base.bbclass | 46 ----------------- meta/lib/oe/__init__.py | 2 +- meta/lib/oe/kernel.py | 51 +++++++++++++++++++ .../linux/linux-yocto-fitimage.bb | 2 +- .../make-mod-scripts/make-mod-scripts_1.0.bb | 2 +- 7 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 meta/lib/oe/kernel.py diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass index 91248467bef..aeaec8ccbd4 100644 --- a/meta/classes-recipe/kernel.bbclass +++ b/meta/classes-recipe/kernel.bbclass @@ -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() { diff --git a/meta/classes-recipe/kernelsrc.bbclass b/meta/classes-recipe/kernelsrc.bbclass index 93361842989..b105fc15990 100644 --- a/meta/classes-recipe/kernelsrc.bbclass +++ b/meta/classes-recipe/kernelsrc.bbclass @@ -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 diff --git a/meta/classes-recipe/linux-kernel-base.bbclass b/meta/classes-recipe/linux-kernel-base.bbclass index 76d8b4d4513..566b2c96ba7 100644 --- a/meta/classes-recipe/linux-kernel-base.bbclass +++ b/meta/classes-recipe/linux-kernel-base.bbclass @@ -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" diff --git a/meta/lib/oe/__init__.py b/meta/lib/oe/__init__.py index 13d887a4aad..faa9987c8ca 100644 --- a/meta/lib/oe/__init__.py +++ b/meta/lib/oe/__init__.py @@ -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 index 00000000000..421debed9af --- /dev/null +++ b/meta/lib/oe/kernel.py @@ -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 "" diff --git a/meta/recipes-kernel/linux/linux-yocto-fitimage.bb b/meta/recipes-kernel/linux/linux-yocto-fitimage.bb index 4dcffb62094..75dbcb2af5c 100644 --- a/meta/recipes-kernel/linux/linux-yocto-fitimage.bb +++ b/meta/recipes-kernel/linux/linux-yocto-fitimage.bb @@ -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}")}" diff --git a/meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb b/meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb index 338a50de916..ab984f4bcfe 100644 --- a/meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb +++ b/meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb @@ -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
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#242528): https://lists.openembedded.org/g/openembedded-core/message/242528 Mute This Topic: https://lists.openembedded.org/mt/120561017/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
