summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorMing Liu <ming.liu@toradex.com>2021-04-16 12:28:25 +0200
committerMax Krummenacher <max.krummenacher@toradex.com>2021-05-24 18:25:16 +0200
commit59e68224cba5579db63aed4f931e7372d04c170a (patch)
treedc91775b1d58546e2765a82cfdfe7de08235701a /classes
parent751a426c155500ac656b6d832c4f62d5c58d21ec (diff)
toradex-sanity.bbclass: introduce bbclass file
I have observed a following OE build issue with the latest dunfell-5.x.y, as follows: ``` ERROR: OE-core's config sanity checker detected a potential misconfiguration. Either fix the cause of this error or at your own risk disable the checker (see sanity.conf). Following is the list of potential problems / advisories: TMPDIR changed to include path filtering from the pseudo database. It is recommended to use a clean TMPDIR with the new pseudo path filtering so TMPDIR would need to be removed to continue. ``` this is due to the ABI VERSION changed in OE, usually we should remove the TMPDIR and rebuild when seeing this error, but it's not enough for Toradex builds, since we have split DEPLOY_DIR out of TMPDIR, so we should also check the ABI VERSION change in DEPLOY_DIR, or else it might not comply the OE layer. We should warn the end users about this risk, let's add a toradex sanity check bbclass for that. We can also add some other basic Toradex specific sanity checks, for instance, for fitimage, the end users must inherit toradex-fitimage rather than kernel-fitimage. Related-to: ELB-3944 Signed-off-by: Ming Liu <ming.liu@toradex.com> (cherry picked from commit 943f7da5a1cbbf695c3385b59e33aaea0c87904c)
Diffstat (limited to 'classes')
-rw-r--r--classes/toradex-sanity.bbclass74
1 files changed, 74 insertions, 0 deletions
diff --git a/classes/toradex-sanity.bbclass b/classes/toradex-sanity.bbclass
new file mode 100644
index 0000000..b30eaa2
--- /dev/null
+++ b/classes/toradex-sanity.bbclass
@@ -0,0 +1,74 @@
+# Sanity check the Toradex setup for common misconfigurations
+
+TORADEX_SANITY_ABIFILE ?= "${DEPLOY_DIR}/abi_version"
+
+#
+# Check the 'ABI' of DEPLOY_DIR
+#
+def toradex_check_abichanges(status, d):
+ current_abi = d.getVar('OELAYOUT_ABI')
+ abifile = d.getVar('TORADEX_SANITY_ABIFILE')
+ if os.path.exists(abifile):
+ with open(abifile, "r") as f:
+ abi = f.read().strip()
+ if not abi.isdigit():
+ with open(abifile, "w") as f:
+ f.write(current_abi)
+ elif (abi != current_abi):
+ # Code to convert from one ABI to another could go here if possible.
+ status.addresult("Error, DEPLOY_DIR has changed its layout version number (%s to %s) and you need to either rebuild, revert or adjust it at your own risk.\n" % (abi, current_abi))
+ else:
+ bb.utils.mkdirhier(os.path.dirname(abifile))
+ with open(abifile, "w") as f:
+ f.write(current_abi)
+
+#
+# Check fitimage bbclass
+#
+def toradex_check_fitimage(status, d):
+ if bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', True, False, d):
+ if bb.utils.contains('KERNEL_CLASSES', 'toradex-fitimage', False, True, d):
+ status.addresult("Error, to build fitImage within Toradex layers, please add toradex-fitimage rather than kernel-fitimage in KERNEL_CLASSES.\n")
+
+def toradex_raise_sanity_error(msg, d):
+ if d.getVar("SANITY_USE_EVENTS") == "1":
+ bb.event.fire(bb.event.SanityCheckFailed(msg), d)
+ return
+
+ bb.fatal("Toradex' config sanity checker detected a potential misconfiguration.\n"
+ "Please fix the cause of this error then you can continue to build.\n"
+ "Following is the list of potential problems / advisories:\n"
+ "\n%s" % msg)
+
+def toradex_check_sanity(sanity_data):
+ class SanityStatus(object):
+ def __init__(self):
+ self.messages = ""
+ self.reparse = False
+
+ def addresult(self, message):
+ if message:
+ self.messages = self.messages + message
+
+ status = SanityStatus()
+
+ toradex_check_abichanges(status, sanity_data)
+ toradex_check_fitimage(status, sanity_data)
+
+ if status.messages != "":
+ toradex_raise_sanity_error(sanity_data.expand(status.messages), sanity_data)
+
+addhandler toradex_check_sanity_eventhandler
+toradex_check_sanity_eventhandler[eventmask] = "bb.event.SanityCheck"
+
+python toradex_check_sanity_eventhandler() {
+ if bb.event.getName(e) == "SanityCheck":
+ sanity_data = copy_data(e)
+ if e.generateevents:
+ sanity_data.setVar("SANITY_USE_EVENTS", "1")
+ reparse = toradex_check_sanity(sanity_data)
+ e.data.setVar("BB_INVALIDCONF", reparse)
+ bb.event.fire(bb.event.SanityCheckPassed(), e.data)
+
+ return
+}