Skip to content

Commit

Permalink
Store BBLAYERS and local.conf fragments in specification order again
Browse files Browse the repository at this point in the history
According to c9326cc, we had issues with producing a deterministic
order for those config elements. As sorting is a rather blunt method of
resolving it and as ordering plays a role in bitbake's processing of the
configs, we should try harder to provide more user control over that.

A key role in this play ordered dictionaries that report their content
the same order it was added. We already use OrderedDict for merging the
config dict across includes, see _internal_dict_merge. Includes are
merged recursively, depths-first, thus are expected to be deterministic
and predictable. We just need to convert building the repo_dict to
OrderedDict, and them sorted() can be removed.

Closes: #36

Reported-by: Marius Kriegerowski <marius.kriegerowski@gfz-potsdam.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
jan-kiszka committed Dec 14, 2020
1 parent 87af46f commit d3f1767
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions kas/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""

import os
from collections import OrderedDict
from .repos import Repo
from .includehandler import IncludeHandler, IncludeException

Expand Down Expand Up @@ -87,7 +88,7 @@ def _get_repo_dict(self):
"""
repo_config_dict = self._config.get('repos', {})
repo_defaults = self._config.get('defaults', {}).get('repos', {})
repo_dict = {}
repo_dict = OrderedDict()
repo_fallback_path = os.path.dirname(self.filenames[0])
for repo in repo_config_dict:
repo_config_dict[repo] = repo_config_dict[repo] or {}
Expand Down Expand Up @@ -128,7 +129,7 @@ def _get_conf_header(self, header_name):
Returns the local.conf header
"""
header = ''
for key, value in sorted(self._config.get(header_name, {}).items()):
for key, value in self._config.get(header_name, {}).items():
header += '# {}\n{}\n'.format(key, value)
return header

Expand Down
4 changes: 2 additions & 2 deletions kas/libcmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ def _write_bblayers_conf(ctx):
fds.write(ctx.config.get_bblayers_conf_header())
fds.write('BBLAYERS ?= " \\\n ')
fds.write(' \\\n '.join(
sorted(layer for repo in ctx.config.get_repos()
for layer in repo.layers)))
layer for repo in ctx.config.get_repos()
for layer in repo.layers))
fds.write('"\n')

def _write_local_conf(ctx):
Expand Down

0 comments on commit d3f1767

Please sign in to comment.