Skip to contentSkip to conversation

lib/bb/utils.py: Fix explode_dep_versions2() determinism issue

PATCH In review Richard Purdie 2 participants 2 messages May 9, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/bb/utils.py: Fix explode_dep_versions2() determinism issue

When we pass data into explode_dep_versions2(), we need to result to be able to be processed in a deterministic way so that we end up with consistent hash values. This means we need an ordered structure rather than an unordered one.

To do this, return an OrderedDict() rather than a dict().

bitbake/lib/bb/utils.py +2 -1
index 3544bbe..bf4ac40 100644
@@ -34,6 +34,7 @@ import traceback
 import errno
 import signal
 import ast
+import collections
 from commands import getstatusoutput
 from contextlib import contextmanager
 from ctypes import cdll
@@ -188,7 +189,7 @@ def explode_dep_versions2(s):
     "DEPEND1 (optional version) DEPEND2 (optional version) ..."
     and return a dictionary of dependencies and versions.
     """
-    r = {}
+    r = collections.OrderedDict()
     l = s.replace(",", "").split()
     lastdep = None
     lastcmp = ""
#1 lore raw
Quoted 9 lines · Richard Purdie

When we pass data into explode_dep_versions2(), we need to result to be able to be processed in a deterministic way so that we end up with consistent hash values. This means we need an ordered structure rather than an unordered one.

To do this, return an OrderedDict() rather than a dict().

Nicely spotted. Looks good.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics