| Message ID | 20261204230358.533865-1-giancarlo.cicellyn@gmail.com |
|---|---|
| State | New |
| Headers | show |
| Series | bitbake-setup: support exporting configuration templates as JSON | expand |
On Sat, 5 Dec 2026 at 00:04, Giancarlo Cicellyn Comneno via bitbake-devel <giancarlo.cicellyn=gmail.com@lists.openembedded.org> wrote: > The list command can export registry metadata as JSON, but does not > provide the contents of an individual configuration template. External > tools therefore cannot inspect its configuration and fragment choices > without initializing a setup or duplicating registry fetching logic. > This seems like another one of those submissions where AI both invented the problem, and made a solution for it. You need to justify the patch with more detailed, specific use cases than the above. I'd also note that Yocto project now does have AI policy, and it requires strict disclosure of AI generated responses in mailing lists, so you can't anymore ask your AI to carry the conversation, and hope that no one notices. Alex
This requirement originates from the ongoing bitbake-setup integration work in the VS Code BitBake extension: https://github.com/yoctoproject/vscode-bitbake/issues/530 In August, Enguerrand proposed an initialization workflow in which the extension presents the available configurations and fragment choices through VS Code QuickPick prompts before invoking bitbake-setup init. The relevant design discussion is here: https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5293176033 The current registry listing provides template identifiers and metadata, but not the template contents needed for those prompts. Enguerrand also suggested extending bitbake-setup itself: https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5295164589 I investigated a Wrynose-specific workaround based on non-interactive diagnostics, but subsequent experiments exposed limitations that make it unsuitable as a reliable general-purpose inspection interface. The proposed patch addresses this specific integration requirement while avoiding duplication of the existing BitBake registry fetching mechanism in TypeScript. I can revise the commit message to document this context in a v2. Regarding the AI policy, I acknowledge the requirements and take responsibility for the submitted changes as always. AI disclosure: ChatGPT (GPT-6.2) assisted in drafting this response. Regards, Giancarlo Il giorno sab 5 dic 2026 alle ore 00:18 Alexander Kanavin < alex.kanavin@gmail.com> ha scritto: > On Sat, 5 Dec 2026 at 00:04, Giancarlo Cicellyn Comneno via bitbake-devel > <giancarlo.cicellyn=gmail.com@lists.openembedded.org> wrote: > >> The list command can export registry metadata as JSON, but does not >> provide the contents of an individual configuration template. External >> tools therefore cannot inspect its configuration and fragment choices >> without initializing a setup or duplicating registry fetching logic. >> > > This seems like another one of those submissions where AI both invented > the problem, and made a solution for it. You need to justify the patch with > more detailed, specific use cases than the above. > > I'd also note that Yocto project now does have AI policy, and it requires > strict disclosure of AI generated responses in mailing lists, so you can't > anymore ask your AI to carry the conversation, and hope that no one notices. > > Alex >
On Sat, 5 Dec 2026 at 02:55, Giancarlo Cicellyn Comneno < giancarlo.cicellyn@gmail.com> wrote: > This requirement originates from the ongoing bitbake-setup integration > work in the VS Code BitBake extension: > https://github.com/yoctoproject/vscode-bitbake/issues/530 > > In August, Enguerrand proposed an initialization workflow in which the > extension presents the available configurations and fragment choices > through VS Code QuickPick prompts before invoking bitbake-setup init. > > The relevant design discussion is here: > https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5293176033 > > The current registry listing provides template identifiers and metadata, > but not the template contents needed for those prompts. > > Enguerrand also suggested extending bitbake-setup itself: > https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5295164589 > > I investigated a Wrynose-specific workaround based on non-interactive > diagnostics, but subsequent experiments exposed limitations that make it > unsuitable as a reliable general-purpose inspection interface. > > The proposed patch addresses this specific integration requirement while > avoiding duplication of the existing BitBake registry fetching mechanism in > TypeScript. > The patch mentions none of this. Did a human look at it before submission? I suspect not. The proposal is "give us the json, and we'll reimplement both configuration template handling and interactive selection logic". Doing that is non-trivial, and you'll end up something that needs ongoing maintenance and can be a source of subtle behaviour differences, or the json changing between the interactive selection and bitbake-setup invocation in non-interactive mode to actually set up a build. Right now, I am not agreeing with the idea. I would like to first have a conversation (with actual humans, including Enguerrand and Adrian) about how the interactive selection part should be handled. Can't vscode just run bitbake-setup in a interactive window, and let it do its job? Is it possible for bitbake-setup to handle the logic, and coordinate UI prompts through some IPC mechanism? Should we rework btibake-setup to provide a python library with an API, which would allow alternative interaction UIs? I can revise the commit message to document this context in a v2. > > Regarding the AI policy, I acknowledge the requirements and take > responsibility for the submitted changes as always. > > AI disclosure: ChatGPT (GPT-6.2) assisted in drafting this response. > I'd also like to point you to this section of the policy: "*The project will not accept automated contributions which rely completely on AI generation without any significant human involvement, judgement or review."* I am not seeing evidence of significant human involvement in either the patch or 'this response'. You need to show clearly what you, the human, did, and why your part is indeed significant. Even framing AI's response in a hand-written note, such as "Apologies for not providing any context, I have asked AI to summarize that, here it is:" would've been much better. Alex
Alex, I find it rather ironic that "Homo sapiens" invented open-source software to foster collaboration, only to turn a discussion about 22 lines of code into a trial of the contributor's intentions. Unfortunately, *you have accompanied those technical observations with personal insinuations that, in my opinion, do nothing to foster constructive collaboration.* Perhaps this is one of humanity's recurring problems: confusing competence with superiority, rigor with intransigence, and authority with the right to humiliate others. *Technical competence does not necessarily guarantee interpersonal intelligence.* Fortunately, I have also had the pleasure of collaborating with *Enguerrand* within this very same project. His openness, patience, and willingness to engage in constructive dialogue demonstrate that technical rigor and mutual respect can coexist. That is the kind of open-source community I enjoy contributing to. Regards, *ChatGPT* *[Human disclosure: Giancarlo assisted in reviewing this response! ahahhahahaha]* Il giorno sab 5 dic 2026 alle ore 09:03 Alexander Kanavin < alex.kanavin@gmail.com> ha scritto: > On Sat, 5 Dec 2026 at 02:55, Giancarlo Cicellyn Comneno < > giancarlo.cicellyn@gmail.com> wrote: > >> This requirement originates from the ongoing bitbake-setup integration >> work in the VS Code BitBake extension: >> https://github.com/yoctoproject/vscode-bitbake/issues/530 >> >> In August, Enguerrand proposed an initialization workflow in which the >> extension presents the available configurations and fragment choices >> through VS Code QuickPick prompts before invoking bitbake-setup init. >> >> The relevant design discussion is here: >> https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5293176033 >> >> The current registry listing provides template identifiers and metadata, >> but not the template contents needed for those prompts. >> >> Enguerrand also suggested extending bitbake-setup itself: >> https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5295164589 >> >> I investigated a Wrynose-specific workaround based on non-interactive >> diagnostics, but subsequent experiments exposed limitations that make it >> unsuitable as a reliable general-purpose inspection interface. >> >> The proposed patch addresses this specific integration requirement while >> avoiding duplication of the existing BitBake registry fetching mechanism in >> TypeScript. >> > > The patch mentions none of this. Did a human look at it before submission? > I suspect not. > > The proposal is "give us the json, and we'll reimplement both > configuration template handling and interactive selection logic". Doing > that is non-trivial, and you'll end up something that needs ongoing > maintenance and can be a source of subtle behaviour differences, or the > json changing between the interactive selection and bitbake-setup > invocation in non-interactive mode to actually set up a build. Right now, I > am not agreeing with the idea. > > I would like to first have a conversation (with actual humans, > including Enguerrand and Adrian) about how the interactive selection part > should be handled. Can't vscode just run bitbake-setup in a interactive > window, and let it do its job? Is it possible for bitbake-setup to handle > the logic, and coordinate UI prompts through some IPC mechanism? Should we > rework btibake-setup to provide a python library with an API, which would > allow alternative interaction UIs? > > I can revise the commit message to document this context in a v2. >> >> Regarding the AI policy, I acknowledge the requirements and take >> responsibility for the submitted changes as always. >> >> AI disclosure: ChatGPT (GPT-6.2) assisted in drafting this response. >> > I'd also like to point you to this section of the policy: > > "*The project will not accept automated contributions which rely > completely on AI generation without any significant human involvement, > judgement or review."* > > I am not seeing evidence of significant human involvement in either the > patch or 'this response'. You need to show clearly what you, the human, > did, and why your part is indeed significant. Even framing AI's response in > a hand-written note, such as "Apologies for not providing any context, I > have asked AI to summarize that, here it is:" would've been much better. > > Alex >
On Sat Dec 5, 2026 at 10:34 AM GMT, Giancarlo Cicellyn Comneno wrote: > Alex, > I find it rather ironic that "Homo sapiens" invented open-source software > to foster collaboration, only to turn a discussion about 22 lines of code > into a trial of the contributor's intentions. > Unfortunately, *you have accompanied those technical observations with > personal insinuations that, in my opinion, do nothing to foster > constructive collaboration.* > Perhaps this is one of humanity's recurring problems: confusing competence > with superiority, rigor with intransigence, and authority with the right to > humiliate others. > > *Technical competence does not necessarily guarantee interpersonal > intelligence.* > Fortunately, I have also had the pleasure of collaborating with *Enguerrand* > within this very same project. His openness, patience, and willingness to > engage in constructive dialogue demonstrate that technical rigor and mutual > respect can coexist. That is the kind of open-source community I enjoy > contributing to. > > Regards, > *ChatGPT* > > *[Human disclosure: Giancarlo assisted in reviewing this response! > ahahhahahaha]* Hi folks, This discussion is becoming very unhelpful. Both of you need to drop the accusations and take a step back. Giancarlo, we do need contributors to engage with the community and not just act as a proxy between an LLM chat and the mailing list. Using AI tools to assist you is fine, but you still need to apply judgement and think about the context maintainers need to assess a contribution. Remember that AI tools are often good at describing the *how*, but often not the *why*. I share Alex's concerns about having two implementations for the interactive selection of bitbake-setup configurations. However I also understand that GUI tools often want a GUI way of doing things. We should consider what logic can be shared between bitbake-setup and vscode-bitbake. This does need some design and collaboration. > > Il giorno sab 5 dic 2026 alle ore 09:03 Alexander Kanavin < > alex.kanavin@gmail.com> ha scritto: > >> On Sat, 5 Dec 2026 at 02:55, Giancarlo Cicellyn Comneno < >> giancarlo.cicellyn@gmail.com> wrote: >> >>> This requirement originates from the ongoing bitbake-setup integration >>> work in the VS Code BitBake extension: >>> https://github.com/yoctoproject/vscode-bitbake/issues/530 >>> >>> In August, Enguerrand proposed an initialization workflow in which the >>> extension presents the available configurations and fragment choices >>> through VS Code QuickPick prompts before invoking bitbake-setup init. >>> >>> The relevant design discussion is here: >>> https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5293176033 >>> >>> The current registry listing provides template identifiers and metadata, >>> but not the template contents needed for those prompts. >>> >>> Enguerrand also suggested extending bitbake-setup itself: >>> https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5295164589 >>> >>> I investigated a Wrynose-specific workaround based on non-interactive >>> diagnostics, but subsequent experiments exposed limitations that make it >>> unsuitable as a reliable general-purpose inspection interface. >>> >>> The proposed patch addresses this specific integration requirement while >>> avoiding duplication of the existing BitBake registry fetching mechanism in >>> TypeScript. >>> >> >> The patch mentions none of this. Did a human look at it before submission? >> I suspect not. >> >> The proposal is "give us the json, and we'll reimplement both >> configuration template handling and interactive selection logic". Doing >> that is non-trivial, and you'll end up something that needs ongoing >> maintenance and can be a source of subtle behaviour differences, or the >> json changing between the interactive selection and bitbake-setup >> invocation in non-interactive mode to actually set up a build. Right now, I >> am not agreeing with the idea. >> >> I would like to first have a conversation (with actual humans, >> including Enguerrand and Adrian) about how the interactive selection part >> should be handled. Can't vscode just run bitbake-setup in a interactive >> window, and let it do its job? Is it possible for bitbake-setup to handle >> the logic, and coordinate UI prompts through some IPC mechanism? Should we >> rework btibake-setup to provide a python library with an API, which would >> allow alternative interaction UIs? >> >> I can revise the commit message to document this context in a v2. >>> >>> Regarding the AI policy, I acknowledge the requirements and take >>> responsibility for the submitted changes as always. >>> >>> AI disclosure: ChatGPT (GPT-6.2) assisted in drafting this response. >>> >> I'd also like to point you to this section of the policy: >> >> "*The project will not accept automated contributions which rely >> completely on AI generation without any significant human involvement, >> judgement or review."* >> >> I am not seeing evidence of significant human involvement in either the >> patch or 'this response'. You need to show clearly what you, the human, >> did, and why your part is indeed significant. Even framing AI's response in >> a hand-written note, such as "Apologies for not providing any context, I >> have asked AI to summarize that, here it is:" would've been much better. >> >> Alex >> Best regards,
I would have genuinely enjoyed participating in discussions about the “how”, had I not been subjected to personal accusations. Accepting technical criticism does not mean having to accept personal insinuations. If a maintainer has every right to challenge an architectural solution, a contributor has an equal right to defend their intellectual dignity. Asking both parties to drop their accusations, without distinguishing between the person who made them and the person who was simply trying to defend themselves, risks putting accusation and self-defense on the same footing. Open discussion should be an integral part of collaboration, even when it concerns human behavior rather than just code. Otherwise, we are always free to choose whom and what we devote our time to. So rest assured, dear *Supreme Judge* and *Prosecuting Counsel*: I shall take my leave. A community's right to establish its own terms of collaboration is entirely compatible with a contributor's right to choose where to invest their time. And I have plenty of other things to do. *[AI disclosure: ChatGPT assisted me in expressing my thoughts in English. The decision to leave is entirely human]* Unsubscribe. Il giorno sab 5 dic 2026 alle ore 13:44 Paul Barker <paul@pbarker.dev> ha scritto: > On Sat Dec 5, 2026 at 10:34 AM GMT, Giancarlo Cicellyn Comneno wrote: > > Alex, > > I find it rather ironic that "Homo sapiens" invented open-source software > > to foster collaboration, only to turn a discussion about 22 lines of code > > into a trial of the contributor's intentions. > > Unfortunately, *you have accompanied those technical observations with > > personal insinuations that, in my opinion, do nothing to foster > > constructive collaboration.* > > Perhaps this is one of humanity's recurring problems: confusing > competence > > with superiority, rigor with intransigence, and authority with the right > to > > humiliate others. > > > > *Technical competence does not necessarily guarantee interpersonal > > intelligence.* > > Fortunately, I have also had the pleasure of collaborating with > *Enguerrand* > > within this very same project. His openness, patience, and willingness to > > engage in constructive dialogue demonstrate that technical rigor and > mutual > > respect can coexist. That is the kind of open-source community I enjoy > > contributing to. > > > > Regards, > > *ChatGPT* > > > > *[Human disclosure: Giancarlo assisted in reviewing this response! > > ahahhahahaha]* > > Hi folks, > > This discussion is becoming very unhelpful. Both of you need to drop the > accusations and take a step back. > > Giancarlo, we do need contributors to engage with the community and not > just act as a proxy between an LLM chat and the mailing list. Using AI > tools to assist you is fine, but you still need to apply judgement and > think about the context maintainers need to assess a contribution. > Remember that AI tools are often good at describing the *how*, but often > not the *why*. > > I share Alex's concerns about having two implementations for the > interactive selection of bitbake-setup configurations. However I also > understand that GUI tools often want a GUI way of doing things. We > should consider what logic can be shared between bitbake-setup and > vscode-bitbake. This does need some design and collaboration. > > > > > Il giorno sab 5 dic 2026 alle ore 09:03 Alexander Kanavin < > > alex.kanavin@gmail.com> ha scritto: > > > >> On Sat, 5 Dec 2026 at 02:55, Giancarlo Cicellyn Comneno < > >> giancarlo.cicellyn@gmail.com> wrote: > >> > >>> This requirement originates from the ongoing bitbake-setup integration > >>> work in the VS Code BitBake extension: > >>> https://github.com/yoctoproject/vscode-bitbake/issues/530 > >>> > >>> In August, Enguerrand proposed an initialization workflow in which the > >>> extension presents the available configurations and fragment choices > >>> through VS Code QuickPick prompts before invoking bitbake-setup init. > >>> > >>> The relevant design discussion is here: > >>> > https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5293176033 > >>> > >>> The current registry listing provides template identifiers and > metadata, > >>> but not the template contents needed for those prompts. > >>> > >>> Enguerrand also suggested extending bitbake-setup itself: > >>> > https://github.com/yoctoproject/vscode-bitbake/issues/530#issuecomment-5295164589 > >>> > >>> I investigated a Wrynose-specific workaround based on non-interactive > >>> diagnostics, but subsequent experiments exposed limitations that make > it > >>> unsuitable as a reliable general-purpose inspection interface. > >>> > >>> The proposed patch addresses this specific integration requirement > while > >>> avoiding duplication of the existing BitBake registry fetching > mechanism in > >>> TypeScript. > >>> > >> > >> The patch mentions none of this. Did a human look at it before > submission? > >> I suspect not. > >> > >> The proposal is "give us the json, and we'll reimplement both > >> configuration template handling and interactive selection logic". Doing > >> that is non-trivial, and you'll end up something that needs ongoing > >> maintenance and can be a source of subtle behaviour differences, or the > >> json changing between the interactive selection and bitbake-setup > >> invocation in non-interactive mode to actually set up a build. Right > now, I > >> am not agreeing with the idea. > >> > >> I would like to first have a conversation (with actual humans, > >> including Enguerrand and Adrian) about how the interactive selection > part > >> should be handled. Can't vscode just run bitbake-setup in a interactive > >> window, and let it do its job? Is it possible for bitbake-setup to > handle > >> the logic, and coordinate UI prompts through some IPC mechanism? Should > we > >> rework btibake-setup to provide a python library with an API, which > would > >> allow alternative interaction UIs? > >> > >> I can revise the commit message to document this context in a v2. > >>> > >>> Regarding the AI policy, I acknowledge the requirements and take > >>> responsibility for the submitted changes as always. > >>> > >>> AI disclosure: ChatGPT (GPT-6.2) assisted in drafting this response. > >>> > >> I'd also like to point you to this section of the policy: > >> > >> "*The project will not accept automated contributions which rely > >> completely on AI generation without any significant human involvement, > >> judgement or review."* > >> > >> I am not seeing evidence of significant human involvement in either the > >> patch or 'this response'. You need to show clearly what you, the human, > >> did, and why your part is indeed significant. Even framing AI's > response in > >> a hand-written note, such as "Apologies for not providing any context, I > >> have asked AI to summarize that, here it is:" would've been much better. > >> > >> Alex > >> > > > > Best regards, > > -- > Paul Barker > >
diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 6b02558cc..99d67ad88 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -1030,11 +1030,29 @@ def list_registry(registry_path, with_expired): def list_configs(settings, args): import tempfile top_dir = tempfile.mkdtemp(prefix="bitbake-setup-list-") - settings['default']['dl-dir'] = os.path.join(top_dir, '.bitbake-setup-downloads') - d = init_bb_cache(top_dir, settings, args) - registry_path = update_registry(settings["default"]["registry"], cache_dir(top_dir), d) - json_data = list_registry(registry_path, args.with_expired) - shutil.rmtree(top_dir) + try: + settings['default']['dl-dir'] = os.path.join(top_dir, '.bitbake-setup-downloads') + d = init_bb_cache(top_dir, settings, args) + registry_path = update_registry(settings["default"]["registry"], cache_dir(top_dir), d) + json_data = list_registry(registry_path, args.with_expired) + # AI-Generated: Uses OpenAI Codex (gpt-6.1-sol). Export the template without selecting build options. + if args.config is not None: + if args.config not in json_data: + logger.error("Unable to find {} in available configurations; use 'list' sub-command to see what is available".format(args.config)) + sys.exit(1) + with open(get_registry_config(registry_path, args.config)) as f: + template = json.load(f) + except json.JSONDecodeError as e: + logger.error("Failed to parse configuration: %s" % e) + sys.exit(1) + finally: + shutil.rmtree(top_dir) + + if args.config is not None: + with open(args.write_json, 'w') as f: + json.dump(template, f, sort_keys=True, indent=4) + logger.plain("Configuration {} written into {}".format(args.config, args.write_json)) + return logger.plain("Available configurations:") for config_name, config_data in sorted(json_data.items()): @@ -1347,6 +1365,7 @@ def main(): parser_list = subparsers.add_parser('list', help='List available configurations') parser_list.add_argument('--with-expired', action='store_true', help='List also configurations that are no longer supported due to reaching their end-of-life dates.') parser_list.add_argument('--write-json', action='store', help='Write available configurations into a json file so they can be programmatically processed.') + parser_list.add_argument('--config', metavar='TEMPLATE_ID', help='Export a complete Configuration Template instead of the registry listing (requires --write-json).') parser_list.set_defaults(func=list_configs) parser_init = subparsers.add_parser('init', help='Select a configuration and initialize a setup from it') @@ -1406,6 +1425,9 @@ def main(): args = parser.parse_args() + if getattr(args, 'func', None) == list_configs and args.config is not None and not args.write_json: + parser_list.error('--config requires --write-json') + if args.debug: logger.setLevel(logging.DEBUG) elif args.quiet: diff --git a/doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst b/doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst index e15c9ed0d..d1c1543dc 100644 --- a/doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +++ b/doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst @@ -410,6 +410,10 @@ In addition, the command can take the following arguments: - ``--write-json``: write the configurations into a JSON file so they can be programmatically processed. +- ``--config TEMPLATE_ID``: with ``--write-json OUTPUT``, export the complete + selected Configuration Template as JSON without initializing a setup. + Expired templates require ``--with-expired``. + .. _ref-bbsetup-command-status: ``bitbake-setup status`` diff --git a/lib/bb/tests/setup.py b/lib/bb/tests/setup.py index 53a07ee3a..7636f1d53 100644 --- a/lib/bb/tests/setup.py +++ b/lib/bb/tests/setup.py @@ -17,6 +17,7 @@ import subprocess import sys import tempfile import unittest +from unittest import mock import venv import zipfile from bb.tests.support.httpserver import HTTPService @@ -319,6 +320,141 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) return os.path.join(self.tempdir, 'bitbake-builds', 'this-is-a-custom-gizmo-build') return os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, "-".join(c.split()))) + # AI-Generated: Uses OpenAI Codex (gpt-6.1-sol). Offline template export coverage. + def run_list_fixture(self, args, registry=None): + # Isolate all temporary cache directories and forbid network access. + tmpdir = os.path.join(self.tempdir, 'list-tmp') + os.makedirs(tmpdir, exist_ok=True) + with mock.patch.dict(os.environ, {'TMPDIR': tmpdir, 'BBPATH': ''}): + try: + return self.runbbsetup([ + '--no-network', '--setting', 'default', 'registry', registry or self.tempdir, + 'list'] + args) + finally: + self.assertEqual(os.listdir(tmpdir), []) + self.assertFalse(os.path.exists(os.path.join(self.tempdir, 'bitbake-builds'))) + self.assertFalse(os.path.exists(os.path.join(self.tempdir, '.bitbake-setup-cache'))) + for root, dirs, files in os.walk(self.tempdir): + self.assertNotIn('site.conf', files) + self.assertNotIn('layers', dirs) + self.assertNotIn('.vscode', dirs) + self.assertFalse(any(f.endswith('.code-workspace') for f in files)) + + def write_list_fixture(self, data): + registry = os.path.join(self.tempdir, 'configurations', 'nested') + os.makedirs(registry, exist_ok=True) + path = os.path.join(registry, 'test-template.conf.json') + with open(path, 'w') as f: + json.dump(data, f) + return path + + def test_list_export_template(self): + output = os.path.join(self.tempdir, 'template.json') + for count in (1, 2): + with self.subTest(configurations=count): + template = { + 'description': 'Complete template', 'version': '1.0', + 'sources': {'unused': {'git-remote': {'remotes': { + 'origin': {'uri': 'file://' + os.path.join(self.tempdir, 'unused-layer')}}, + 'branch': 'main', 'rev': 'HEAD'}}}, + 'bitbake-setup': {'configurations': [ + {'name': 'config-{}'.format(i), 'oe-template': 'unused', + 'oe-fragments-one-of': {'choice': {'options': ['a', 'b']}}} + for i in range(count)]}, + 'extension': {'nested': [None, True, False, 42, 1.5, 'café', + {'empty': [], 'object': {}}]}, + } + self.write_list_fixture(template) + self.run_list_fixture(['--config', 'test-template', '--write-json', output]) + with open(output) as f: + self.assertEqual(json.load(f), template) + + def test_list_export_unknown(self): + self.write_list_fixture({'description': 'Available template'}) + output = os.path.join(self.tempdir, 'template.json') + for existing in (False, True): + with self.subTest(existing=existing): + if existing: + with open(output, 'w') as f: + f.write('keep existing output') + with self.assertRaises(bb.process.ExecutionError) as error: + self.run_list_fixture(['--config', 'missing', '--write-json', output]) + self.assertIn('Unable to find missing', str(error.exception)) + if existing: + with open(output) as f: + self.assertEqual(f.read(), 'keep existing output') + else: + self.assertFalse(os.path.exists(output)) + + def test_list_export_expired(self): + template = {'description': 'Expired template', 'expires': '2000-01-01', + 'bitbake-setup': {'configurations': [{'name': 'expired'}]}} + self.write_list_fixture(template) + output = os.path.join(self.tempdir, 'template.json') + with self.assertRaises(bb.process.ExecutionError) as error: + self.run_list_fixture(['--config', 'test-template', '--write-json', output]) + self.assertIn('Unable to find test-template', str(error.exception)) + self.assertFalse(os.path.exists(output)) + self.run_list_fixture(['--config', 'test-template', '--with-expired', '--write-json', output]) + with open(output) as f: + self.assertEqual(json.load(f), template) + + def test_list_export_invalid_arguments(self): + with self.assertRaises(bb.process.ExecutionError) as error: + self.run_list_fixture(['--config', 'test-template']) + self.assertEqual(error.exception.exitcode, 2) + self.assertIn('--config requires --write-json', str(error.exception)) + + def test_list_export_invalid_json(self): + path = self.write_list_fixture({'description': 'Broken template'}) + with open(path, 'w') as f: + f.write('{invalid json') + output = os.path.join(self.tempdir, 'template.json') + for existing in (False, True): + with self.subTest(existing=existing): + if existing: + with open(output, 'w') as f: + f.write('keep existing output') + with self.assertRaises(bb.process.ExecutionError) as error: + self.run_list_fixture(['--config', 'test-template', '--write-json', output]) + self.assertIn('Failed to parse configuration', str(error.exception)) + if existing: + with open(output) as f: + self.assertEqual(f.read(), 'keep existing output') + else: + self.assertFalse(os.path.exists(output)) + + def test_list_export_registry_failure(self): + output = os.path.join(self.tempdir, 'template.json') + registry = 'git://{};protocol=file;branch=master;rev=master'.format( + os.path.join(self.tempdir, 'missing-registry')) + with self.assertRaises(bb.process.ExecutionError): + self.run_list_fixture(['--config', 'test-template', '--write-json', output], + registry=registry) + self.assertFalse(os.path.exists(output)) + + def test_list_registry_json_compatibility(self): + self.write_list_fixture({'description': 'Available template', 'extra': {'a': [1, 2]}}) + registry = os.path.join(self.tempdir, 'configurations') + with open(os.path.join(registry, 'old.conf.json'), 'w') as f: + json.dump({'description': 'Old template', 'expires': '2000-01-01'}, f) + output = os.path.join(self.tempdir, 'registry.json') + for expired in (False, True): + with self.subTest(with_expired=expired): + flags = ['--with-expired'] if expired else [] + plain = self.run_list_fixture(flags)[0] + written = self.run_list_fixture(flags + ['--write-json', output])[0] + self.assertEqual(written, plain + 'Available configurations written into {}\n'.format(output)) + self.assertIn('test-template\tAvailable template', plain) + expected = {'test-template': {'description': 'Available template'}} + if expired: + expected['old'] = {'description': 'Old template', 'expires': '2000-01-01'} + self.assertIn('old\tOld template (supported until 2000-01-01)', plain) + else: + self.assertNotIn('old\t', plain) + with open(output) as f: + self.assertEqual(json.load(f), expected) + def test_setup(self): # unset BBPATH to ensure tests run in isolation from the existing bitbake environment if 'BBPATH' in os.environ:
The list command can export registry metadata as JSON, but does not provide the contents of an individual configuration template. External tools therefore cannot inspect its configuration and fragment choices without initializing a setup or duplicating registry fetching logic. Add a --config option to list, requiring --write-json, to export the complete selected template using the existing registry acquisition and lookup functions. Respect the existing expiration filter and ensure temporary registry directories are removed on failure as well as on success. Preserve the existing list output and leave the init workflow unchanged. Add offline tests covering template export, expiration filtering, error handling, cleanup and compatibility with existing list output. Validation: LC_ALL=C BB_SKIP_NETTESTS=yes bin/bitbake-selftest bb.tests.setup 19 tests run, 11 passed, 8 skipped. AI-Generated: Uses OpenAI Codex (gpt-6.1-sol) AI-Generated: Uses OpenAI ChatGPT (GPT-6.2) Signed-off-by: Giancarlo Cicellyn Comneno <giancarlo.cicellyn@gmail.com> --- bin/bitbake-setup | 32 ++++- .../bitbake-user-manual-environment-setup.rst | 4 + lib/bb/tests/setup.py | 136 ++++++++++++++++++ 3 files changed, 167 insertions(+), 5 deletions(-)