layer.conf: add a bb_min_version statement to perform an early bitbake version check
RFC PATCH 1/1 layer.conf: add a bb_min_version statement to perform an early bitbake version check
From: Alexander Kanavin <[email protected]>
Please see the corresponding change in bitbake for the rationale.
--- meta/conf/layer.conf | 2 ++ 1 file changed, 2 insertions(+)
meta/conf/layer.conf +2 -0
@@ -1,3 +1,5 @@ +bitbake_min_version 2.15.2 + # We have a conf and classes directory, add to BBPATH BBPATH .= ":${LAYERDIR}" # We have recipes-* directories, add to BBFILES
Signature · 1 line
2.39.5
Hi Alex,
Quoted 4 lines · Alexander Kanavin via lists.openembedded.org
From: Alexander Kanavin <[email protected]>
Please see the corresponding change in bitbake for the rationale.
https://lore.kernel.org/bitbake-devel/[email protected]/
I would recommend that we specify which commit from bitbake we're talking about in the commit log here so it's easier to find it. Considering we anyway need the bitbake change to be merged before this one, that should be doable.
meta/conf/layer.conf line 2
Quoted 12 lines
Signed-off-by Alexander Kanavin <[email protected]>--- meta/conf/layer.conf | 2 ++ 1 file changed, 2 insertions(+)meta/conf/layer.conf +2
-0@@ -1,3 +1,5 @@ +bitbake_min_version 2.15.2 +
Does the sanity check still make sense if it simply cannot be triggered anymore?
In other words, should we remove BB_MIN_VERSION variable and its check in meta/classes-global/sanity.bbclass? My worry is that we forget to keep them in sync. If we need to keep it, do you think it'd make sense to move BB_MIN_VERSION to this file here too? And if possible use it as argument to bitbake_min_version so we only have one place to modify for bumping the variable.
Another question is whether we should backport this to earlier releases.
Another question is whether we can use a newer bitbake with older releases, which this wouldn't help with. E.g. what happens if I use bitbake 2.15.2 with scarthgap layers for example. Should we force the version to be MAJOR.MINOR and ignore any patch if not specified? e.g.
bitbake_expect_version 2.15
would match anything from 2.15 to 2.15.999
bitbake_expect_version 2.15.2
would match anything from 2.15.2 to 2.15.999.
à-la Rust version resolver, c.f. https://doc.rust-lang.org/cargo/reference/resolver.html#version-requirements
Should we rather have an explicit max version (but ok if not defined for e.g. the master branch)?
Cheers,
Quentin
Quoted 9 lines · Quentin Schulz
Does the sanity check still make sense if it simply cannot be triggered anymore?
In other words, should we remove
BB_MIN_VERSIONvariable and its check in meta/classes-global/sanity.bbclass? My worry is that we forget to keep them in sync. If we need to keep it, do you think it'd make sense to moveBB_MIN_VERSIONto this file here too? And if possible use it as argument tobitbake_min_versionso we only have one place to modify for bumping the variable.
I think the existing sanity check could be dropped, yes. I tried defining BB_MIN_VERSION here, and using it as an argument to bitbake_min_version, but at this point the datastore doesn't seem to be ready, and variable expansion doesn't work. Or maybe I did something incorrectly. Can you try it on your side?
Quoted 1 line
Another question is whether we should backport this to earlier releases.
Probably not. It's a new feature, and the issue is most pressing when people move on from integrated poky into separate bitbake/core checkouts.
Quoted 11 lines
Another question is whether we can use a newer bitbake with older releases, which this wouldn't help with. E.g. what happens if I use bitbake 2.15.2 with scarthgap layers for example. Should we force the version to be MAJOR.MINOR and ignore any patch if not specified? e.g.
bitbake_expect_version2.15would match anything from 2.15 to 2.15.999
bitbake_expect_version2.15.2
Quoted 7 lines
would match anything from 2.15.2 to 2.15.999.
à-la Rust version resolver, c.f.
https://doc.rust-lang.org/cargo/reference/resolver.html#version-requirementsShould we rather have an explicit max version (but ok if not defined for e.g. the master branch)?
I don't know. Enforcing a minimum version is straightforward, but what the maximum version should be is more complicated to define and maintain. It's probably a separate issue; this change simply moves an existing check earlier in bitbake invocations.
Alex
Quoted 11 lines · Alexander Kanavin
Quoted 9 lines · Quentin Schulz
Does the sanity check still make sense if it simply cannot be triggered anymore?
In other words, should we remove
BB_MIN_VERSIONvariable and its check in meta/classes-global/sanity.bbclass? My worry is that we forget to keep them in sync. If we need to keep it, do you think it'd make sense to moveBB_MIN_VERSIONto this file here too? And if possible use it as argument tobitbake_min_versionso we only have one place to modify for bumping the variable.
Quoted 6 lines
I think the existing sanity check could be dropped, yes. I tried defining
BB_MIN_VERSIONhere, and using it as an argument tobitbake_min_version, but at this point the datastore doesn't seem to be ready, and variable expansion doesn't work. Or maybe I did something incorrectly. Can you try it on your side?
$ bitbake -e mesa-native
ERROR: Unable to parse /home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py
Traceback (most recent call last):
File
"/home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 108, in check_bb_version
raise ParseError('Bitbake version %s is required and version %s is
used\n' % (min_version, bb.__version__), fn, lineno)
bb.parse.ParseError: ParseError at /home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/layer.conf:2: Bitbake version $BB_MIN_VERSION is required and version 2.15.2 is usedBut this was to be expected since in the BB patch it's simply a regexp where we extract whatever's after "bitbake_min_version " with re.match() which means only a string.
Quoted 6 lines
Quoted 1 line
Another question is whether we should backport this to earlier releases.
Probably not. It's a new feature, and the issue is most pressing when people move on from integrated poky into separate bitbake/core checkouts.
Yeah but this happened because the person updated their oe-core repo and not bitbake, but the opposite could happen as well. We would only protect from one scenario and not the other.
Quoted 16 lines
Quoted 16 lines
Another question is whether we can use a newer bitbake with older releases, which this wouldn't help with. E.g. what happens if I use bitbake 2.15.2 with scarthgap layers for example. Should we force the version to be MAJOR.MINOR and ignore any patch if not specified? e.g.
bitbake_expect_version2.15would match anything from 2.15 to 2.15.999
bitbake_expect_version2.15.2would match anything from 2.15.2 to 2.15.999.
à-la Rust version resolver, c.f.
https://doc.rust-lang.org/cargo/reference/resolver.html#version-requirements
Quoted 8 lines
Quoted 2 lines
Should we rather have an explicit max version (but ok if not defined for e.g. the master branch)?
I don't know. Enforcing a minimum version is straightforward, but what the maximum version should be is more complicated to define and maintain. It's probably a separate issue; this change simply moves an existing check earlier in bitbake invocations.
We historically (since Denzil) use an even minor version number for releases (and considering we are currently at 2.15 in master, I would say odd numbers for development). We could then match on MAJOR.MINOR only and ignore the rest except if provided (but I assume this should never happen except on the master branch since we would otherwise be breaking backward compatibility of releases (e.g. min_version is now 2.8.98 on scarthgap means we are forced to update bitbake to that version to be able to build newer releases of scarthgap) This assumption would mean tagging bitbake for a release, then using that even minor version number as argument to this new bitbake_expect_version (or whatever name we can find) and then tag oe-core for the new branch. Then the master branch of bitbake gets the new odd version number for the development of the next branch, which is then used also in the development of the next branch in oe-core. I assume something that needs to be added to the branching off process we already have.
In any case, considering this patch is about fixing a failsafe that exists but doesn't work, removing the BB_MIN_VERSION check and migrating to this seems fine to me.
Thanks!
Quentin
Quoted 13 lines · Quentin Schulz
$ bitbake -e mesa-native
ERROR: Unable to parse
/home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py
Traceback (most recent call last):
File
"/home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py",
line 108, in check_bb_version
raise ParseError('Bitbake version %s is required and version %s is
used\n' % (min_version, bb.__version__), fn, lineno)
bb.parse.ParseError: ParseError at
/home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/layer.conf:2:
Bitbake version $BB_MIN_VERSION is required and version 2.15.2 is usedQuoted 3 lines
But this was to be expected since in the BB patch it's simply a regexp where we extract whatever's after "
bitbake_min_version" withre.match()which means only a string.
You need to declare it thusly:BB_MIN_VERSION = "2.15.2"bb_min_version ${BB_MIN_VERSION}
and then run the regexp match (which should be '${BB_MIN_VERSION}') through data.expand() inside eval() in ast.py. It's supposed to work, but for me it did not.
Alex
Quoted 18 lines · Alexander Kanavin
Quoted 13 lines · Quentin Schulz
$ bitbake -e mesa-native ERROR: Unable to parse /home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py Traceback (most recent call last): File "/home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 108, in check_bb_version raise ParseError('Bitbake version %s is required and version %s is used\n' % (min_version, bb.__version__), fn, lineno) bb.parse.ParseError: ParseError at /home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/layer.conf:2: Bitbake version $BB_MIN_VERSION is required and version 2.15.2 is usedQuoted 3 lines
But this was to be expected since in the BB patch it's simply a regexp where we extract whatever's after "
bitbake_min_version" withre.match()which means only a string.
Quoted 8 lines
You need to declare it thusly:
BB_MIN_VERSION= "2.15.2"bb_min_version${BB_MIN_VERSION}and then run the regexp match (which should be '${BB_MIN_VERSION}') through
data.expand()insideeval()inast.py. It's supposed to work, but for me it did not.
I confirm, same here. (Spent the last few hours reviewing shell code so forgot how to use variables properly in BitBake, thanks for the reminder!)
meta/conf/layer.conf +3 -0
@@ -1,3 +1,6 @@ +BB_MIN_VERSION = "2.15.2" +bitbake_min_version ${BB_MIN_VERSION} + # We have a conf and classes directory, add to BBPATH BBPATH .= ":${LAYERDIR}" # We have recipes-* directories, add to BBFILES
Looking into the BB RFC patch, I'm wondering if we don't need to explicitly expand the string passed to bb_min_version? I see that the IncludeNode class does it during its eval() method.
I have no clue if this is proper but
lib/bb/parse/ast.py +1 -0
@@ -418,6 +418,7 @@ class BbMinVersionNode(AstNode): self.bb_min_version = bb_min_version def eval(self, data): + self.bb_min_version = data.expand(self.bb_min_version) bb.parse.ConfHandler.check_bb_version(self.filename,
self.lineno, self.bb_min_version)
def handleInclude(statements, filename, lineno, m, force):
Made it work (both with ${BB_MIN_VERSION} and the 2.15.2 string).
Quentin
Quoted 16 lines · Quentin Schulz
I have no clue if this is proper but
lib/bb/parse/ast.py +1
-0@@ -418,6 +418,7 @@ class BbMinVersionNode(AstNode): self.bb_min_version = bb_min_version def eval(self, data): + self.bb_min_version = data.expand(self.bb_min_version) bb.parse.ConfHandler.check_bb_version(self.filename, self.lineno, self.bb_min_version)def
handleInclude(statements, filename, lineno, m, force):
Quoted 1 line
Made it work (both with ${BB_MIN_VERSION} and the 2.15.2 string).
Well, this is what I did (data.expand(...)), and yet the expansion didn't happen for me. Can you share a patch where it works?
Alex
Quoted 16 lines · Alexander Kanavin
Quoted 14 lines · Quentin Schulz
I have no clue if this is proper but
lib/bb/parse/ast.py +1
-0@@ -418,6 +418,7 @@ class BbMinVersionNode(AstNode): self.bb_min_version = bb_min_version def eval(self, data): + self.bb_min_version = data.expand(self.bb_min_version) bb.parse.ConfHandler.check_bb_version(self.filename, self.lineno, self.bb_min_version)
Quoted 7 lines
Quoted 3 lines
def
handleInclude(statements, filename, lineno, m, force):Made it work (both with ${BB_MIN_VERSION} and the 2.15.2 string).
Well, this is what I did (
data.expand(...)), and yet the expansion didn't happen for me. Can you share a patch where it works?
BitBake master (35a421cdc) + your patch from https://lore.kernel.org/bitbake-devel/[email protected]/T/#u +
lib/bb/parse/ast.py +1 -0
@@ -418,6 +418,7 @@ class BbMinVersionNode(AstNode): self.bb_min_version = bb_min_version def eval(self, data): + self.bb_min_version = data.expand(self.bb_min_version) bb.parse.ConfHandler.check_bb_version(self.filename,
self.lineno, self.bb_min_version)
def handleInclude(statements, filename, lineno, m, force):
OE-COre master (7a900ff52d) +
meta/conf/layer.conf +3 -0
@@ -1,3 +1,6 @@ +BB_MIN_VERSION = "2.15.7" +bitbake_min_version ${BB_MIN_VERSION} + # We have a conf and classes directory, add to BBPATH BBPATH .= ":${LAYERDIR}" # We have recipes-* directories, add to BBFILES
source oe-init-build-env ../build-oe-core-tmp
Then run
bitbake-getvar BB_MIN_VERSION
NOTE: Starting bitbake server...
ERROR: Unable to parse /home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py
Traceback (most recent call last):
File
"/home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 108, in check_bb_version
raise ParseError('Bitbake version %s is required and version %s is
used\n' % (min_version, bb.__version__), fn, lineno)
bb.parse.ParseError: ParseError at /home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/layer.conf:2: Bitbake version 2.15.7 is required and version 2.15.2 is used
ERROR: Unable to parse /home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py
Traceback (most recent call last):
File
"/home/qschulz/work/upstream/yocto/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 108, in check_bb_version
raise ParseError('Bitbake version %s is required and version %s is
used\n' % (min_version, bb.__version__), fn, lineno)
bb.parse.ParseError: ParseError at /home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/layer.conf:2: Bitbake version 2.15.7 is required and version 2.15.2 is used
Traceback (most recent call last):
File "/home/qschulz/work/upstream/yocto/bitbake/bin/bitbake-getvar",
line 54, in <module>
tinfoil.prepare(quiet=2, config_only=True)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/qschulz/work/upstream/yocto/bitbake/lib/bb/tinfoil.py",
line 550, in prepare
config_params.updateToServer(self.server_connection.connection,os.environ.copy())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/home/qschulz/work/upstream/yocto/bitbake/lib/bb/cookerdata.py", line 74, in updateToServer
ret, error = server.runCommand(["updateConfig", options,
environment, sys.argv])
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/home/qschulz/work/upstream/yocto/bitbake/lib/bb/server/process.py", line 492, in runCommand
raise bb.BBHandledException()
bb.BBHandledException
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/qschulz/work/upstream/yocto/bitbake/bin/bitbake-getvar",
line 46, in <module>
with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not quiet) as
tinfoil:
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/qschulz/work/upstream/yocto/bitbake/lib/bb/tinfoil.py",
line 477, in __exit__
self.shutdown()
~~~~~~~~~~~~~^^
File "/home/qschulz/work/upstream/yocto/bitbake/lib/bb/tinfoil.py",
line 996, in shutdown
self.run_command('clientComplete')
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/home/qschulz/work/upstream/yocto/bitbake/lib/bb/tinfoil.py",
line 612, in run_command
result = self.server_connection.connection.runCommand(commandline)
File
"/home/qschulz/work/upstream/yocto/bitbake/lib/bb/server/process.py", line 492, in runCommand
raise bb.BBHandledException()
bb.BBHandledException
Changing BB_MIN_VERSION to 2.15.2 results in
NOTE: Starting bitbake server...
#
# $BB_MIN_VERSION [2 operations]
# set /home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/layer.conf:1
# "2.15.2"
# set /home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/sanity.conf:6
# "2.15.2"
# pre-expansion value: # "2.15.2" BB_MIN_VERSION="2.15.2"
as expected.
Host distro is fedora 42, no container involved.
Quentin
Quoted 11 lines · Quentin Schulz
Changing
BB_MIN_VERSIONto 2.15.2 results inNOTE: Starting bitbake server...
#
# $BB_MIN_VERSION [2 operations]
# set/home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/layer.conf:1
# "2.15.2"
# set/home/qschulz/work/upstream/yocto/openembedded-core/meta/conf/sanity.conf:6
# "2.15.2"
Quoted 5 lines
# pre-expansion value: # "2.15.2" BB_MIN_VERSION="2.15.2"as expected.
Thanks, yes this works for me too. Not sure what I did incorrectly the first time around. I'll incorporate this into the next version, but it would be good to get RP's approval of the overall idea. Maybe this can be done without adding a whole new keyword (which is then used once).
Alex