[OE-core] [PATCH 1/3] bbclass/sstate_readonly approach 1: add prefuncs to SSTATETASKS

Hongxu Jia hongxu.jia at windriver.com
Wed Aug 6 07:15:59 UTC 2014


Add prefuncs to SSTATETASKS 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 each SSTATETASKS 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}.

3. The checking time is postponed to SSTATETASKS, take db-native for example:
   if you tweak db-native's do_configure, the checking will occur at
   do_populate_sysroot time. The tasks 'do_compile', 'do_install' has
   been invoked.

...
$ bitbake db
ERROR: Read-only sstate-cache is enabled, the build of gettext-minimal-native
did not come from sstate-cache. Only the recipe listed in
SSTATECACHE_WHITELIST is allowed to build from source
ERROR: Function failed: sstate_readonly_check
ERROR: Logfile of failure stored in: tmp/work/x86_64-linux/gettext-minimal-native/0.18.3.2-r0/temp/log.do_populate_sysroot.23801
ERROR: Task 155 (poky/meta/recipes-core/gettext/gettext-minimal-native_0.18.3.2.bb, do_populate_sysroot) failed with exit code '1'
NOTE: Tasks Summary: Attempted 84 tasks of which 49 didn't need to be rerun and 1 failed.
...

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

diff --git a/meta/classes/sstate_readonly.bbclass b/meta/classes/sstate_readonly.bbclass
new file mode 100644
index 0000000..88b1c39
--- /dev/null
+++ b/meta/classes/sstate_readonly.bbclass
@@ -0,0 +1,38 @@
+# 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 ?= ""
+
+python () {
+    unique_tasks = set((d.getVar('SSTATETASKS', True) or "").split())
+    d.setVar('SSTATETASKS', " ".join(unique_tasks))
+    for task in unique_tasks:
+        d.prependVarFlag(task, 'prefuncs', "sstate_readonly_check")
+}
+
+_sstate_readonly_check[vardepsexclude] += "SSTATECACHE_WHITELIST"
+def _sstate_readonly_check(d):
+    whitelist = d.getVar('SSTATECACHE_WHITELIST', True) or ""
+    if whitelist != "":
+        pn = d.getVar('PN', True)
+        if pn not in whitelist.split():
+            msg =  'Read-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.fatal(msg)
+
+python sstate_readonly_check(){
+    _sstate_readonly_check(d)
+}
+
+python do_cleansstate_prepend() {
+        _sstate_readonly_check(d)
+}
+
+python do_cleanall_prepend() {
+    _sstate_readonly_check(d)
+}
+
-- 
1.9.1




More information about the Openembedded-core mailing list