bitbake-setup: add descriptions for fragment choices
v3 cover bitbake-setup: add descriptions for fragment choices
---
Changes in v3:
- Rework logic as suggested by Alex
- Remove modifications of {oe-nodistro,poky}-whinlatter.conf.json
- Add a test case for oe-fragments-one-of
- Link to v2: https://patch.msgid.link/20260120-bitbake-setup-choose-builtin-v2-0-ade604ff2351@bootlin.com
Changes in v2:
- As suggested by Alex, change the new way of specifying fragments to
remain a dictionary so they can be extended in the future
- Link to v1: https://patch.msgid.link/20260116-bitbake-setup-choose-builtin-v1-0-8d66666a9efd@bootlin.com
---
Antonin Godard (3):
bin/bitbake-setup: add descriptions for fragment choices
default-registry: update fragments choices with descriptions lib/bb/tests/setup.py: add tests for oe-fragments-one-of
bin/bitbake-setup | 23 ++++++++++++++----- .../configurations/oe-nodistro-master.conf.json | 6 ++++- .../configurations/poky-master.conf.json | 14 ++++++++++-- .../bitbake-user-manual-environment-setup.rst | 26 ++++++++++++++++++++-- lib/bb/tests/setup.py | 25 +++++++++++++++++++-- setup-schema/bitbake-setup.schema.json | 21 ++++++++++++++++- 6 files changed, 101 insertions(+), 14 deletions(-)
---
base-commit: 5127faf986d8543bb88e73cf3dccb407d80c9a25
change-id: 20260116-bitbake-setup-choose-builtin-fb199054cc25
PATCH v3 1/3 bin/bitbake-setup: add descriptions for fragment choices
Make it possible to give fragments descriptions as it can help users determine which fragments to pick during bitbake-setup init.
It is still possible to provide a list (with no descriptions) for backwards-compatibility.
Update the documentation accordingly.
--- bin/bitbake-setup | 23 ++++++++++++++----- .../bitbake-user-manual-environment-setup.rst | 26 ++++++++++++++++++++-- setup-schema/bitbake-setup.schema.json | 21 ++++++++++++++++- 3 files changed, 61 insertions(+), 9 deletions(-)
bin/bitbake-setup +17 -6
@@ -494,23 +494,34 @@ def choose_fragments(possibilities, parameters, non_interactive, skip_selection) if skip_selection and k in skip_selection: logger.info("Skipping a selection of {}, as requested on command line. The resulting bitbake configuration may require further manual adjustments.".format(k)) continue - choice = [o for o in v["options"] if o in parameters] + + # options can be a list of strings or a list of dicts + options = v["options"] + if len(options) > 0 and isinstance(v["options"][0], str): + options = [{"name": o, "description": ""} for o in v["options"]] + + choice = [o["name"] for o in options if o["name"] in parameters] if len(choice) > 1: - raise Exception("Options specified on command line do not allow a single selection from possibilities {}, please remove one or more from {}".format(v["options"], parameters)) + raise Exception("Options specified on command line do not allow a single selection " + f"from possibilities {[o['name'] for o in options]}, please " + f"remove one or more from {parameters}") if len(choice) == 1: choices[k] = choice[0] continue if non_interactive: - raise Exception("Unable to choose from options in non-interactive mode: {}".format(v["options"])) + raise Exception(f"Unable to choose from options in non-interactive mode: {[o['name'] for o in options]}") logger.plain("\n" + v["description"] + ":") - options_enumerated = list(enumerate(v["options"], 1)) + options_enumerated = list(enumerate(options, 1)) for n,o in options_enumerated: - logger.plain("{}. {}".format(n, o)) + opt_str = f"{n}. {o['name']}" + if o["description"]: + opt_str += f"\t{o['description']}" + logger.plain(opt_str) option_n = int_input([i[0] for i in options_enumerated], "\nPlease select one of the above options by its number: ") - 1 - choices[k] = options_enumerated[option_n][1] + choices[k] = options_enumerated[option_n][1]["name"] return choices def obtain_config(top_dir, settings, args, source_overrides, d):
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +24 -2
@@ -759,11 +759,21 @@ They contain the following sections: "oe-fragments-one-of": { "machine": { "description": "Target machines", - "options" : ["machine/qemux86-64", "machine/qemuarm64", "machine/qemuriscv64", "machine/genericarm64", "machine/genericx86-64"] + "options" : [ + { "name": "machine/qemux86-64", "description": "Machine configuration for running an x86-64 system on QEMU" }, + { "name": "machine/qemuarm64", "description": "Machine configuration for running an ARMv8 system on QEMU" }, + { "name": "machine/qemuriscv64", "description": "Machine configuration for running an RISC-V system on QEMU" }, + { "name": "machine/genericarm64", "description": "Machine configuration for Arm64 SystemReady IR/ES platforms" }, + { "name": "machine/genericx86-64", "description": "Machine configuration for generic x86_64 (64-bit) PCs and servers" } + ] }, "distro": { "description": "Distribution configuration variants", - "options" : ["distro/poky", "distro/poky-altcfg", "distro/poky-tiny"] + "options" : [ + { "name": "distro/poky", "description": "Distro configuration for Poky (Yocto Project Reference Distro)" }, + { "name": "distro/poky-altcfg", "description": "Distro configuration for Poky (systemd init manager)" }, + { "name": "distro/poky-tiny", "description": "Distro configuration for Poky (optimized for size)" } + ] } }, "configurations": [
@@ -852,6 +862,18 @@ They contain the following sections: - ``oe-fragments-one-of`` (*optional*, OpenEmbedded specific): the OpenEmbedded fragments to select as part of the build. + This can one of two formats: + + - A list of dictionaries with ``name`` and a ``description``, + corresponding to respectively the fragments names and fragment + descriptions (like in the example above). + + - A list of fragment names. For example: + + .. code-block:: json + + "options" : ["machine/qemux86-64", "machine/qemuarm64", "machine/qemuriscv64", "machine/genericarm64", "machine/genericx86-64"] + This will trigger choices to make during the :ref:`ref-bbsetup-command-init` command execution.
setup-schema/bitbake-setup.schema.json +20 -1
@@ -64,7 +64,26 @@ "type": "array", "description": "List of BitBake configuration fragments to enable", "items": { - "type": "string" + "oneOf": [ + { + "type": "string", + "description": "Configuration fragment name" + }, + { + "type": "object", + "description": "Dictionary of BitBake configuration fragments to enable (with description)", + "properties": { + "name": { + "type": "string", + "description": "Configuration fragment name" + }, + "description": { + "type": "string", + "description": "Human-readable description of the fragment" + } + } + } + ] } }, "oe-fragments-one-of": {
Signature · 1 line
2.52.0
PATCH v3 2/3 default-registry: update fragments choices with descriptions
In reply to Antonin GodardGive descriptions to the fragment choices to help the user know what to pick during 'bitbake-setup init'. These descriptions were based on the descriptions found in the corresponding configuration files in OE-Core/meta-yocto.
--- .../configurations/oe-nodistro-master.conf.json | 6 +++++- default-registry/configurations/poky-master.conf.json | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-)
default-registry/configurations/oe-nodistro-master.conf.json +5 -1
@@ -45,7 +45,11 @@ "oe-fragments-one-of": { "machine": { "description": "Target machines", - "options" : ["machine/qemux86-64", "machine/qemuarm64", "machine/qemuriscv64"] + "options" : [ + { "name": "machine/qemux86-64", "description": "Machine configuration for running an x86-64 system on QEMU" }, + { "name": "machine/qemuarm64", "description": "Machine configuration for running an ARMv8 system on QEMU" }, + { "name": "machine/qemuriscv64", "description": "Machine configuration for running an RISC-V system on QEMU" } + ] } } }
default-registry/configurations/poky-master.conf.json +12 -2
@@ -54,11 +54,21 @@ "oe-fragments-one-of": { "machine": { "description": "Target machines", - "options" : ["machine/qemux86-64", "machine/qemuarm64", "machine/qemuriscv64", "machine/genericarm64", "machine/genericx86-64"] + "options" : [ + { "name": "machine/qemux86-64", "description": "Machine configuration for running an x86-64 system on QEMU" }, + { "name": "machine/qemuarm64", "description": "Machine configuration for running an ARMv8 system on QEMU" }, + { "name": "machine/qemuriscv64", "description": "Machine configuration for running an RISC-V system on QEMU" }, + { "name": "machine/genericarm64", "description": "Machine configuration for Arm64 SystemReady IR/ES platforms" }, + { "name": "machine/genericx86-64", "description": "Machine configuration for generic x86_64 (64-bit) PCs and servers" } + ] }, "distro": { "description": "Distribution configuration variants", - "options" : ["distro/poky", "distro/poky-altcfg", "distro/poky-tiny"] + "options" : [ + { "name": "distro/poky", "description": "Distro configuration for Poky (Yocto Project Reference Distro)" }, + { "name": "distro/poky-altcfg", "description": "Distro configuration for Poky (systemd init manager)" }, + { "name": "distro/poky-tiny", "description": "Distro configuration for Poky (optimized for size)" } + ] } }, "configurations": [
Signature · 1 line
2.52.0
PATCH v3 3/3 lib/bb/tests/setup.py: add tests for oe-fragments-one-of
In reply to Antonin GodardThere were no tests of oe-fragments-one-of so add a new configuration for it, and test both formats for the options (with or without a description).
--- lib/bb/tests/setup.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
lib/bb/tests/setup.py +23 -2
@@ -146,6 +146,25 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) "bb-layers": ["layerC","layerD/meta-layer"], "bb-layers-file-relative": ["layerE/meta-layer"], "oe-fragments": ["test-fragment-2"] + }, + { + "name": "gizmo-fragments-one-of", + "description": "Gizmo configuration using oe-fragments-one-of, both formats", + "oe-template": "test-configuration-gizmo", + "oe-fragments-one-of": { + "fragment-desc": { + "description": "Test fragments (with description)", + "options" : [ + { "name": "fragment-desc-1", "description": "fragment 1 desc" } + ] + }, + "fragment-nodesc": { + "description": "Test fragments (no description)", + "options" : [ + "fragment-nodesc-1" + ] + } + } } ] },
@@ -258,7 +277,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) def get_setup_path(self, cf, c): if c == 'gizmo': return os.path.join(self.tempdir, 'bitbake-builds', 'this-is-a-custom-gizmo-build') - return os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, c)) + return os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, "-".join(c.split()))) def test_setup(self): # unset BBPATH to ensure tests run in isolation from the existing bitbake environment
@@ -328,7 +347,9 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) 'buildconfigs':('gadget','gizmo', 'gizmo-env-passthrough', 'gizmo-no-fragment', - 'gadget-notemplate','gizmo-notemplate')}, + 'gadget-notemplate', + 'gizmo-notemplate', + 'gizmo-fragments-one-of fragment-desc-1 fragment-nodesc-1')}, 'test-config-2': {'cmdline': os.path.join(self.registrypath,'config-2/test-config-2.conf.json'), 'buildconfigs': ('gadget','gizmo', 'gizmo-env-passthrough',
Signature · 1 line
2.52.0
Re: [PATCH v3 3/3] lib/bb/tests/setup.py: add tests for oe-fragments-one-of
Quoted 9 lines · Antonin Godard
lib/bb/tests/setup.py +9
-0+ }, + { + "name": "gizmo-fragments-one-of", + "description": "Gizmo configuration using oe-fragments-one-of, both formats", + "oe-template": "test-configuration-gizmo", + "oe-fragments-one-of": { + "fragment-desc": { + "description": "Test fragments (with description)", + "options" : [
lib/bb/tests/setup.py print("BBPATH is {{}}".format(os.environ["BBPATH"])) · line 167
Quoted 10 lines
lib/bb/tests/setup.py +10
-0+ { "name": "fragment-desc-1", "description": "fragment 1 desc" } + ] + }, + "fragment-nodesc": { + "description": "Test fragments (no description)", + "options" : [ + "fragment-nodesc-1" + ] + } + }
To avoid multiplying test configs further (and making the tests slower), perhaps this can be added to gizmo-notemplate, and that renamed to gizmo-notemplate-fragments-one-of ?
lib/bb/tests/setup.py print("BBPATH is {{}}".format(os.environ["BBPATH"])) · line 352
Quoted 4 lines
lib/bb/tests/setup.py +3
-1- 'gadget-notemplate','gizmo-notemplate')}, + 'gadget-notemplate', + 'gizmo-notemplate', + 'gizmo-fragments-one-of fragment-desc-1 fragment-nodesc-1')},
As there's only one choice in each, bitbake-setup should pick that without asking, or having to specify them on command line. Let's test that too, and drop the fragment names from here.
Alex
Re: [docs] [PATCH v3 3/3] lib/bb/tests/setup.py: add tests for oe-fragments-one-of
Hi,
Quoted 21 lines · Alexander Kanavin via lists.yoctoproject.org
Quoted 9 lines · Antonin Godard
lib/bb/tests/setup.py +9
-0+ }, + { + "name": "gizmo-fragments-one-of", + "description": "Gizmo configuration using oe-fragments-one-of, both formats", + "oe-template": "test-configuration-gizmo", + "oe-fragments-one-of": { + "fragment-desc": { + "description": "Test fragments (with description)", + "options" : [lib/bb/tests/setup.py print("BBPATH is {{}}".format(os.environ["BBPATH"])) · line 167
Quoted 10 lines
lib/bb/tests/setup.py +10
-0+ { "name": "fragment-desc-1", "description": "fragment 1 desc" } + ] + }, + "fragment-nodesc": { + "description": "Test fragments (no description)", + "options" : [ + "fragment-nodesc-1" + ] + } + }
Quoted 3 lines
To avoid multiplying test configs further (and making the tests slower), perhaps this can be added to gizmo-notemplate, and that renamed to gizmo-notemplate-fragments-one-of ?
Sure
Quoted 8 lines
lib/bb/tests/setup.py print("BBPATH is {{}}".format(os.environ["BBPATH"])) · line 352
Quoted 4 lines
lib/bb/tests/setup.py +3
-1- 'gadget-notemplate','gizmo-notemplate')}, + 'gadget-notemplate', + 'gizmo-notemplate', + 'gizmo-fragments-one-of fragment-desc-1 fragment-nodesc-1')},As there's only one choice in each, bitbake-setup should pick that without asking, or having to specify them on command line. Let's test that too, and drop the fragment names from here.
I tried that with the following modified configuration:
{
"name": "gizmo-notemplate-fragments-one-of",
"description": "Gizmo notemplate configuration",
"bb-layers": ["layerC","layerD/meta-layer"],
"oe-fragments": ["test-fragment-2"],
"oe-fragments-one-of": {
"fragment-desc": {
"description": "Test fragments (with description)",
"options" : [
{ "name": "fragment-desc-1", "description": "fragment 1 desc" }
]
},
"fragment-nodesc": {
"description": "Test fragments (no description)",
"options" : [
"fragment-nodesc-1"
]
}
}
},But I'm hitting:
bb.process.ExecutionError: Execution of '/bitbake/bin/bitbake-setup --global-settings /tmp/bitbake-fetch-q1wqa8zi/global-config init --non-interactive test-config-1 gizmo-notemplate-fragments-one-of' failed with exit code 1:
Traceback (most recent call last):
File "/bitbake/bin/bitbake-setup", line 1320, in <module>
main()
File "/bitbake/bin/bitbake-setup", line 1310, in main
init_config(top_dir, all_settings, args)
File "/bitbake/bin/bitbake-setup", line 767, in init_config
upstream_config = obtain_config(top_dir, settings["default"]["registry"], args, source_overrides, d)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/bitbake/bin/bitbake-setup", line 586, in obtain_config
upstream_config['bitbake-config']['oe-fragment-choices'] = choose_fragments(upstream_config['bitbake-config'].get('oe-fragments-one-of',{}), config_parameters[1:], args.non_interactive, args.skip_selection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/bitbake/bin/bitbake-setup", line 534, in choose_fragments
raise Exception(f"Unable to choose from options in non-interactive mode: {[o['name'] for o in options]}")
Exception: Unable to choose from options in non-interactive mode: ['fragment-desc-1']
So just after:
# options can be a list of strings or a list of dicts
options = v["options"]
if len(options) > 0 and isinstance(v["options"][0], str):
options = [{"name": o, "description": ""} for o in v["options"]]I added:
if len(options) == 1:
choices[k] = options[0]["name"]
continuewhich seems to accomplish what you had in mind.
However this makes the setup dir name "non-predictable" and I hit the following next error:
Traceback (most recent call last):
File "/bitbake/lib/bb/tests/setup.py", line 357, in test_setup
self.check_setupdir_files(setuppath, test_file_content)
File "/bitbake/lib/bb/tests/setup.py", line 224, in check_setupdir_files
with open(os.path.join(setuppath, 'config', "config-upstream.json")) as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/bitbake-fetch-9d85c0us/bitbake-builds/test-config-1-gizmo-notemplate-fragments-one-of/config/config-upstream.json'
which is due to the setup directory name containing the fragment choices (even if none were passed on the command-line).
$ ls -l /tmp/bitbake-fetch-atck07q2/bitbake-builds ... drwxr-xr-x - builder 23 Jan 08:22 test-config-1-gizmo-notemplate-fragments-one-of-fragment-desc-1-fragment-nodesc-1
So I added:
"setup-dir-name": "gizmo-notemplate-fragments-one-of",
To make sure we get a fixed name for this configuration. Sounds good to you?
Antonin
Signature · 3 lines
Antonin Godard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [docs] [PATCH v3 3/3] lib/bb/tests/setup.py: add tests for oe-fragments-one-of
Quoted 8 lines · Antonin Godard
Quoted 8 lines
lib/bb/tests/setup.py print("BBPATH is {{}}".format(os.environ["BBPATH"])) · line 352
Quoted 4 lines
lib/bb/tests/setup.py +3
-1- 'gadget-notemplate','gizmo-notemplate')}, + 'gadget-notemplate', + 'gizmo-notemplate', + 'gizmo-fragments-one-of fragment-desc-1 fragment-nodesc-1')},As there's only one choice in each, bitbake-setup should pick that without asking, or having to specify them on command line. Let's test that too, and drop the fragment names from here.
After reading your response, I retract this suggestion. The reason bitbake-setup is not automatically picking up a single choice is because such configuration doesn't make sense: if someone makes oe-fragments-one-of with a single choice, they should just add that choice to oe-fragments.
That said, we still need to test oe-fragments-one-of, so can you place two choices to each (old syntax, new syntax), and supply the selections on command line, as you've already done? The non-active fragment can be entirely bogus and non-existing.
Alex
Thanks, other than the suggested test tweaks, lgtm. There might be a merge conflict with the tests, as I've also tweaked them, but it should not be hard to resolve.
Alex
Quoted 31 lines · Antonin Godard
Signed-off-by Antonin Godard <[email protected]>---
Changes in v3:
- Rework logic as suggested by Alex
- Remove modifications of {oe-nodistro,poky}-whinlatter.conf.json
- Add a test case for oe-fragments-one-of
- Link to v2: https://patch.msgid.link/20260120-bitbake-setup-choose-builtin-v2-0-ade604ff2351@bootlin.comChanges in v2:
- As suggested by Alex, change the new way of specifying fragments to
remain a dictionary so they can be extended in the future
- Link to v1: https://patch.msgid.link/20260116-bitbake-setup-choose-builtin-v1-0-8d66666a9efd@bootlin.com---
Antonin Godard (3):
bin/bitbake-setup: add descriptions for fragment choices
default-registry: update fragments choices with descriptionslib/bb/tests/setup.py: add tests for oe-fragments-one-ofbin/bitbake-setup | 23 ++++++++++++++----- .../configurations/oe-nodistro-master.conf.json | 6 ++++- .../configurations/poky-master.conf.json | 14 ++++++++++-- .../bitbake-user-manual-environment-setup.rst | 26 ++++++++++++++++++++-- lib/bb/tests/setup.py | 25 +++++++++++++++++++-- setup-schema/bitbake-setup.schema.json | 21 ++++++++++++++++- 6 files changed, 101 insertions(+), 14 deletions(-)---
base-commit:5127faf986d8543bb88e73cf3dccb407d80c9a25
change-id: 20260116-bitbake-setup-choose-builtin-fb199054cc25