[bitbake-devel] [PATCH] providers: Fix determinism issue

Richard Purdie richard.purdie at linuxfoundation.org
Sun Dec 10 22:35:47 UTC 2017

We saw builds where runtime providers were sometimes changing order and the
build result was therefore non-deterministic. For example it could show:

DEBUG: providers for lib32-initd-functions are: ['lib32-lsbinitscripts', 'lib32-initscripts']
DEBUG: providers for lib32-initd-functions are: ['lib32-initscripts', 'lib32-lsbinitscripts']

which could cause a test to pass or fail.

This change ensures we don't rely on the random order of dictonaries in
memory and act deterministically.

Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
 lib/bb/providers.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/bb/providers.py b/lib/bb/providers.py
index 443187e..c2aa98c 100644
--- a/lib/bb/providers.py
+++ b/lib/bb/providers.py
@@ -244,17 +244,17 @@ def _filterProviders(providers, item, cfgData, dataCache):
             pkg_pn[pn] = []
-    logger.debug(1, "providers for %s are: %s", item, list(pkg_pn.keys()))
+    logger.debug(1, "providers for %s are: %s", item, list(sorted(pkg_pn.keys())))
-    for pn in pkg_pn:
+    for pn in sorted(pkg_pn):
         sortpkg_pn[pn] = sortPriorities(pn, dataCache, pkg_pn)
         preferred_versions[pn] = findPreferredProvider(pn, cfgData, dataCache, sortpkg_pn[pn], item)
         if preferred_versions[pn][1]:
     # Now add latest versions
-    for pn in sortpkg_pn:
+    for pn in sorted(sortpkg_pn):
         if pn in preferred_versions and preferred_versions[pn][1]:
         preferred_versions[pn] = findLatestProvider(pn, cfgData, dataCache, sortpkg_pn[pn][0])

More information about the bitbake-devel mailing list