diff mbox series

[1/2] rm_work: also remove work directories for do_populate_sdk

Message ID 20261127124657.769093-2-sean@geanix.com
State Under Review
Headers show
Series rm_work: remove work directories for do_populate_sdk | expand

Commit Message

Sean Nyekjaer Nov. 27, 2026, 12:46 p.m. UTC
do_rm_work_all only runs before do_build, so "bitbake <image> -c
populate_sdk" leaves the work directories of all recipes the SDK
depends on behind.

Add do_rm_work_populate_sdk before do_populate_sdk to run do_rm_work
for those recipes, without building the image itself. Keep it out of
the do_populate_sdk signature, and don't let extend_recipe_sysroot
stage the sysroots of the recipes the do_rm_work tasks depend on.

[YOCTO #15824]

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
 meta/classes-global/staging.bbclass |  3 +++
 meta/classes/rm_work.bbclass        | 14 ++++++++++++++
 meta/lib/oe/sstatesig.py            |  5 +++++
 3 files changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/meta/classes-global/staging.bbclass b/meta/classes-global/staging.bbclass
index 20340a16e1..558d808243 100644
--- a/meta/classes-global/staging.bbclass
+++ b/meta/classes-global/staging.bbclass
@@ -338,6 +338,9 @@  python extend_recipe_sysroot() {
             start.add(dep2)
         start.remove(dep)
 
+    # Don't stage the sysroots of the recipes the do_rm_work tasks depend on
+    start = set(dep for dep in start if not setscenedeps[dep][1].startswith("do_rm_work"))
+
     #bb.note(" start3 is %s" % str(start))
 
     # Create collapsed do_populate_sysroot -> do_populate_sysroot tree
diff --git a/meta/classes/rm_work.bbclass b/meta/classes/rm_work.bbclass
index 7cb8a325b2..12cb70d55d 100644
--- a/meta/classes/rm_work.bbclass
+++ b/meta/classes/rm_work.bbclass
@@ -131,6 +131,20 @@  do_rm_work_all[recrdeptask] = "do_rm_work"
 do_rm_work_all[noexec] = "1"
 addtask rm_work_all before do_build
 
+# Remove the work directories of the recipes do_populate_sdk depends on.
+# Only the dependencies on other recipes are copied, so the image isn't built.
+do_rm_work_populate_sdk () {
+    :
+}
+do_rm_work_populate_sdk[recrdeptask] = "do_rm_work"
+do_rm_work_populate_sdk[depends] = "${@d.getVarFlag('do_populate_sdk', 'depends') or ''}"
+do_rm_work_populate_sdk[rdepends] = "${@d.getVarFlag('do_populate_sdk', 'rdepends') or ''}"
+do_rm_work_populate_sdk[noexec] = "1"
+python () {
+    if d.getVarFlag('do_populate_sdk', 'task'):
+        bb.build.addtask('do_rm_work_populate_sdk', 'do_populate_sdk', '', d)
+}
+
 do_populate_sdk[postfuncs] += "rm_work_populatesdk"
 rm_work_populatesdk () {
     :
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py
index c0e581d0c8..cbe210215e 100644
--- a/meta/lib/oe/sstatesig.py
+++ b/meta/lib/oe/sstatesig.py
@@ -39,6 +39,11 @@  def sstate_rundepfilter(siggen, fn, recipename, task, dep, depname, dataCaches):
     if task == "do_rm_work":
         return False
 
+    # Skip the do_rm_work_populate_sdk task signature, it only removes work
+    # directories and must not change the do_populate_sdk signature
+    if deptaskname == "do_rm_work_populate_sdk":
+        return False
+
     # (Almost) always include our own inter-task dependencies (unless it comes
     # from a mcdepends). The exception is the special
     # do_kernel_configme->do_unpack_and_patch dependency from archiver.bbclass.