[OE-core] [PATCH 2/3] bbclass/sstate_readonly_2 approach 2: add event handler at TaskStarted time

Hongxu Jia hongxu.jia at windriver.com
Wed Aug 6 07:16:00 UTC 2014


Add event handler at TaskStarted time to handle the sstate-cache
read-only cheking. If read-only sstate-cache enable, and the building recipe
not in the ${SSTATECACHE_WHITELIST}, it trigered an instant error.

Flaws:
1. For every task, there is a read-only sstate-cache checking, it increased
   the build loads.

2. The instant error breaks the building randomly while there are multible
   recipes not in the ${SSTATECACHE_WHITELIST}, and also could not list all
   the missing recipes which sould be added to ${SSTATECACHE_WHITELIST}.

...
$ bitbake db
ERROR:
Read-only sstate-cache is enabled, the build of ncurses-native
did not come from sstate-cache. Only the recipe listed in
SSTATECACHE_WHITELIST is allowed to build from source
ERROR: Execution of event handler 'sstate_readonly_eventhandler' failed
ERROR: Task 350 (virtual:native:poky/meta/recipes-core/ncurses/ncurses_5.9.bb, do_fetch) failed with exit code '1'
ERROR:
Read-only sstate-cache is enabled, the build of gcc-cross-initial-i586
did not come from sstate-cache. Only the recipe listed in
SSTATECACHE_WHITELIST is allowed to build from source
ERROR: Execution of event handler 'sstate_readonly_eventhandler' failed
ERROR: Task 290 (poky/meta/recipes-devtools/gcc/gcc-cross-initial_4.9.bb, do_fetch) failed with exit code '1'
...

Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
---
 meta/classes/sstate_readonly_2.bbclass | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 meta/classes/sstate_readonly_2.bbclass

diff --git a/meta/classes/sstate_readonly_2.bbclass b/meta/classes/sstate_readonly_2.bbclass
new file mode 100644
index 0000000..871b56f
--- /dev/null
+++ b/meta/classes/sstate_readonly_2.bbclass
@@ -0,0 +1,25 @@
+# 1) If ${SSTATECACHE_WHITELIST} is "", it means read-only sstate-cache
+#    disabled;
+#
+# 2) If read-only sstate-cache enabled and the recipe's ${PN} not listed
+#    in ${SSTATECACHE_WHITELIST}, the build from source will triger an
+#    instant error;
+SSTATECACHE_WHITELIST ?= ""
+
+addhandler sstate_readonly_eventhandler
+sstate_readonly_eventhandler[eventmask] = "bb.build.TaskStarted"
+python sstate_readonly_eventhandler() {
+    d = e.data
+    whitelist = d.getVar('SSTATECACHE_WHITELIST', True) or ""
+    if whitelist != "":
+        taskname = d.getVar('BB_CURRENTTASK', True)
+        if not taskname.startswith('do_'):
+            taskname = 'do_%s' % taskname
+        if not taskname.endswith("_setscene") and taskname != "do_setscene":
+            pn = d.getVar('PN', True)
+            if pn not in whitelist.split():
+                msg =  '\nRead-only sstate-cache is enabled, the build of %s\n' % pn
+                msg += 'did not come from sstate-cache. Only the recipe listed in\n'
+                msg += 'SSTATECACHE_WHITELIST is allowed to build from source'
+                bb.msg.fatal('sstate', msg)
+}
-- 
1.9.1




More information about the Openembedded-core mailing list