]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
update-alternatives: Simplfy variable dependency logic
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 4 Jun 2025 15:56:25 +0000 (16:56 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 5 Jun 2025 20:19:08 +0000 (21:19 +0100)
When looking at bitbake parsing speed issues, I noticed a lot of weird looking
variables from the update-alternatives class. It is possible this was written
before variable dependencies could handle flags. It can handle flags now so
simplfy the code to take advantage of that and avoid the indirection variables.

The win here is a significant reduction in the number of variables, which
in turn significantly reduces the looping bitbake's taskhash calculation code
needs to do.

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

index b153e1b297326fc0340de085d87aa7c841087af4..5f40dc23ea31ceea92f32ee68ed13ac4b1af497d 100644 (file)
@@ -73,24 +73,6 @@ UPDALTVARS  = "ALTERNATIVE ALTERNATIVE_LINK_NAME ALTERNATIVE_TARGET ALTERNATIVE_
 
 PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
 
-def gen_updatealternativesvardeps(d):
-    pkgs = (d.getVar("PACKAGES") or "").split()
-    vars = (d.getVar("UPDALTVARS") or "").split()
-
-    # First compute them for non_pkg versions
-    for v in vars:
-        for flag in sorted((d.getVarFlags(v) or {}).keys()):
-            if flag == "doc" or flag == "vardeps" or flag == "vardepsexp":
-                continue
-            d.appendVar('%s_VARDEPS' % (v), ' %s:%s' % (flag, d.getVarFlag(v, flag, False)))
-
-    for p in pkgs:
-        for v in vars:
-            for flag in sorted((d.getVarFlags("%s:%s" % (v,p)) or {}).keys()):
-                if flag == "doc" or flag == "vardeps" or flag == "vardepsexp":
-                    continue
-                d.appendVar('%s_VARDEPS_%s' % (v,p), ' %s:%s' % (flag, d.getVarFlag('%s:%s' % (v,p), flag, False)))
-
 def ua_extend_depends(d):
     if not 'virtual/update-alternatives' in d.getVar('PROVIDES'):
         d.appendVar('DEPENDS', ' virtual/${MLPREFIX}update-alternatives')
@@ -112,9 +94,6 @@ python __anonymous() {
     if not update_alternatives_enabled(d):
         return
 
-    # compute special vardeps
-    gen_updatealternativesvardeps(d)
-
     # extend the depends to include virtual/update-alternatives
     ua_extend_depends(d)
 }
@@ -124,13 +103,20 @@ def gen_updatealternativesvars(d):
     pkgs = (d.getVar("PACKAGES") or "").split()
     vars = (d.getVar("UPDALTVARS") or "").split()
 
+    # First compute them for non_pkg versions
     for v in vars:
-        ret.append(v + "_VARDEPS")
+        for flag in sorted((d.getVarFlags(v) or {}).keys()):
+            if flag == "doc" or flag == "vardeps" or flag == "vardepsexp":
+                continue
+            ret.append(v + "[" + flag + "]")
 
     for p in pkgs:
         for v in vars:
-            ret.append(v + ":" + p)
-            ret.append(v + "_VARDEPS_" + p)
+            for flag in sorted((d.getVarFlags("%s:%s" % (v,p)) or {}).keys()):
+                if flag == "doc" or flag == "vardeps" or flag == "vardepsexp":
+                    continue
+                ret.append('%s:%s' % (v,p) + "[" + flag + "]")
+
     return " ".join(ret)
 
 # Now the new stuff, we use a custom function to generate the right values