<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 17, 2016 at 1:25 AM, California Sullivan <span dir="ltr"><<a href="mailto:california.l.sullivan@intel.com" target="_blank">california.l.sullivan@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The kernel being built should match what the recipe claims it is<br>
building. This function ensures that happens for anyone using<br>
LINUX_VERSION as they should. As it will likely break outside kernels<br>
not using LINUX_VERSION, only enable the function for linux-yocto for<br>
now.<br>
<br>
Signed-off-by: California Sullivan <<a href="mailto:california.l.sullivan@intel.com">california.l.sullivan@intel.<wbr>com</a>><br>
---<br>
I'm not absolutely sure this is the correct path to solve the issue.<br>
This patch relies on LINUX_VERSION being set which isn't a guarantee.<br>
There is probably a more general solution that I'm not thinking of.<br></blockquote><div><br></div><div>I can't say that I know of all the options either, but I can ask questions and perhaps<br></div><div>others will have more ideas.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
meta/classes/kernel.bbclass | 21 +++++++++++++++++++++<br>
meta/recipes-kernel/linux/<wbr>linux-yocto.inc | 1 +<br>
2 files changed, 22 insertions(+)<br>
<br>
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass<br>
index db42744..ac2611f 100644<br>
--- a/meta/classes/kernel.bbclass<br>
+++ b/meta/classes/kernel.bbclass<br>
@@ -330,6 +330,27 @@ kernel_do_install() {<br>
}<br>
do_install[prefuncs] += "package_get_auto_pr"<br>
<br>
+# Must be ran some time after do_kernel_checkout or else Makefile won't be in ${S}/Makefile<br>
+do_kernel_version_sanity_<wbr>check() {<br>
+ # The Makefile determines the kernel version shown at runtime<br>
+ # Don't use KERNEL_VERSION because the headers it grabs the version from aren't generated until do_compile <br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ VERSION=$(grep "^VERSION =" ${S}/Makefile | sed s/.*=\ //)<br>
+ PATCHLEVEL=$(grep "^PATCHLEVEL =" ${S}/Makefile | sed s/.*=\ //)<br>
+ SUBLEVEL=$(grep "^SUBLEVEL =" ${S}/Makefile | sed s/.*=\ //)<br></blockquote><div><br></div><div>I was also trying to think of a way to avoid duplicating code that is yanking out version<br></div><div>numbers, but yes if we depend on utsrelease, we also have to do some level of <br></div><div>building .. but that can actually be pretty lightweight.<br><br></div><div>Have you tried just invoking the prepare1 target in the kernel build ? That should <br></div><div>generate the utsrelease, and not much more.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ # If SUBLEVEL is zero or doesn't exist we ignore it as VERSION.PATCHLEVEL is normal<br>
+ if [ -n "${SUBLEVEL}" ] && [ "${SUBLEVEL}" != "0" ]; then<br>
+ if [ "${VERSION}.${PATCHLEVEL}.${<wbr>SUBLEVEL}" != "${LINUX_VERSION}" ]; then<br>
+ bbfatal "LINUX_VERSION (${LINUX_VERSION}) does not match kernel being built (${VERSION}.${PATCHLEVEL}.${<wbr>SUBLEVEL}).\nTo fix this correct the LINUX_VERSION variable in your kernel recipe."<br></blockquote><div><br></div><div>I know that I use LINUX_VERSION in the linux-yocto recipes, but it isn't something<br></div><div>enforced or widespread (as far as I know). Since this is kernel.bbclass versus kernel-yocto.bbclass<br></div><div>should this be checking against PV versus LINUX_VERSION ? Alternatively, this could just<br></div><div>move to kernel-yocto.bbclass as we try and make it more general.<br><br></div><div>Bruce<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ fi<br>
+ else<br>
+ if [ "${VERSION}.${PATCHLEVEL}" != "${LINUX_VERSION}" ]; then<br>
+ bbfatal "LINUX_VERSION (${LINUX_VERSION}) does not match kernel being built (${VERSION}.${PATCHLEVEL}).\<wbr>nTo fix this correct the LINUX_VERSION variable in your kernel recipe."<br>
+ fi<br>
+ fi<br>
+ exit 0<br>
+}<br>
+<br>
addtask shared_workdir after do_compile before do_compile_kernelmodules<br>
addtask shared_workdir_setscene<br>
<br>
diff --git a/meta/recipes-kernel/linux/<wbr>linux-yocto.inc b/meta/recipes-kernel/linux/<wbr>linux-yocto.inc<br>
index 98a48ec..d979662 100644<br>
--- a/meta/recipes-kernel/linux/<wbr>linux-yocto.inc<br>
+++ b/meta/recipes-kernel/linux/<wbr>linux-yocto.inc<br>
@@ -55,6 +55,7 @@ do_install_append(){<br>
}<br>
<br>
# extra tasks<br>
+addtask kernel_version_sanity_check after do_kernel_checkout before do_compile<br>
addtask kernel_link_images after do_compile before do_install<br>
addtask validate_branches before do_patch after do_kernel_checkout<br>
addtask kernel_configcheck after do_configure before do_compile<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.5<br>
<br>
--<br>
______________________________<wbr>_________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"</div>
</div></div>