]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
staging: Fix rare sysroot corruption issue
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 16 May 2022 10:12:18 +0000 (11:12 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 16 May 2022 22:18:23 +0000 (23:18 +0100)
We've seen failures on the autobuilder in oe-selftest where things which should
be in the sysroot aren't. The exact steps to reproduce the exact failure are
elusive and probably hash equivalance dependency but this set of steps does
reproduce corruption which is probably of the same origin:

Add DISTRO_FEATURES += "systemd"

  bitbake dbus

Remove DISTRO_FEATURES += "systemd"

  bitbake dbus
  bitbake dbus -c clean
  bitbake dbus -c configure

Add DISTRO_FEATURES += "systemd"

  bitbake quilt-native
  bitbake dbus -c populate_sysroot

Remove DISTRO_FEATURES += "systemd"

  bitbake dbus -c compile

Where dbus will now fail as the compiler was no longer in the sysroot.

This works by clearing x11 and other values out of DISTRO_FEATURES so the x11
dependencies are removed from the sysroot. The configure stamp remains valid so
when the original configuration is restored, it becomes valid again but a load
of the sysroot disappeared and build failures result.

Fix this by removing stamps when we remove things from the sysroot.

Depends on a change to bitbake build.py to add the clean_stamp API.

[YOCTO #14790]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/staging.bbclass

index 9fc8f4f2839b284ff6b02fbd10e7f71531ba86d5..8372a4574ace27f3568aa7884667f6d05db00512 100644 (file)
@@ -404,7 +404,9 @@ python extend_recipe_sysroot() {
     # All files that we're going to be installing, to find conflicts.
     fileset = {}
 
+    invalidate_tasks = set()
     for f in os.listdir(depdir):
+        removed = []
         if not f.endswith(".complete"):
             continue
         f = depdir + "/" + f
@@ -414,6 +416,28 @@ python extend_recipe_sysroot() {
             sstate_clean_manifest(depdir + "/" + lnk, d, canrace=True, prefix=workdir)
             os.unlink(f)
             os.unlink(f.replace(".complete", ""))
+            removed.append(os.path.basename(f.replace(".complete", "")))
+
+        # If we've removed files from the sysroot above, the task that installed them may still
+        # have a stamp file present for the task. This is probably invalid right now but may become
+        # valid again if the user were to change configuration back for example. Since we've removed
+        # the files a task might need, remove the stamp file too to force it to rerun.
+        # YOCTO #14790
+        if removed:
+            for i in glob.glob(depdir + "/index.*"):
+                if i.endswith("." + mytaskname):
+                    continue
+                with open(i, "r") as f:
+                    for l in f:
+                        if l.startswith("TaskDeps:"):
+                            continue
+                        l = l.strip()
+                        if l in removed:
+                            invalidate_tasks.add(i.rsplit(".", 1)[1])
+                            break
+    for t in invalidate_tasks:
+        bb.note("Invalidating stamps for task %s" % t)
+        bb.build.clean_stamp(t, d)
 
     installed = []
     for dep in configuredeps: