[gnome-continuous-yocto/gnomeostree-3.28-rocko: 5297/8267] staging: Remove uninstalled dependencies from sysroots



commit faf70253bae495b1c366171339073174fd6ebb76
Author: Richard Purdie <richard purdie linuxfoundation org>
Date:   Thu Mar 23 16:35:30 2017 +0000

    staging: Remove uninstalled dependencies from sysroots
    
    Currently, if something is added to a sysroot, its hash remains unchanged,
    and it continues to be buildable, it doesn't get removed from the sysroot.
    
    This patch handles the case where something is removed from DEPENDS or
    [depends].
    
    It does introduce its own issue where something could get removed even
    though some other task in parallel may have the same requirement. This
    case should be extrememly rare and fixing the more common DEPENDS removal
    is likely the bigger win though.
    
    (From OE-Core rev: 06227bc5e533841ab12cde84a6ed6f8b8ddeb5cb)
    
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 meta/classes/staging.bbclass |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
index 6dd21e8..27fcd1e 100644
--- a/meta/classes/staging.bbclass
+++ b/meta/classes/staging.bbclass
@@ -469,6 +469,8 @@ python extend_recipe_sysroot() {
     multilibs = {}
     manifests = {}
 
+    installed = []
+
     for f in os.listdir(depdir):
         if not f.endswith(".complete"):
             continue
@@ -487,6 +489,9 @@ python extend_recipe_sysroot() {
         if mytaskname in ["do_sdk_depends", "do_populate_sdk_ext"] and c.endswith("-initial"):
             bb.note("Skipping initial setscene dependency %s for installation into the sysroot" % c)
             continue
+
+        installed.append(c)
+
         if os.path.exists(depdir + "/" + c):
             lnk = os.readlink(depdir + "/" + c)
             if lnk == c + "." + taskhash and os.path.exists(depdir + "/" + c + ".complete"):
@@ -601,6 +606,29 @@ python extend_recipe_sysroot() {
         c = setscenedeps[dep][0]
         os.symlink(manifests[dep], depdir + "/" + c + ".complete")
 
+    # We want to remove anything which this task previously installed but is no longer a dependency
+    # This could potentially race against another task which also installed it but still requires it
+    # but the alternative is not doing anything at all and that race window should be small enough
+    # to be insignificant
+    taskindex = depdir + "/" + "index." + mytaskname
+    if os.path.exists(taskindex):
+        with open(taskindex, "r") as f:
+            for l in f:
+                l = l.strip()
+                if l not in installed:
+                    l = depdir + "/" + l
+                    if not os.path.exists(l):
+                        # Was likely already uninstalled
+                        continue
+                    bb.note("Task %s no longer depends on %s, removing from sysroot" % (mytaskname, l))
+                    lnk = os.readlink(l)
+                    sstate_clean_manifest(depdir + "/" + lnk, d, workdir)
+                    os.unlink(l)
+                    os.unlink(l + ".complete")
+    with open(taskindex, "w") as f:
+        for l in sorted(installed):
+            f.write(l + "\n")
+
     bb.utils.unlockfile(lock)
 }
 extend_recipe_sysroot[vardepsexclude] += "MACHINE_ARCH PACKAGE_EXTRA_ARCHS SDK_ARCH BUILD_ARCH SDK_OS 
BB_TASKDEPDATA"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]