update-alternatives: Simplfy variable dependency logic

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.

(From OE-Core rev: bd8fc4c59a137a37bd7a54f398949617982d447e)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2025-06-04 16:56:25 +01:00
parent 4c5831e8eb
commit e492016a7b

View 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