Bug 3645

Summary: Using wrong data when 2 recipes provide same runtime package
Product: [Build System, Metadata & Runtime] BitBake Reporter: Martin Jansa <Martin.Jansa>
Component: bitbakeAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: poky.bs.watcher, poky.watcher, sgw
Version: unspecified   
Target Milestone: 1.4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---
Attachments:
Description Flags
0001-package-test-add-test-recipes.patch.patch none

Description Martin Jansa 2012-12-26 19:55:12 UTC
Created attachment 992 [details]
0001-package-test-add-test-recipes.patch.patch

It's some sort of race condition, because it does not happen all the time, but often enough to be dangerous.

The same happens between systemd/udev when both gets build (systemd is not preferred provider for udev).

To reproduce use oe-core patch attached and run 'bitbake -k c', you can also 'bitbake -c cleansstate a b c' if it does not happen on first try.

'b.do_package_ipk' is referenceing WORKDIR from 'a' recipe:
ERROR: Error executing a python function in /OE/oe-core/openembedded-core/meta/recipes-extended/package-test/b.bb:
OSError: [Errno 2] No such file or directory: '/OE/oe-core/tmp-eglibc/work/all-oe-linux/a/1.0-r0/packages-split/b-dbg'

ERROR: The stack trace of python calls that resulted in this exception/failure was:
ERROR:   File "do_package_ipk", line 193, in <module>
ERROR: 
ERROR:   File "do_package_ipk", line 45, in do_package_ipk
ERROR: 
ERROR: The code that was being executed was:
ERROR:      0189:        bb.utils.unlockfile(lf)
ERROR:      0190:
ERROR:      0191:
ERROR:      0192:
ERROR:  *** 0193:do_package_ipk(d)
ERROR:      0194:
ERROR: [From file: 'do_package_ipk', lineno: 193, function: <module>]
ERROR:      0041:        basedir = os.path.join(os.path.dirname(root))
ERROR:      0042:        arch = localdata.getVar('PACKAGE_ARCH', True)
ERROR:      0043:        pkgoutdir = "%s/%s" % (outdir, arch)
ERROR:      0044:        bb.mkdirhier(pkgoutdir)
ERROR:  *** 0045:        os.chdir(root)
ERROR:      0046:        from glob import glob
ERROR:      0047:        g = glob('*')
ERROR:      0048:        try:
ERROR:      0049:            del g[g.index('CONTROL')]
ERROR: [From file: 'do_package_ipk', lineno: 45, function: do_package_ipk]
ERROR: Function failed: do_package_ipk
ERROR: Logfile of failure stored in: /OE/oe-core/tmp-eglibc/work/all-oe-linux/b/1.0-r0/temp/log.do_package_write_ipk.18983
ERROR: Task 89 (/OE/oe-core/openembedded-core/meta/recipes-extended/package-test/b.bb, do_package_write_ipk) failed with exit code '1'
Comment 1 Richard Purdie 2013-01-21 14:18:16 UTC
A patch to stop bitbake and at least tell the user what is wrong and how to fix it:

diff --git a/meta/classes/packagedata.bbclass b/meta/classes/packagedata.bbclass
index 790d874..120cd64 100644
--- a/meta/classes/packagedata.bbclass
+++ b/meta/classes/packagedata.bbclass
@@ -1,7 +1,8 @@
 python read_subpackage_metadata () {
     import oe.packagedata
 
-    data = oe.packagedata.read_pkgdata(d.getVar('PN', True), d)
+    pn = d.getVar('PN', True)
+    data = oe.packagedata.read_pkgdata(pn, d)
 
     for key in data.keys():
         d.setVar(key, data[key])
@@ -9,5 +10,9 @@ python read_subpackage_metadata () {
     for pkg in d.getVar('PACKAGES', True).split():
         sdata = oe.packagedata.read_subpkgdata(pkg, d)
         for key in sdata.keys():
+            if key == "PN":
+                if sdata[key] != pn:
+                    bb.fatal("Recipe %s is trying to create package %s which was already written by recipe %s. This will cause corruption, plea
+                continue
             d.setVar(key, sdata[key])
 }

For the attached test case (which was extremely helpful btw), this results in:

ERROR: Recipe a is trying to create package d which was already written by recipe b. This will cause corruption, please resolve this and only provide the package from one recipe or the other or only build one of the recipes.