Skip to contentSkip to conversation

kernel.bbclass: avoid duplicates in KERNEL_IMAGETYPE_FOR_MAKE

PATCH Superseded Andre McCurdy 2 participants 3 messages May 14, 2018 – May 15, 2018

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kernel.bbclass: avoid duplicates in KERNEL_IMAGETYPE_FOR_MAKE

Currently if KERNEL_IMAGETYPES contains both vmlinux and vmlinux.gz, KERNEL_IMAGETYPE_FOR_MAKE will end up containing two copies of vmlinux, which will result in two calls to "make vmlinux" from kernel_do_compile().

Avoid duplicating vmlinux in KERNEL_IMAGETYPE_FOR_MAKE plus some minor non-functional updates to formatting and comments.

---
v2: refresh + make typeformake a set based on suggestion from Martin Hundeb�ll

 meta/classes/kernel.bbclass | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
meta/classes/kernel.bbclass +16 -12
index 6595a04..68d2185 100644
@@ -62,32 +62,36 @@ python __anonymous () {
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
-    kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
         types = (alttype + ' ' + types).strip()
     d.setVar('KERNEL_IMAGETYPES', types)
 
+    # KERNEL_IMAGETYPES may contain a mixture of image types supported directly
+    # by the kernel build system and types which are created by post-processing
+    # the output of the kernel build system (e.g. compressing vmlinux ->
+    # vmlinux.gz in kernel_do_compile()).
+    # KERNEL_IMAGETYPE_FOR_MAKE should contain only image types supported
+    # directly by the kernel build system.
     if not d.getVar('KERNEL_IMAGETYPE_FOR_MAKE'):
-        # some commonly used kernel images aren't generated by the kernel build system, such as vmlinux.gz
-        # typeformake lists only valid kernel make targets, and post processing can be done after the kernel
-        # is built (such as using gzip to compress vmlinux)
-        typeformake = types.replace('vmlinux.gz', 'vmlinux')
-        d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
+        typeformake = set()
+        for type in types.split():
+            if type == 'vmlinux.gz':
+                type = 'vmlinux'
+            typeformake.add(type)
+
+        d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', ' '.join(typeformake))
+
+    kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel"
+    imagedest = d.getVar('KERNEL_IMAGEDEST')
 
     for type in types.split():
         typelower = type.lower()
-        imagedest = d.getVar('KERNEL_IMAGEDEST')
-
         d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
-
         d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
-
         d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
-
         d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
-
         d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
     image = d.getVar('INITRAMFS_IMAGE')
Signature · 1 line
1.9.1
#1 lore raw

Hi Andre,

The autobuilder is failing in mips64 builds and I suspect this patch is to blame. For example
https://autobuilder.yocto.io/builders/nightly-mips64/builds/1001.

Ross

Quoted 78 lines · Andre McCurdy

Currently if KERNEL_IMAGETYPES contains both vmlinux and vmlinux.gz, KERNEL_IMAGETYPE_FOR_MAKE will end up containing two copies of vmlinux, which will result in two calls to "make vmlinux" from kernel_do_compile().

Avoid duplicating vmlinux in KERNEL_IMAGETYPE_FOR_MAKE plus some minor non-functional updates to formatting and comments.

---
v2: refresh + make typeformake a set based on suggestion from Martin Hundebøll

 meta/classes/kernel.bbclass | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
meta/classes/kernel.bbclass +16 -13
index 6595a04..68d2185 100644
@@ -62,32 +62,36 @@ python __anonymous () {
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
-    kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
         types = (alttype + ' ' + types).strip()
     d.setVar('KERNEL_IMAGETYPES', types)
 
+    # KERNEL_IMAGETYPES may contain a mixture of image types supported directly
+    # by the kernel build system and types which are created by post-processing
+    # the output of the kernel build system (e.g. compressing vmlinux ->
+    # vmlinux.gz in kernel_do_compile()).
+    # KERNEL_IMAGETYPE_FOR_MAKE should contain only image types supported
+    # directly by the kernel build system.
     if not d.getVar('KERNEL_IMAGETYPE_FOR_MAKE'):
-        # some commonly used kernel images aren't generated by the kernel build system, such as vmlinux.gz
-        # typeformake lists only valid kernel make targets, and post processing can be done after the kernel
-        # is built (such as using gzip to compress vmlinux)
-        typeformake = types.replace('vmlinux.gz', 'vmlinux')
-        d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
+        typeformake = set()
+        for type in types.split():
+            if type == 'vmlinux.gz':
+                type = 'vmlinux'
+            typeformake.add(type)
+
+        d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', ' '.join(typeformake))
+
+    kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel"
+    imagedest = d.getVar('KERNEL_IMAGEDEST')
 
     for type in types.split():
         typelower = type.lower()
-        imagedest = d.getVar('KERNEL_IMAGEDEST')
-
         d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
-
         d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
-
         d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
-
         d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
-
         d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
     image = d.getVar('INITRAMFS_IMAGE')
--

1.9.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#2 lore raw
Quoted 5 lines · Ross

Hi Andre,

The autobuilder is failing in mips64 builds and I suspect this patch is to blame. For example
https://autobuilder.yocto.io/builders/nightly-mips64/builds/1001.

Yes.

  $ bitbake-diffsigs ... ...
  basehash changed from 4c73c2d1e35cbb6229786c026945a8b7 to
1fc1b817a40ff6510533d3a3f3c06492
  Variable KERNEL_IMAGETYPE_FOR_MAKE value changed:
  "[-vmlinux.bin-] vmlinux {+vmlinux.bin+}"

I've sent a v3.

Quoted 81 lines

Ross

Quoted 78 lines · Andre McCurdy

Currently if KERNEL_IMAGETYPES contains both vmlinux and vmlinux.gz, KERNEL_IMAGETYPE_FOR_MAKE will end up containing two copies of vmlinux, which will result in two calls to "make vmlinux" from kernel_do_compile().

Avoid duplicating vmlinux in KERNEL_IMAGETYPE_FOR_MAKE plus some minor non-functional updates to formatting and comments.

---
v2: refresh + make typeformake a set based on suggestion from Martin Hundebøll

 meta/classes/kernel.bbclass | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
meta/classes/kernel.bbclass +16 -13
index 6595a04..68d2185 100644
@@ -62,32 +62,36 @@ python __anonymous () {
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
-    kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
         types = (alttype + ' ' + types).strip()
     d.setVar('KERNEL_IMAGETYPES', types)
 
+    # KERNEL_IMAGETYPES may contain a mixture of image types supported directly
+    # by the kernel build system and types which are created by post-processing
+    # the output of the kernel build system (e.g. compressing vmlinux ->
+    # vmlinux.gz in kernel_do_compile()).
+    # KERNEL_IMAGETYPE_FOR_MAKE should contain only image types supported
+    # directly by the kernel build system.
     if not d.getVar('KERNEL_IMAGETYPE_FOR_MAKE'):
-        # some commonly used kernel images aren't generated by the kernel build system, such as vmlinux.gz
-        # typeformake lists only valid kernel make targets, and post processing can be done after the kernel
-        # is built (such as using gzip to compress vmlinux)
-        typeformake = types.replace('vmlinux.gz', 'vmlinux')
-        d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
+        typeformake = set()
+        for type in types.split():
+            if type == 'vmlinux.gz':
+                type = 'vmlinux'
+            typeformake.add(type)
+
+        d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', ' '.join(typeformake))
+
+    kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel"
+    imagedest = d.getVar('KERNEL_IMAGEDEST')
 
     for type in types.split():
         typelower = type.lower()
-        imagedest = d.getVar('KERNEL_IMAGEDEST')
-
         d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
-
         d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
-
         d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
-
         d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
-
         d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
     image = d.getVar('INITRAMFS_IMAGE')
--

1.9.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core