Skip to contentSkip to conversation

data: Ensure functions are defined in a deterministic order

PATCH New Richard Purdie 1 participant 1 message Oct 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 data: Ensure functions are defined in a deterministic order

When writing functions into shell scripts, write then in a deterministic order. This is unlikely to affect anything at runtime but it does change the signatures of the generated useradd postinst scripts in OE-Core and is a good thing to be consistent about in general.

---
 lib/bb/data.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/data.py +1 -1
index 97022853ca..9d18b1e2bf 100644
@@ -226,7 +226,7 @@ def emit_func(func, o=sys.__stdout__, d = init()):
         deps = newdeps
         seen |= deps
         newdeps = set()
-        for dep in deps:
+        for dep in sorted(deps):
             if d.getVarFlag(dep, "func", False) and not d.getVarFlag(dep, "python", False):
                emit_var(dep, o, d, False) and o.write('\n')
                newdeps |=  bb.codeparser.ShellParser(dep, logger).parse_shell(d.getVar(dep))
Signature · 1 line
2.32.0