summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2023-07-21 22:31:09 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-07-25 15:27:33 +0100
commit88ae1b73c09c4a1b2563f61fcddd15b5ae9fedca (patch)
tree3f26bc71b71a363bb5a81e73f61d1186f51cbf75
parent71252e03e732163a90a59e28aae06ebf4e427e6c (diff)
downloadpoky-88ae1b73c09c4a1b2563f61fcddd15b5ae9fedca.tar.gz
kernel: make LOCALVERSION consistent between recipes
The initial fix for localversion setting in 6.3+ broke older recipes and also broke recipes setting localversion in a kernel recipe, as make-mod-scripts (and other locations) can trigger a regeneration of files and don't have access to the variable. Moving the setting of this variable to the global namespace doesn't make sense, so we follow the example of the kernel-abiversion and save a kernel-localversion to the build artifacts. Recipes that may regenerate scripts/dynamic files, must depend on the do_shared_workedir of the kernel and use the helper function to read the file storing the localversion. (From OE-Core rev: b378eec156998eea55ba61e59103cb34fab0d07c) Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/kernel-arch.bbclass8
-rw-r--r--meta/classes-recipe/kernel.bbclass14
-rw-r--r--meta/classes-recipe/kernelsrc.bbclass1
-rw-r--r--meta/classes-recipe/linux-kernel-base.bbclass11
-rw-r--r--meta/classes-recipe/module-base.bbclass1
-rw-r--r--meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb3
6 files changed, 30 insertions, 8 deletions
diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass
index df4884b6c4..b0db99faa3 100644
--- a/meta/classes-recipe/kernel-arch.bbclass
+++ b/meta/classes-recipe/kernel-arch.bbclass
@@ -79,11 +79,3 @@ KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
79KERNEL_OBJCOPY = "${CCACHE}${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}" 79KERNEL_OBJCOPY = "${CCACHE}${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}"
80KERNEL_STRIP = "${CCACHE}${HOST_PREFIX}strip ${HOST_STRIP_KERNEL_ARCH}" 80KERNEL_STRIP = "${CCACHE}${HOST_PREFIX}strip ${HOST_STRIP_KERNEL_ARCH}"
81TOOLCHAIN ?= "gcc" 81TOOLCHAIN ?= "gcc"
82
83# 6.3+ requires the variable LOCALVERSION to be set to not get a "+" in
84# the local version. Having it empty means nothing will be added, and any
85# value will be appended to the local kernel version. This replaces the
86# use of .scmversion file for setting a localversion without using
87# the CONFIG_LOCALVERSION option.
88KERNEL_LOCALVERSION ??= ""
89export LOCALVERSION ?= "${KERNEL_LOCALVERSION}"
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index 2e9563186e..247ef4a48a 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -551,6 +551,7 @@ do_shared_workdir () {
551 # 551 #
552 552
553 echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion 553 echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
554 echo "${KERNEL_LOCALVERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-localversion
554 555
555 # Copy files required for module builds 556 # Copy files required for module builds
556 cp System.map $kerneldir/System.map-${KERNEL_VERSION} 557 cp System.map $kerneldir/System.map-${KERNEL_VERSION}
@@ -640,6 +641,19 @@ python check_oldest_kernel() {
640check_oldest_kernel[vardepsexclude] += "OLDEST_KERNEL KERNEL_VERSION" 641check_oldest_kernel[vardepsexclude] += "OLDEST_KERNEL KERNEL_VERSION"
641do_configure[prefuncs] += "check_oldest_kernel" 642do_configure[prefuncs] += "check_oldest_kernel"
642 643
644KERNEL_LOCALVERSION ??= ""
645
646# 6.3+ requires the variable LOCALVERSION to be set to not get a "+" in
647# the local version. Having it empty means nothing will be added, and any
648# value will be appended to the local kernel version. This replaces the
649# use of .scmversion file for setting a localversion without using
650# the CONFIG_LOCALVERSION option.
651#
652# Note: This class saves the value of localversion to a file
653# so other recipes like make-mod-scripts can restore it via the
654# helper function get_kernellocalversion_file
655export LOCALVERSION="${KERNEL_LOCALVERSION}"
656
643kernel_do_configure() { 657kernel_do_configure() {
644 # fixes extra + in /lib/modules/2.6.37+ 658 # fixes extra + in /lib/modules/2.6.37+
645 # $ scripts/setlocalversion . => + 659 # $ scripts/setlocalversion . => +
diff --git a/meta/classes-recipe/kernelsrc.bbclass b/meta/classes-recipe/kernelsrc.bbclass
index a32882a5d2..ecb02dc9ed 100644
--- a/meta/classes-recipe/kernelsrc.bbclass
+++ b/meta/classes-recipe/kernelsrc.bbclass
@@ -11,6 +11,7 @@ do_patch[depends] += "virtual/kernel:do_shared_workdir"
11do_patch[noexec] = "1" 11do_patch[noexec] = "1"
12do_package[depends] += "virtual/kernel:do_populate_sysroot" 12do_package[depends] += "virtual/kernel:do_populate_sysroot"
13KERNEL_VERSION = "${@get_kernelversion_file("${STAGING_KERNEL_BUILDDIR}")}" 13KERNEL_VERSION = "${@get_kernelversion_file("${STAGING_KERNEL_BUILDDIR}")}"
14LOCAL_VERSION = "${@get_kernellocalversion_file("${STAGING_KERNEL_BUILDDIR}")}"
14 15
15inherit linux-kernel-base 16inherit linux-kernel-base
16 17
diff --git a/meta/classes-recipe/linux-kernel-base.bbclass b/meta/classes-recipe/linux-kernel-base.bbclass
index 65cc48f304..e2187a73f0 100644
--- a/meta/classes-recipe/linux-kernel-base.bbclass
+++ b/meta/classes-recipe/linux-kernel-base.bbclass
@@ -39,6 +39,17 @@ def get_kernelversion_file(p):
39 except IOError: 39 except IOError:
40 return None 40 return None
41 41
42def get_kernellocalversion_file(p):
43 fn = p + '/kernel-localversion'
44
45 try:
46 with open(fn, 'r') as f:
47 return f.readlines()[0].strip()
48 except IOError:
49 return ""
50
51 return ""
52
42def linux_module_packages(s, d): 53def linux_module_packages(s, d):
43 suffix = "" 54 suffix = ""
44 return " ".join(map(lambda s: "kernel-module-%s%s" % (s.lower().replace('_', '-').replace('@', '+'), suffix), s.split())) 55 return " ".join(map(lambda s: "kernel-module-%s%s" % (s.lower().replace('_', '-').replace('@', '+'), suffix), s.split()))
diff --git a/meta/classes-recipe/module-base.bbclass b/meta/classes-recipe/module-base.bbclass
index 094b563b1a..2a225881ba 100644
--- a/meta/classes-recipe/module-base.bbclass
+++ b/meta/classes-recipe/module-base.bbclass
@@ -20,6 +20,7 @@ export CROSS_COMPILE = "${TARGET_PREFIX}"
20export KBUILD_OUTPUT = "${STAGING_KERNEL_BUILDDIR}" 20export KBUILD_OUTPUT = "${STAGING_KERNEL_BUILDDIR}"
21 21
22export KERNEL_VERSION = "${@oe.utils.read_file('${STAGING_KERNEL_BUILDDIR}/kernel-abiversion')}" 22export KERNEL_VERSION = "${@oe.utils.read_file('${STAGING_KERNEL_BUILDDIR}/kernel-abiversion')}"
23export LOCALVERSION = "${@oe.utils.read_file('${STAGING_KERNEL_BUILDDIR}/kernel-localversion')}"
23KERNEL_OBJECT_SUFFIX = ".ko" 24KERNEL_OBJECT_SUFFIX = ".ko"
24 25
25# kernel modules are generally machine specific 26# kernel modules are generally machine specific
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 e3b258753f..a91680d497 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
@@ -21,6 +21,9 @@ DEPENDS += "gmp-native"
21EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"" 21EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}""
22EXTRA_OEMAKE += " HOSTCXX="${BUILD_CXX} ${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}" CROSS_COMPILE=${TARGET_PREFIX}" 22EXTRA_OEMAKE += " HOSTCXX="${BUILD_CXX} ${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}" CROSS_COMPILE=${TARGET_PREFIX}"
23 23
24KERNEL_LOCALVERSION = "${@get_kernellocalversion_file("${STAGING_KERNEL_BUILDDIR}")}"
25export LOCALVERSION="${KERNEL_LOCALVERSION}"
26
24# Build some host tools under work-shared. CC, LD, and AR are probably 27# Build some host tools under work-shared. CC, LD, and AR are probably
25# not used, but this is the historical way of invoking "make scripts". 28# not used, but this is the historical way of invoking "make scripts".
26# 29#