All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 1/1] kernel.bbclass: Add kernel_version_sanity_check function
@ 2016-09-16 23:48 California Sullivan
  2016-09-19 15:04 ` Bruce Ashfield
  2016-09-21  3:11 ` Robert Yang
  0 siblings, 2 replies; 16+ messages in thread
From: California Sullivan @ 2016-09-16 23:48 UTC (permalink / raw)
  To: openembedded-core; +Cc: bruce.ashfield

The kernel being built should match what the recipe claims it is
building. This function ensures that happens by comparing the version
information in the kernel's Makefile to the PV the recipe is using.

v2 changes:
* Match against PV instead of LINUX_VERSION
* Match against EXTRAVERSION as well (e.g., -rc4)
* Cleaned up version string building

Fixes [YOCTO #6767].

Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
---
 meta/classes/kernel.bbclass               | 30 ++++++++++++++++++++++++++++++
 meta/recipes-kernel/linux/linux-yocto.inc |  1 +
 2 files changed, 31 insertions(+)

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index a6112e8..f894795 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -327,6 +327,36 @@ kernel_do_install() {
 }
 do_install[prefuncs] += "package_get_auto_pr"
 
+# Must be ran no earlier than after do_kernel_checkout or else Makefile won't be in ${S}/Makefile
+do_kernel_version_sanity_check() {
+	# The Makefile determines the kernel version shown at runtime
+	# Don't use KERNEL_VERSION because the headers it grabs the version from aren't generated until do_compile
+	VERSION=$(grep "^VERSION =" ${S}/Makefile | sed s/.*=\ *//)
+	PATCHLEVEL=$(grep "^PATCHLEVEL =" ${S}/Makefile | sed s/.*=\ *//)
+	SUBLEVEL=$(grep "^SUBLEVEL =" ${S}/Makefile | sed s/.*=\ *//)
+	EXTRAVERSION=$(grep "^EXTRAVERSION =" ${S}/Makefile | sed s/.*=\ *//)
+
+	# Build a string for regex and a plain version string
+	reg="^${VERSION}\.${PATCHLEVEL}"
+	vers="${VERSION}.${PATCHLEVEL}"
+	if [ -n "${SUBLEVEL}" ]; then
+		# Ignoring a SUBLEVEL of zero is fine
+		if [ "${SUBLEVEL}" = "0" ]; then
+			reg="${reg}(\.${SUBLEVEL})?"
+		else
+			reg="${reg}\.${SUBLEVEL}"
+			vers="${vers}.${SUBLEVEL}"
+		fi
+	fi
+	vers="${vers}${EXTRAVERSION}"
+	reg="${reg}${EXTRAVERSION}"
+
+	if [ -z `echo ${PV} | grep -E "${reg}"` ]; then
+		bbfatal "Package Version (${PV}) does not match of kernel being built (${vers}). Please update the PV variable to match the kernel source."
+	fi
+	exit 0
+}
+
 addtask shared_workdir after do_compile before do_compile_kernelmodules
 addtask shared_workdir_setscene
 
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 98a48ec..d979662 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -55,6 +55,7 @@ do_install_append(){
 }
 
 # extra tasks
+addtask kernel_version_sanity_check after do_kernel_checkout before do_compile
 addtask kernel_link_images after do_compile before do_install
 addtask validate_branches before do_patch after do_kernel_checkout
 addtask kernel_configcheck after do_configure before do_compile
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-09-21 16:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-16 23:48 [PATCH V2 1/1] kernel.bbclass: Add kernel_version_sanity_check function California Sullivan
2016-09-19 15:04 ` Bruce Ashfield
2016-09-19 15:09   ` Burton, Ross
2016-09-19 16:22     ` Burton, Ross
2016-09-19 17:05       ` Cal Sullivan
2016-09-19 18:54         ` Burton, Ross
2016-09-19 19:53           ` Cal Sullivan
2016-09-19 19:55             ` Bruce Ashfield
2016-09-19 20:49               ` Saul Wold
2016-09-19 22:02                 ` Cal Sullivan
2016-09-19 22:55                   ` Bruce Ashfield
2016-09-19 23:02                     ` Cal Sullivan
2016-09-20  0:03                       ` Bruce Ashfield
2016-09-20  3:54                         ` Bruce Ashfield
2016-09-21  3:11 ` Robert Yang
2016-09-21 16:27   ` Cal Sullivan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.