Bug 15377

Summary: ${D}/sysroot-only has race between do_populate_sysroot and do_package
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Callum Moffat <callum>
Component: coreAssignee: Ross Burton <ross.burton>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: meta.mr.watcher, meta.watcher, randy.macleod, richard.purdie
Version: unspecified   
Target Milestone: 5.1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Callum Moffat 2024-01-31 13:14:37 UTC
If both do_package and do_populate_sysroot tasks need to be run for a recipe, they may both run at the same time, because there isn't any specific dependency between them, besides the fact they both depend on do_install. If the /sysroot-only feature is used, it can cause an issue, because do_package may delete the /sysroot-only directory before do_populate_sysroot can copy it to the sysroot directory.

If you use /sysroot-only, you could force the dependency with the following snippet in recipe

do_package[depends] += "${PN}:do_populate_sysroot"

But I think in oe-core, staging.bbclass and/or package.bbclass should be adjusted to avoid this race by default. Either the task order could be specified, or do_package could be changed to avoid mutating ${D}.
Comment 1 Richard Purdie 2024-02-01 15:01:00 UTC
We need to stop it chamging ${D}
Comment 2 Randy MacLeod 2024-02-01 15:43:44 UTC
Not a common error and unlikely so medium priority.
Comment 3 Ross Burton 2024-10-10 11:42:52 UTC
Callum: where you using an old release when you found this bug?  It appears to be resolved with poky f2016af0399250d2378818758c704c37a96e2ed6 which was in 4.1 onwards.

Basically the patch does this:

-        shutil.rmtree(sysroot_only)

-    cmd = 'tar -cf - -C %s -p -S . | tar -xf - -C %s' % (dest, dvar)
+    cmd = 'tar --exclude=./sysroot-only -cf - -C %s -p -S . | tar -xf - -C %s' % (dest, dvar)

Closing as I believe this is fixed.
Comment 4 Callum Moffat 2024-10-10 12:08:09 UTC
Oh you're right I am not at 4.1 yet. Yeah that snippet would fix it. Thanks.