]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
kernel-fitimage.bbclass: introduce get_fit_replacement_type function
authorMing Liu <liu.ming50@gmail.com>
Sat, 19 Mar 2022 12:32:19 +0000 (13:32 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Mar 2022 12:11:15 +0000 (12:11 +0000)
Avoid to set KERNEL_IMAGETYPE_REPLACEMENT in anonymous python function,
otherwise it chould not be overridden in config files, for instance,
it's being set now in meta/lib/oeqa/selftest/cases/fitimage.py.

Introduce a get_fit_replacement_type function to get the default value
of KERNEL_IMAGETYPE_REPLACEMENT, and it could be overridden in config
files.

Signed-off-by: Ming Liu <liu.ming50@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/kernel-fitimage.bbclass

index 8a9b195d6ee2a31ffbc1a2c462fa52ab61f8d0bb..df5de0427b108c1d99f25328bc0efe72d847578e 100644 (file)
@@ -1,14 +1,9 @@
 inherit kernel-uboot kernel-artifact-names uboot-sign
 
-KERNEL_IMAGETYPE_REPLACEMENT = ""
-
-python __anonymous () {
+def get_fit_replacement_type(d):
     kerneltypes = d.getVar('KERNEL_IMAGETYPES') or ""
+    replacementtype = ""
     if 'fitImage' in kerneltypes.split():
-        depends = d.getVar("DEPENDS")
-        depends = "%s u-boot-tools-native dtc-native" % depends
-        d.setVar("DEPENDS", depends)
-
         uarch = d.getVar("UBOOT_ARCH")
         if uarch == "arm64":
             replacementtype = "Image"
@@ -22,15 +17,18 @@ python __anonymous () {
             replacementtype = "linux.bin"
         else:
             replacementtype = "zImage"
+    return replacementtype
 
-        d.setVar("KERNEL_IMAGETYPE_REPLACEMENT", replacementtype)
+KERNEL_IMAGETYPE_REPLACEMENT ?= "${@get_fit_replacement_type(d)}"
+DEPENDS:append = " ${@'u-boot-tools-native dtc-native' if 'fitImage' in (d.getVar('KERNEL_IMAGETYPES') or '').split() else ''}"
 
+python __anonymous () {
         # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
         # to kernel.bbclass . We have to override it, since we pack zImage
         # (at least for now) into the fitImage .
         typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or ""
         if 'fitImage' in typeformake.split():
-            d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', replacementtype))
+            d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', d.getVar('KERNEL_IMAGETYPE_REPLACEMENT')))
 
         image = d.getVar('INITRAMFS_IMAGE')
         if image: