parse: add bitbake version check via bitbake_min_version keyword
PATCH 1/1 parse: add bitbake version check via bitbake_min_version keyword
From: Alexander Kanavin <[email protected]>
Layers (e.g. openembedded-core) can specify in conf/layer.conf:
bitbake_min_version 2.15.2
and if bitbake has a lesser version it will stop itself, as early as possible, to avoid hitting cryptic compatibility issues later on, with this error:
bb.parse.ParseError: ParseError at /home/alex/bitbake-builds/poky-master-poky-distro_poky-machine_qemux86-64/layers/openembedded-core/meta/conf/layer.conf:1: Bitbake version 2.15.3 is required and version 2.15.2 is used
Note that sanity.bbclass in oe-core has a similar check, but as this thread [1] highlighted, compatibility issues can stop bitbake sooner and the check is never reached, leaving the user with confusing errors.
[1] https://lists.openembedded.org/g/openembedded-core/topic/115724008
--- bitbake/lib/bb/parse/ast.py | 12 ++++++++++++ bitbake/lib/bb/parse/parse_py/ConfHandler.py | 10 ++++++++++ 2 files changed, 22 insertions(+)
bitbake/lib/bb/parse/ast.py +12 -0
@@ -412,6 +412,14 @@ class AddFragmentsNode(AstNode): else: bb.error("Could not find fragment {} in enabled layers: {}".format(f, layers)) +class BbMinVersionNode(AstNode): + def __init__(self, filename, lineno, bb_min_version): + AstNode.__init__(self, filename, lineno) + self.bb_min_version = bb_min_version + + def eval(self, data): + bb.parse.ConfHandler.check_bb_version(self.filename, self.lineno, data.expand(self.bb_min_version)) + def handleInclude(statements, filename, lineno, m, force): statements.append(IncludeNode(filename, lineno, m.group(1), force))
@@ -466,6 +474,10 @@ def handleAddFragments(statements, filename, lineno, m): builtin_fragments_variable = m.group(4) statements.append(AddFragmentsNode(filename, lineno, fragments_path_prefix, fragments_variable, flagged_variables_list_variable, builtin_fragments_variable)) +def handleBbMinVersion(statements, filename, lineno, m): + bb_min_version = m.group(1) + statements.append(BbMinVersionNode(filename, lineno, bb_min_version)) + def runAnonFuncs(d): code = [] for funcname in d.getVar("__BBANONFUNCS", False) or []:
bitbake/lib/bb/parse/parse_py/ConfHandler.py +10 -0
@@ -49,6 +49,7 @@ __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\]$" ) __addpylib_regexp__ = re.compile(r"addpylib\s+(.+)\s+(.+)" ) __addfragments_regexp__ = re.compile(r"addfragments\s+(.+)\s+(.+)\s+(.+)\s+(.+)" ) +__bitbake_min_version_regexp__ = re.compile(r"bitbake_min_version\s+(.+)" ) def init(data): return
@@ -102,6 +103,10 @@ def include_single_file(parentfn, fn, lineno, data, error_out): else: raise ParseError("Error parsing %s: %s" % (fn, exc.strerror), parentfn, lineno) +def check_bb_version(fn, lineno, min_version): + if bb.utils.vercmp_string_op(bb.__version__, min_version, "<"): + raise ParseError('Bitbake version %s is required and version %s is used\n' % (min_version, bb.__version__), fn, lineno) + # We have an issue where a UI might want to enforce particular settings such as # an empty DISTRO variable. If configuration files do something like assigning # a weak default, it turns out to be very difficult to filter out these changes,
@@ -213,6 +218,11 @@ def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True): ast.handleAddFragments(statements, fn, lineno, m) return + m = __bitbake_min_version_regexp__.match(s) + if m: + ast.handleBbMinVersion(statements, fn, lineno, m) + return + raise ParseError("unparsed line: '%s'" % s, fn, lineno); # Add us to the handlers list
Signature · 1 line
2.39.5
On Mon, 2025-10-27 at 19:12 +0100, Alexander Kanavin via lists.openembedded.org wrote:
From: Alexander Kanavin <[email protected]>
Layers (e.g. openembedded-core) can specify in conf/layer.conf:
bitbake_min_version 2.15.2
and if bitbake has a lesser version it will stop itself, as early as possible, to avoid hitting cryptic compatibility issues later on, with this error:
bb.parse.ParseError: ParseError at /home/alex/bitbake-builds/poky-master-poky-distro_poky-machine_qemux86-64/layers/openembedded-core/meta/conf/layer.conf:1: Bitbake version 2.15.3 is required and version 2.15.2 is used
Note that sanity.bbclass in oe-core has a similar check, but as this thread [1] highlighted, compatibility issues can stop bitbake sooner and the check is never reached, leaving the user with confusing errors.
[1] https://lists.openembedded.org/g/openembedded-core/topic/115724008
---
bitbake/lib/bb/parse/ast.py | 12 ++++++++++++ bitbake/lib/bb/parse/parse_py/ConfHandler.py | 10 ++++++++++
2 files changed, 22 insertions(+)
Why not just allow a BB_MINVERSION variable in layer.conf which we check? Do we really need a special new syntax just for this which then has to be documented?
Cheers,
Richard
Quoted 3 lines · Richard Purdie
Why not just allow a
BB_MINVERSIONvariable in layer.conf which we check? Do we really need a special new syntax just for this which then has to be documented?
We don't, I'm just unsure where to perform the check. I'm somewhat reluctant to insert a special case like this into DataSmart's setVar(), even though that would ensure the check is peformed as soon as possible.
Alex