Skip to contentSkip to conversation

bitbake-setup: extra-remotes support for contrib push mirrors

PATCH In review AdrianF 3 participants 11 messages Apr 6 – Apr 8

lore
Share & tools
lore

AdrianF

author
#0 lore raw

cover bitbake-setup: extra-remotes support for contrib push mirrors

From: Adrian Freihofer <[email protected]>

This series contains one small fix and a new feature that may warrant discussion before merging.

Fix (likely uncontroversial):
bitbake-setup: update vscode workspace always

The vscode workspace file is now updated unconditionally so that a manually changed build directory is always reflected. Previously it was skipped when the registry configuration had not changed.

New feature (may need discussion / could be postponed):
bitbake-setup: add support for extra-remotes in layer sources
bitbake-setup: add contrib extra-remotes to default-registry configs
bitbake-selftest: setup: add test_extra_remotes

Adds an 'extra-remotes' property to git-remote source definitions so that additional git remotes (e.g. SSH push mirrors) can be configured in checked-out repositories after checkout, without affecting fetch or change detection.

A new --extra-remotes-filter option controls which remotes are added:
non-optional (default), all, none, or comma-separated names.

The default-registry entries for bitbake, openembedded-core, and meta-yocto are extended with optional 'contrib' extra-remotes pointing to the SSH push mirrors on push.openembedded.org.

Self-tests cover all filter variants and the re-apply/update behaviour.

Adrian Freihofer (4):
bitbake-setup: update vscode workspace always
bitbake-setup: add support for extra-remotes in layer sources
bitbake-setup: add contrib extra-remotes to default-registry configs
bitbake-selftest: setup: add test_extra_remotes

 bin/bitbake-setup                             |  87 +++++++++++++-
 .../oe-nodistro-master.conf.json              |  16 ++-
 .../oe-nodistro-whinlatter.conf.json          |  16 ++-
 .../configurations/poky-master.conf.json      |  24 +++-
 .../configurations/poky-whinlatter.conf.json  |  24 +++-
 lib/bb/tests/setup.py                         | 107 ++++++++++++++++++
 setup-schema/layers.schema.json               |  22 ++++
 7 files changed, 280 insertions(+), 16 deletions(-)
Signature · 1 line
2.53.0
author
#1 lore raw

PATCH 1/4 bitbake-setup: update vscode workspace always

From: Adrian Freihofer <[email protected]>

Update the vscode workspace file with the current build directory, even if the configuration in the registry has not changed. This allows to keep the workspace file up to date when the build directory is changed manually.

---
 bin/bitbake-setup | 5 +++++
 1 file changed, 5 insertions(+)
bin/bitbake-setup +5 -0
index c006a059c..5a3394092 100755
@@ -956,6 +956,11 @@ def build_status(top_dir, settings, args, d, update=False):
         return
 
     logger.plain("\nConfiguration in {} has not changed.".format(setupdir))
+    if update:
+        workspace_file = os.path.join(setupdir, "bitbake.code-workspace")
+        if os.path.exists(workspace_file):
+            bitbake_builddir = os.path.join(setupdir, "build")
+            configure_vscode(setupdir, layerdir, bitbake_builddir, os.path.join(bitbake_builddir, "init-build-env"))
 
 def build_update(top_dir, settings, args, d):
     build_status(top_dir, settings, args, d, update=True)
Signature · 1 line
2.53.0
#2 lore raw

Re: [bitbake-devel] [PATCH 1/4] bitbake-setup: update vscode workspace always

bin/bitbake-setup def build_status(top_dir, settings, args, d, update=False): · line 963

Quoted 6 lines · Adrian Freihofer via lists.openembedded.org

logger.plain("\nConfiguration in {} has not changed.".format(setupdir))

bin/bitbake-setup +5 -0
+    if update:
+        workspace_file = os.path.join(setupdir, "bitbake.code-workspace")
+        if os.path.exists(workspace_file):
+            bitbake_builddir = os.path.join(setupdir, "build")
+            configure_vscode(setupdir, layerdir, bitbake_builddir, os.path.join(bitbake_builddir, "init-build-env"))

Will this do the update quietly or inform the user that vscode workspace is being synced with local changes even though no configuration updates have been detected?

Perhaps this should be its own command rather, something like 'update-vscode-workspace' ?

Alex

#3 lore raw

Re: [bitbake-devel] [PATCH 1/4] bitbake-setup: update vscode workspace always

Quoted 13 lines · Alexander Kanavin via lists.openembedded.org
Quoted 9 lines · Adrian Freihofer via lists.openembedded.org

     logger.plain("\nConfiguration in {} has not changed.".format(setupdir))
+    if update:
+        workspace_file = os.path.join(setupdir, "bitbake.code- workspace")
+        if os.path.exists(workspace_file):
+            bitbake_builddir = os.path.join(setupdir, "build") +            configure_vscode(setupdir, layerdir, bitbake_builddir, os.path.join(bitbake_builddir, "init-build-env"))

Quoted 3 lines

Will this do the update quietly or inform the user that vscode workspace is being synced with local changes even though no configuration updates have been detected?

The configure_vscode function preserves user-customized VSCode configurations and it enforces essential settings required for proper functionality. That means, executing configure_vscode should not harm and hence it should be fine to just run it always (when "which code" is true).

Having this as a separate command looks like more complicated for the user. Expecting that the user always does something like

bitbake-setup update
bitbake-setup update-vscode-workspace

would be inconvenient. Most probably the user would just not run the second command and end up with an inconsistent environment which can be very annoying.

Or do you mean a separate command in addition to calling the configure_vscode function in init and update? That would then lead to the question when the user should run bitbake-setup update-vscode- workspace. After init? After update? Or just if update does nothing but the VSCode configuration needs an update?
Having only bitbake-setup update to update what ever might needs an update, looks at least simple to me. But I agree, a separate command could work as well.

Maybe this patch is not very important if bitbake-setup itself does not change anymore. Might be that I thought this should be improved when working on bitbake-setup itself, which is a very special use case.

Thanks for the quick feedback
Adrian

Quoted 16 lines

Perhaps this should be its own command rather, something like 'update-vscode-workspace' ?

Alex

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#19351):
https://lists.openembedded.org/g/bitbake-devel/message/19351
Mute This Topic: https://lists.openembedded.org/mt/118697281/4454582
Group Owner: [email protected] Unsubscribe:
https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]
]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw

Re: [bitbake-devel] [PATCH 1/4] bitbake-setup: update vscode workspace always

Quoted 3 lines · On Tue, 7 Apr 2026 at 21:58, <[email protected]> wrote:

Maybe this patch is not very important if bitbake-setup itself does not change anymore. Might be that I thought this should be improved when working on bitbake-setup itself, which is a very special use case.

What I would like to understand is this: what kind of local changes require re-generating the vscode workspace (when otherwise there are no changes in bitbake-setup configuration). Presumably the user does 'something' that causes the workspace to go out of sync, what is it, can you provide examples? Can we write the workspace in a more 'universal' way such that it doesn't happen?

Alex

author
#5 lore raw

PATCH 2/4 bitbake-setup: add support for extra-remotes in layer sources

In reply to AdrianF

From: Adrian Freihofer <[email protected]>

Support an easy way to configure the contrib git remotes in checked-out layer repositories.

Add an 'extra-remotes' property to the git-remote source definition. Extra remotes are added to checked-out repositories via 'git remote add' after checkout, but are not used for fetching or change detection. This is useful for contrib push URIs (e.g. SSH push mirrors) that should not affect how bitbake-setup fetches or tracks upstream changes.

Each extra remote entry supports:
- 'uri': the remote URI (required)
- 'optional': if true, the remote is excluded by the default 'non-optional' filter (useful for remotes that require special access like SSH keys); failures when adding any extra remote are always reported as warnings

A new --extra-remotes-filter option is added to 'init' and 'update':
- 'non-optional' (default): configure only non-optional extra remotes
- 'all': configure all extra remotes including optional ones
- 'none': skip all extra remotes
- comma-separated names: configure only the named remotes

---
 bin/bitbake-setup               | 82 ++++++++++++++++++++++++++++++---
 setup-schema/layers.schema.json | 22 +++++++++
 2 files changed, 98 insertions(+), 6 deletions(-)
bin/bitbake-setup +76 -6
index 5a3394092..9962a25f1 100755
@@ -152,6 +152,27 @@ def add_unique_timestamp_to_path(path):
                 break
     return path_unique
 
+def _filter_extra_remotes(extra_remotes, filter_value):
+    """
+    Filter the extra-remotes dict according to --extra-remotes-filter.
+    'non-optional' -> return only entries where optional is False (default)
+    'all'  -> return all entries including optional ones
+    'none' -> return empty dict
+    otherwise -> treat filter_value as a comma-separated list of allowed remote names
+    """
+    logger.debug("_filter_extra_remotes: filter='{}', candidates={}".format(filter_value, list(extra_remotes.keys())))
+    if filter_value == 'non-optional':
+        result = {k: v for k, v in extra_remotes.items() if not v.get('optional', False)}
+    elif filter_value == 'all':
+        result = extra_remotes
+    elif filter_value == 'none':
+        result = {}
+    else:
+        allowed = {n.strip() for n in filter_value.split(',')}
+        result = {k: v for k, v in extra_remotes.items() if k in allowed}
+    logger.debug("_filter_extra_remotes: selected={}".format(list(result.keys())))
+    return result
+
 def _get_remotes(r_remote):
     remotes = []
 
@@ -167,7 +188,41 @@ def _get_remotes(r_remote):
 
     return remotes
 
-def checkout_layers(layers, confdir, layerdir, d, rebase_conflicts_strategy='abort'):
+def _add_extra_remotes(extra_remotes, repodir_path):
+    if not os.path.exists(os.path.join(repodir_path, '.git')):
+        logger.debug("_add_extra_remotes: skipping {}, no .git entry found".format(repodir_path))
+        return
+    existing = bb.process.run('git -C {} remote'.format(repodir_path))[0].split()
+    logger.debug("_add_extra_remotes: existing remotes in {}: {}".format(repodir_path, existing))
+    for remote_name, remote_data in extra_remotes.items():
+        uri = remote_data['uri']
+        try:
+            if remote_name in existing:
+                bb.process.run('git -C {} remote set-url {} {}'.format(repodir_path, remote_name, uri))
+                logger.plain("    Updated extra remote '{}' -> {}".format(remote_name, uri))
+            else:
+                bb.process.run('git -C {} remote add {} {}'.format(repodir_path, remote_name, uri))
+                logger.plain("    Added extra remote '{}' -> {}".format(remote_name, uri))
+        except bb.process.ExecutionError as e:
+            logger.warning("    Skipping extra remote '{}': {}".format(remote_name, e))
+
+def _apply_extra_remotes(r_name, r_data, layerdir, extra_remotes_filter):
+    r_remote = r_data.get('git-remote')
+    if not r_remote:
+        logger.debug("_apply_extra_remotes: skipping {}, no git-remote".format(r_name))
+        return
+    extra_remotes = r_remote.get('extra-remotes')
+    if not extra_remotes:
+        logger.debug("_apply_extra_remotes: skipping {}, no extra-remotes defined".format(r_name))
+        return
+    extra_remotes = _filter_extra_remotes(extra_remotes, extra_remotes_filter)
+    if extra_remotes:
+        repodir = r_data.get('path', r_name)
+        _add_extra_remotes(extra_remotes, os.path.join(layerdir, repodir))
+    else:
+        logger.debug("_apply_extra_remotes: all extra-remotes for {} were filtered out".format(r_name))
+
+def checkout_layers(layers, confdir, layerdir, d, rebase_conflicts_strategy='abort', extra_remotes_filter='non-optional'):
     def _checkout_git_remote(r_remote, repodir, layers_fixed_revisions):
         rev = r_remote['rev']
         branch = r_remote.get('branch', None)
@@ -236,6 +291,7 @@ bitbake-setup init -L {} /path/to/repo/checkout""".format(
 
         if r_remote:
             _checkout_git_remote(r_remote, repodir, layers_fixed_revisions)
+            _apply_extra_remotes(r_name, r_data, layerdir, extra_remotes_filter)
         if r_local:
             _symlink_local(os.path.expanduser(r_local["path"]), repodir_path)
 
@@ -458,9 +514,9 @@ def merge_overrides_into_sources(sources, overrides):
             layers[k] = v
     return layers
 
-def update_build(config, confdir, setupdir, layerdir, d, update_bb_conf="prompt", init_vscode=False, rebase_conflicts_strategy='abort'):
+def update_build(config, confdir, setupdir, layerdir, d, update_bb_conf="prompt", init_vscode=False, rebase_conflicts_strategy='abort', extra_remotes_filter='non-optional'):
     layer_config = merge_overrides_into_sources(config["data"]["sources"], config["source-overrides"]["sources"])
-    sources_fixed_revisions = checkout_layers(layer_config, confdir, layerdir, d, rebase_conflicts_strategy=rebase_conflicts_strategy)
+    sources_fixed_revisions = checkout_layers(layer_config, confdir, layerdir, d, rebase_conflicts_strategy=rebase_conflicts_strategy, extra_remotes_filter=extra_remotes_filter)
     bitbake_config = config["bitbake-config"]
     thisdir = os.path.dirname(config["path"]) if config["type"] == 'local' else None
     setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_conf, init_vscode)
@@ -866,7 +922,7 @@ def init_config(top_dir, settings, args):
     bb.event.register("bb.build.TaskProgress", handle_task_progress, data=d)
 
     write_upstream_config(confdir, upstream_config)
-    update_build(upstream_config, confdir, setupdir, layerdir, d, update_bb_conf="yes", init_vscode=args.init_vscode)
+    update_build(upstream_config, confdir, setupdir, layerdir, d, update_bb_conf="yes", init_vscode=args.init_vscode, extra_remotes_filter=args.extra_remotes_filter)
 
     bb.event.remove("bb.build.TaskProgress", None)
 
@@ -943,7 +999,8 @@ def build_status(top_dir, settings, args, d, update=False):
         logger.plain('\nConfiguration in {} has changed:\n{}'.format(setupdir, config_diff))
         if update:
             update_build(new_upstream_config, confdir, setupdir, layerdir, d,
-                         update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy)
+                         update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy,
+                         extra_remotes_filter=args.extra_remotes_filter)
         else:
             bb.process.run('git -C {} restore config-upstream.json'.format(confdir))
         return
@@ -952,11 +1009,14 @@ def build_status(top_dir, settings, args, d, update=False):
     if are_layers_changed(layer_config, layerdir, d):
         if update:
             update_build(current_upstream_config, confdir, setupdir, layerdir,
-                         d, update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy)
+                         d, update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy,
+                         extra_remotes_filter=args.extra_remotes_filter)
         return
 
     logger.plain("\nConfiguration in {} has not changed.".format(setupdir))
     if update:
+        for r_name, r_data in layer_config.items():
+            _apply_extra_remotes(r_name, r_data, layerdir, args.extra_remotes_filter)
         workspace_file = os.path.join(setupdir, "bitbake.code-workspace")
         if os.path.exists(workspace_file):
             bitbake_builddir = os.path.join(setupdir, "build")
@@ -1239,6 +1299,14 @@ def main():
         else:
             parser.add_argument('--setup-dir', required=True, help="Path to the setup")
 
+    def add_extra_remotes_filter_arg(parser):
+        parser.add_argument('--extra-remotes-filter', default='non-optional', metavar='FILTER', dest='extra_remotes_filter',
+                            help="Control which extra-remotes are configured in checked-out repositories: "
+                                 "'non-optional' (default) configures only extra-remotes that are not marked as optional; "
+                                 "'all' configures all extra-remotes including optional ones; "
+                                 "'none' skips all extra-remotes; "
+                                 "a comma-separated list of remote names configures only those named remotes (e.g. 'contrib,upstream').")
+
     parser = argparse.ArgumentParser(
         description="BitBake setup utility. Run with 'init' argument to get started.",
         epilog="Use %(prog)s <subcommand> --help to get help on a specific command"
@@ -1269,6 +1337,7 @@ def main():
                         help='Symlink local source into a build, instead of getting it as prescribed by a configuration (useful for local development).')
     parser_init.add_argument('--init-vscode', action=argparse.BooleanOptionalAction, default=bool(shutil.which('code')),
                         help='Generate VSCode workspace configuration (default: %(default)s)')
+    add_extra_remotes_filter_arg(parser_init)
     parser_init.set_defaults(func=init_config)
 
     parser_status = subparsers.add_parser('status', help='Check if the setup needs to be synchronized with configuration')
@@ -1282,6 +1351,7 @@ def main():
                         help="What to do when a layer repository has local modifications that prevent "
                              "an in-place update: 'abort' (default) aborts with an error message; "
                              "'backup' renames the directory to a timestamped backup and re-clones from upstream.")
+    add_extra_remotes_filter_arg(parser_update)
     parser_update.set_defaults(func=build_update)
 
     parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine')
setup-schema/layers.schema.json +22 -0
index f42606941..65b5ae5c7 100644
@@ -67,6 +67,28 @@
                                         }
                                     }
                                 }}
+                            },
+                            "extra-remotes": {
+                                "description": "Additional named git remotes to configure in the checked-out repository. These are not used for fetching or change detection, only added via 'git remote add'.",
+                                "type": "object",
+                                "patternProperties": { ".*" : {
+                                    "description": "An extra git remote",
+                                    "type": "object",
+                                    "additionalProperties": false,
+                                    "required": [
+                                        "uri"
+                                    ],
+                                    "properties": {
+                                        "uri": {
+                                            "description": "The URI for the remote",
+                                            "type": "string"
+                                        },
+                                        "optional": {
+                                            "description": "If true, the remote is excluded by the default 'non-optional' filter. Useful for remotes that require special access (e.g. contrib push URIs with SSH keys).",
+                                            "type": "boolean"
+                                        }
+                                    }
+                                }}
                             }
                         }
                     },
Signature · 1 line
2.53.0
#6 lore raw

Re: [bitbake-devel] [PATCH 2/4] bitbake-setup: add support for extra-remotes in layer sources

I'd rather think we should make regular 'multiple remotes' work well, instead of adding a whole new 'extra-remotes' property. E.g. define additional per-remote properties to avoid fetching when that is undesired, etc.

Alex

Quoted 236 lines · Adrian Freihofer via lists.openembedded.org

From: Adrian Freihofer <[email protected]>

Support an easy way to configure the contrib git remotes in checked-out layer repositories.

Add an 'extra-remotes' property to the git-remote source definition. Extra remotes are added to checked-out repositories via 'git remote add' after checkout, but are not used for fetching or change detection. This is useful for contrib push URIs (e.g. SSH push mirrors) that should not affect how bitbake-setup fetches or tracks upstream changes.

Each extra remote entry supports:
- 'uri': the remote URI (required)
- 'optional': if true, the remote is excluded by the default 'non-optional' filter (useful for remotes that require special access like SSH keys); failures when adding any extra remote are always reported as warnings

A new --extra-remotes-filter option is added to 'init' and 'update':
- 'non-optional' (default): configure only non-optional extra remotes
- 'all': configure all extra remotes including optional ones
- 'none': skip all extra remotes
- comma-separated names: configure only the named remotes

---
 bin/bitbake-setup               | 82 ++++++++++++++++++++++++++++++---
 setup-schema/layers.schema.json | 22 +++++++++
 2 files changed, 98 insertions(+), 6 deletions(-)
bin/bitbake-setup +76 -6
index 5a3394092..9962a25f1 100755
@@ -152,6 +152,27 @@ def add_unique_timestamp_to_path(path):
                 break
     return path_unique
 
+def _filter_extra_remotes(extra_remotes, filter_value):
+    """
+    Filter the extra-remotes dict according to --extra-remotes-filter.
+    'non-optional' -> return only entries where optional is False (default)
+    'all'  -> return all entries including optional ones
+    'none' -> return empty dict
+    otherwise -> treat filter_value as a comma-separated list of allowed remote names
+    """
+    logger.debug("_filter_extra_remotes: filter='{}', candidates={}".format(filter_value, list(extra_remotes.keys())))
+    if filter_value == 'non-optional':
+        result = {k: v for k, v in extra_remotes.items() if not v.get('optional', False)}
+    elif filter_value == 'all':
+        result = extra_remotes
+    elif filter_value == 'none':
+        result = {}
+    else:
+        allowed = {n.strip() for n in filter_value.split(',')}
+        result = {k: v for k, v in extra_remotes.items() if k in allowed}
+    logger.debug("_filter_extra_remotes: selected={}".format(list(result.keys())))
+    return result
+
 def _get_remotes(r_remote):
     remotes = []
 
@@ -167,7 +188,41 @@ def _get_remotes(r_remote):
 
     return remotes
 
-def checkout_layers(layers, confdir, layerdir, d, rebase_conflicts_strategy='abort'):
+def _add_extra_remotes(extra_remotes, repodir_path):
+    if not os.path.exists(os.path.join(repodir_path, '.git')):
+        logger.debug("_add_extra_remotes: skipping {}, no .git entry found".format(repodir_path))
+        return
+    existing = bb.process.run('git -C {} remote'.format(repodir_path))[0].split()
+    logger.debug("_add_extra_remotes: existing remotes in {}: {}".format(repodir_path, existing))
+    for remote_name, remote_data in extra_remotes.items():
+        uri = remote_data['uri']
+        try:
+            if remote_name in existing:
+                bb.process.run('git -C {} remote set-url {} {}'.format(repodir_path, remote_name, uri))
+                logger.plain("    Updated extra remote '{}' -> {}".format(remote_name, uri))
+            else:
+                bb.process.run('git -C {} remote add {} {}'.format(repodir_path, remote_name, uri))
+                logger.plain("    Added extra remote '{}' -> {}".format(remote_name, uri))
+        except bb.process.ExecutionError as e:
+            logger.warning("    Skipping extra remote '{}': {}".format(remote_name, e))
+
+def _apply_extra_remotes(r_name, r_data, layerdir, extra_remotes_filter):
+    r_remote = r_data.get('git-remote')
+    if not r_remote:
+        logger.debug("_apply_extra_remotes: skipping {}, no git-remote".format(r_name))
+        return
+    extra_remotes = r_remote.get('extra-remotes')
+    if not extra_remotes:
+        logger.debug("_apply_extra_remotes: skipping {}, no extra-remotes defined".format(r_name))
+        return
+    extra_remotes = _filter_extra_remotes(extra_remotes, extra_remotes_filter)
+    if extra_remotes:
+        repodir = r_data.get('path', r_name)
+        _add_extra_remotes(extra_remotes, os.path.join(layerdir, repodir))
+    else:
+        logger.debug("_apply_extra_remotes: all extra-remotes for {} were filtered out".format(r_name))
+
+def checkout_layers(layers, confdir, layerdir, d, rebase_conflicts_strategy='abort', extra_remotes_filter='non-optional'):
     def _checkout_git_remote(r_remote, repodir, layers_fixed_revisions):
         rev = r_remote['rev']
         branch = r_remote.get('branch', None)
@@ -236,6 +291,7 @@ bitbake-setup init -L {} /path/to/repo/checkout""".format(
 
         if r_remote:
             _checkout_git_remote(r_remote, repodir, layers_fixed_revisions)
+            _apply_extra_remotes(r_name, r_data, layerdir, extra_remotes_filter)
         if r_local:
             _symlink_local(os.path.expanduser(r_local["path"]), repodir_path)
 
@@ -458,9 +514,9 @@ def merge_overrides_into_sources(sources, overrides):
             layers[k] = v
     return layers
 
-def update_build(config, confdir, setupdir, layerdir, d, update_bb_conf="prompt", init_vscode=False, rebase_conflicts_strategy='abort'):
+def update_build(config, confdir, setupdir, layerdir, d, update_bb_conf="prompt", init_vscode=False, rebase_conflicts_strategy='abort', extra_remotes_filter='non-optional'):
     layer_config = merge_overrides_into_sources(config["data"]["sources"], config["source-overrides"]["sources"])
-    sources_fixed_revisions = checkout_layers(layer_config, confdir, layerdir, d, rebase_conflicts_strategy=rebase_conflicts_strategy)
+    sources_fixed_revisions = checkout_layers(layer_config, confdir, layerdir, d, rebase_conflicts_strategy=rebase_conflicts_strategy, extra_remotes_filter=extra_remotes_filter)
     bitbake_config = config["bitbake-config"]
     thisdir = os.path.dirname(config["path"]) if config["type"] == 'local' else None
     setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_conf, init_vscode)
@@ -866,7 +922,7 @@ def init_config(top_dir, settings, args):
     bb.event.register("bb.build.TaskProgress", handle_task_progress, data=d)
 
     write_upstream_config(confdir, upstream_config)
-    update_build(upstream_config, confdir, setupdir, layerdir, d, update_bb_conf="yes", init_vscode=args.init_vscode)
+    update_build(upstream_config, confdir, setupdir, layerdir, d, update_bb_conf="yes", init_vscode=args.init_vscode, extra_remotes_filter=args.extra_remotes_filter)
 
     bb.event.remove("bb.build.TaskProgress", None)
 
@@ -943,7 +999,8 @@ def build_status(top_dir, settings, args, d, update=False):
         logger.plain('\nConfiguration in {} has changed:\n{}'.format(setupdir, config_diff))
         if update:
             update_build(new_upstream_config, confdir, setupdir, layerdir, d,
-                         update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy)
+                         update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy,
+                         extra_remotes_filter=args.extra_remotes_filter)
         else:
             bb.process.run('git -C {} restore config-upstream.json'.format(confdir))
         return
@@ -952,11 +1009,14 @@ def build_status(top_dir, settings, args, d, update=False):
     if are_layers_changed(layer_config, layerdir, d):
         if update:
             update_build(current_upstream_config, confdir, setupdir, layerdir,
-                         d, update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy)
+                         d, update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy,
+                         extra_remotes_filter=args.extra_remotes_filter)
         return
 
     logger.plain("\nConfiguration in {} has not changed.".format(setupdir))
     if update:
+        for r_name, r_data in layer_config.items():
+            _apply_extra_remotes(r_name, r_data, layerdir, args.extra_remotes_filter)
         workspace_file = os.path.join(setupdir, "bitbake.code-workspace")
         if os.path.exists(workspace_file):
             bitbake_builddir = os.path.join(setupdir, "build")
@@ -1239,6 +1299,14 @@ def main():
         else:
             parser.add_argument('--setup-dir', required=True, help="Path to the setup")
 
+    def add_extra_remotes_filter_arg(parser):
+        parser.add_argument('--extra-remotes-filter', default='non-optional', metavar='FILTER', dest='extra_remotes_filter',
+                            help="Control which extra-remotes are configured in checked-out repositories: "
+                                 "'non-optional' (default) configures only extra-remotes that are not marked as optional; "
+                                 "'all' configures all extra-remotes including optional ones; "
+                                 "'none' skips all extra-remotes; "
+                                 "a comma-separated list of remote names configures only those named remotes (e.g. 'contrib,upstream').")
+
     parser = argparse.ArgumentParser(
         description="BitBake setup utility. Run with 'init' argument to get started.",
         epilog="Use %(prog)s <subcommand> --help to get help on a specific command"
@@ -1269,6 +1337,7 @@ def main():
                         help='Symlink local source into a build, instead of getting it as prescribed by a configuration (useful for local development).')
     parser_init.add_argument('--init-vscode', action=argparse.BooleanOptionalAction, default=bool(shutil.which('code')),
                         help='Generate VSCode workspace configuration (default: %(default)s)')
+    add_extra_remotes_filter_arg(parser_init)
     parser_init.set_defaults(func=init_config)
 
     parser_status = subparsers.add_parser('status', help='Check if the setup needs to be synchronized with configuration')
@@ -1282,6 +1351,7 @@ def main():
                         help="What to do when a layer repository has local modifications that prevent "
                              "an in-place update: 'abort' (default) aborts with an error message; "
                              "'backup' renames the directory to a timestamped backup and re-clones from upstream.")
+    add_extra_remotes_filter_arg(parser_update)
     parser_update.set_defaults(func=build_update)
 
     parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine')
setup-schema/layers.schema.json +22 -1
index f42606941..65b5ae5c7 100644
@@ -67,6 +67,28 @@
                                         }
                                     }
                                 }}
+                            },
+                            "extra-remotes": {
+                                "description": "Additional named git remotes to configure in the checked-out repository. These are not used for fetching or change detection, only added via 'git remote add'.",
+                                "type": "object",
+                                "patternProperties": { ".*" : {
+                                    "description": "An extra git remote",
+                                    "type": "object",
+                                    "additionalProperties": false,
+                                    "required": [
+                                        "uri"
+                                    ],
+                                    "properties": {
+                                        "uri": {
+                                            "description": "The URI for the remote",
+                                            "type": "string"
+                                        },
+                                        "optional": {
+                                            "description": "If true, the remote is excluded by the default 'non-optional' filter. Useful for remotes that require special access (e.g. contrib push URIs with SSH keys).",
+                                            "type": "boolean"
+                                        }
+                                    }
+                                }}
                             }
                         }
                     },
--

2.53.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#19336): https://lists.openembedded.org/g/bitbake-devel/message/19336
Mute This Topic: https://lists.openembedded.org/mt/118697285/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#7 lore raw

Re: [bitbake-devel] [PATCH 2/4] bitbake-setup: add support for extra-remotes in layer sources

Quoted 4 lines · Alexander Kanavin via lists.openembedded.org

I'd rather think we should make regular 'multiple remotes' work well, instead of adding a whole new 'extra-remotes' property. E.g. define additional per-remote properties to avoid fetching when that is undesired, etc.

Agree, that would be better.

Regards,
Adrian

Quoted 351 lines

Alex

Quoted 322 lines · Adrian Freihofer via lists.openembedded.org

From: Adrian Freihofer <[email protected]>

Support an easy way to configure the contrib git remotes in checked-out
layer repositories.

Add an 'extra-remotes' property to the git-remote source definition.
Extra remotes are added to checked-out repositories via 'git remote add'
after checkout, but are not used for fetching or change detection. This
is useful for contrib push URIs (e.g. SSH push mirrors) that should not affect how bitbake-setup fetches or tracks upstream changes.

Each extra remote entry supports:
- 'uri': the remote URI (required)
- 'optional': if true, the remote is excluded by the default 'non- optional'
  filter (useful for remotes that require special access like SSH keys);
  failures when adding any extra remote are always reported as warnings

A new --extra-remotes-filter option is added to 'init' and 'update':
- 'non-optional' (default): configure only non-optional extra remotes
- 'all': configure all extra remotes including optional ones
- 'none': skip all extra remotes
- comma-separated names: configure only the named remotes

---
 bin/bitbake-setup               | 82
++++++++++++++++++++++++++++++---
 setup-schema/layers.schema.json | 22 +++++++++

 2 files changed, 98 insertions(+), 6 deletions(-)
bin/bitbake-setup +0 -0
index 5a3394092..9962a25f1 100755
@@ -152,6 +152,27 @@ def add_unique_timestamp_to_path(path):

                 break
     return path_unique

+def _filter_extra_remotes(extra_remotes, filter_value):
+    """
+    Filter the extra-remotes dict according to --extra-remotes- filter.
+    'non-optional' -> return only entries where optional is False (default)
+    'all'  -> return all entries including optional ones +    'none' -> return empty dict
+    otherwise -> treat filter_value as a comma-separated list of allowed remote names
+    """
+    logger.debug("_filter_extra_remotes: filter='{}', candidates={}".format(filter_value, list(extra_remotes.keys()))) +    if filter_value == 'non-optional':
+        result = {k: v for k, v in extra_remotes.items() if not v.get('optional', False)}
+    elif filter_value == 'all':
+        result = extra_remotes
+    elif filter_value == 'none':
+        result = {}
+    else:
+        allowed = {n.strip() for n in filter_value.split(',')} +        result = {k: v for k, v in extra_remotes.items() if k in allowed}
+    logger.debug("_filter_extra_remotes:
selected={}".format(list(result.keys())))
+    return result
+
 def _get_remotes(r_remote):
     remotes = []

bin/bitbake-setup +0 -0
@@ -167,7 +188,41 @@ def _get_remotes(r_remote):
 

     return remotes

-def checkout_layers(layers, confdir, layerdir, d, rebase_conflicts_strategy='abort'):
+def _add_extra_remotes(extra_remotes, repodir_path):
+    if not os.path.exists(os.path.join(repodir_path, '.git')):
+        logger.debug("_add_extra_remotes: skipping {}, no .git entry found".format(repodir_path))
+        return
+    existing = bb.process.run('git -C {} remote'.format(repodir_path))[0].split()
+    logger.debug("_add_extra_remotes: existing remotes in {}:
{}".format(repodir_path, existing))
+    for remote_name, remote_data in extra_remotes.items():
+        uri = remote_data['uri']
+        try:
+            if remote_name in existing:
+                bb.process.run('git -C {} remote set-url {} {}'.format(repodir_path, remote_name, uri))
+                logger.plain("    Updated extra remote '{}' -> {}".format(remote_name, uri))
+            else:
+                bb.process.run('git -C {} remote add {} {}'.format(repodir_path, remote_name, uri))
+                logger.plain("    Added extra remote '{}' -> {}".format(remote_name, uri))
+        except bb.process.ExecutionError as e:
+            logger.warning("    Skipping extra remote '{}':
{}".format(remote_name, e))

bin/bitbake-setup +2 -0
+
+def _apply_extra_remotes(r_name, r_data, layerdir,

extra_remotes_filter):
+    r_remote = r_data.get('git-remote')
+    if not r_remote:
+        logger.debug("_apply_extra_remotes: skipping {}, no git- remote".format(r_name))
+        return
+    extra_remotes = r_remote.get('extra-remotes')
+    if not extra_remotes:
+        logger.debug("_apply_extra_remotes: skipping {}, no extra- remotes defined".format(r_name))
+        return
+    extra_remotes = _filter_extra_remotes(extra_remotes, extra_remotes_filter)
+    if extra_remotes:
+        repodir = r_data.get('path', r_name)
+        _add_extra_remotes(extra_remotes, os.path.join(layerdir, repodir))
+    else:
+        logger.debug("_apply_extra_remotes: all extra-remotes for {} were filtered out".format(r_name))

bin/bitbake-setup +2 -0
+
+def checkout_layers(layers, confdir, layerdir, d,

rebase_conflicts_strategy='abort', extra_remotes_filter='non- optional'):
     def _checkout_git_remote(r_remote, repodir, layers_fixed_revisions):
         rev = r_remote['rev']
         branch = r_remote.get('branch', None)

bin/bitbake-setup +0 -0
@@ -236,6 +291,7 @@ bitbake-setup init -L {}

/path/to/repo/checkout""".format(

         if r_remote:
             _checkout_git_remote(r_remote, repodir, layers_fixed_revisions)
+            _apply_extra_remotes(r_name, r_data, layerdir, extra_remotes_filter)
         if r_local:
             _symlink_local(os.path.expanduser(r_local["path"]), repodir_path)

bin/bitbake-setup +0 -0
@@ -458,9 +514,9 @@ def merge_overrides_into_sources(sources,

overrides):
             layers[k] = v
     return layers

-def update_build(config, confdir, setupdir, layerdir, d, update_bb_conf="prompt", init_vscode=False, rebase_conflicts_strategy='abort'):
+def update_build(config, confdir, setupdir, layerdir, d, update_bb_conf="prompt", init_vscode=False, rebase_conflicts_strategy='abort', extra_remotes_filter='non- optional'):
     layer_config = merge_overrides_into_sources(config["data"]["sources"], config["source-overrides"]["sources"])
-    sources_fixed_revisions = checkout_layers(layer_config, confdir, layerdir, d, rebase_conflicts_strategy=rebase_conflicts_strategy)
+    sources_fixed_revisions = checkout_layers(layer_config, confdir, layerdir, d, rebase_conflicts_strategy=rebase_conflicts_strategy, extra_remotes_filter=extra_remotes_filter) bitbake_config = config["bitbake-config"]
     thisdir = os.path.dirname(config["path"]) if config["type"] == 'local' else None
     setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_conf, init_vscode)

bin/bitbake-setup +1 -1
@@ -866,7 +922,7 @@ def init_config(top_dir, settings, args):
      bb.event.register("bb.build.TaskProgress",
 handle_task_progress, data=d)
 
      write_upstream_config(confdir, upstream_config)
-    update_build(upstream_config, confdir, setupdir, layerdir, d,
 update_bb_conf="yes", init_vscode=args.init_vscode)
+    update_build(upstream_config, confdir, setupdir, layerdir, d,
 update_bb_conf="yes", init_vscode=args.init_vscode,

extra_remotes_filter=args.extra_remotes_filter)

     bb.event.remove("bb.build.TaskProgress", None)

bin/bitbake-setup +0 -0
@@ -943,7 +999,8 @@ def build_status(top_dir, settings, args, d,

update=False):
         logger.plain('\nConfiguration in {} has changed:\n{}'.format(setupdir, config_diff))
         if update:
             update_build(new_upstream_config, confdir, setupdir, layerdir, d,
-                         update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy) +                         update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy, +
extra_remotes_filter=args.extra_remotes_filter)
         else:
             bb.process.run('git -C {} restore config- upstream.json'.format(confdir))
         return

bin/bitbake-setup +0 -0
@@ -952,11 +1009,14 @@ def build_status(top_dir, settings, args, d,

update=False):
     if are_layers_changed(layer_config, layerdir, d):
         if update:
             update_build(current_upstream_config, confdir, setupdir, layerdir,
-                         d, update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy) +                         d, update_bb_conf=args.update_bb_conf, rebase_conflicts_strategy=args.rebase_conflicts_strategy, +
extra_remotes_filter=args.extra_remotes_filter)
         return

     logger.plain("\nConfiguration in {} has not changed.".format(setupdir))
     if update:
+        for r_name, r_data in layer_config.items():
+            _apply_extra_remotes(r_name, r_data, layerdir, args.extra_remotes_filter)
         workspace_file = os.path.join(setupdir, "bitbake.code- workspace")
         if os.path.exists(workspace_file):
             bitbake_builddir = os.path.join(setupdir, "build")

bin/bitbake-setup +0 -0
@@ -1239,6 +1299,14 @@ def main():

         else:
             parser.add_argument('--setup-dir', required=True, help="Path to the setup")

+    def add_extra_remotes_filter_arg(parser):
+        parser.add_argument('--extra-remotes-filter', default='non-optional', metavar='FILTER', dest='extra_remotes_filter',
+                            help="Control which extra-remotes are configured in checked-out repositories: "
+                                 "'non-optional' (default) configures only extra-remotes that are not marked as optional; " +                                 "'all' configures all extra- remotes including optional ones; "
+                                 "'none' skips all extra-remotes; "
+                                 "a comma-separated list of remote names configures only those named remotes (e.g. 'contrib,upstream').")
+
     parser = argparse.ArgumentParser( description="BitBake setup utility. Run with 'init' argument to get started.",
         epilog="Use %(prog)s <subcommand> --help to get help on a specific command"

bin/bitbake-setup +0 -0
@@ -1269,6 +1337,7 @@ def main():
                          help='Symlink local source into a build,

instead of getting it as prescribed by a configuration (useful for local development).') parser_init.add_argument('--init-vscode', action=argparse.BooleanOptionalAction, default=bool(shutil.which('code')),
                         help='Generate VSCode workspace configuration (default: %(default)s)')
+    add_extra_remotes_filter_arg(parser_init) parser_init.set_defaults(func=init_config)

     parser_status = subparsers.add_parser('status', help='Check if the setup needs to be synchronized with configuration')

bin/bitbake-setup +0 -0
@@ -1282,6 +1351,7 @@ def main():

                         help="What to do when a layer repository has local modifications that prevent "
                              "an in-place update: 'abort' (default) aborts with an error message; "
                              "'backup' renames the directory to a timestamped backup and re-clones from upstream.")
+    add_extra_remotes_filter_arg(parser_update) parser_update.set_defaults(func=build_update)

     parser_install_buildtools = subparsers.add_parser('install- buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine')

setup- renamed from setup-schema/layers.schema.json +0 -0

schema/layers.schema.json
index f42606941..65b5ae5c7 100644

setup-schema/layers.schema.json +3 -0
@@ -67,6 +67,28 @@
                                          }
                                      }
                                  }}
+                            },
+                            "extra-remotes": {
+                                "description": "Additional named

git remotes to configure in the checked-out repository. These are not used for fetching or change detection, only added via 'git remote add'.",
+                                "type": "object",
+                                "patternProperties": { ".*" : { +                                    "description": "An extra git remote",
+                                    "type": "object",
+                                    "additionalProperties": false, +                                    "required": [
+                                        "uri"
+                                    ],
+                                    "properties": {
+                                        "uri": {
+                                            "description": "The URI for the remote",
+                                            "type": "string" +                                        },
+                                        "optional": {
+                                            "description": "If true, the remote is excluded by the default 'non-optional' filter. Useful for remotes that require special access (e.g. contrib push URIs with SSH keys).",
+                                            "type": "boolean"

Quoted 12 lines

+                                        }
+                                    }
+                                }}
                             }
                         }
                     },
--
2.53.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#19352):
https://lists.openembedded.org/g/bitbake-devel/message/19352
Mute This Topic: https://lists.openembedded.org/mt/118697285/4454582
Group Owner: [email protected] Unsubscribe:
https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]
]
-=-=-=-=-=-=-=-=-=-=-=-

author
#8 lore raw

PATCH 3/4 bitbake-setup: add contrib extra-remotes to default-registry configs

In reply to AdrianF

From: Adrian Freihofer <[email protected]>

Extend the default-registry configurations with 'contrib' extra-remotes for the bitbake, openembedded-core, and meta-yocto layer sources.

The contrib remotes point to the SSH push mirrors on push.openembedded.org and are marked optional=true, meaning they are excluded by the default 'non-optional' filter and must be explicitly requested via:

bitbake-setup init --extra-remotes-filter all ... bitbake-setup init --extra-remotes-filter contrib ...

---
 .../oe-nodistro-master.conf.json              | 16 +++++++++++--
 .../oe-nodistro-whinlatter.conf.json          | 16 +++++++++++--
 .../configurations/poky-master.conf.json      | 24 ++++++++++++++++---
 .../configurations/poky-whinlatter.conf.json  | 24 ++++++++++++++++---
 4 files changed, 70 insertions(+), 10 deletions(-)
default-registry/configurations/oe-nodistro-master.conf.json +14 -2
index 5aa148d42..c06f5602a 100644
@@ -5,14 +5,26 @@
             "git-remote": {
                 "uri": "https://git.openembedded.org/bitbake",
                 "branch": "master",
-                "rev": "master"
+                "rev": "master",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/bitbake-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "openembedded-core": {
             "git-remote": {
                 "uri": "https://git.openembedded.org/openembedded-core",
                 "branch": "master",
-                "rev": "master"
+                "rev": "master",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/openembedded-core-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "yocto-docs": {
default-registry/configurations/oe-nodistro-whinlatter.conf.json +14 -2
index 7b183ae1c..b8d5b1eca 100644
@@ -10,7 +10,13 @@
                     }
                 },
                 "branch": "2.16",
-                "rev": "2.16"
+                "rev": "2.16",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/bitbake-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "openembedded-core": {
@@ -21,7 +27,13 @@
                     }
                 },
                 "branch": "whinlatter",
-                "rev": "whinlatter"
+                "rev": "whinlatter",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/openembedded-core-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "yocto-docs": {
default-registry/configurations/poky-master.conf.json +21 -3
index 58d379648..bb7c53e10 100644
@@ -5,21 +5,39 @@
             "git-remote": {
                 "uri": "https://git.openembedded.org/bitbake",
                 "branch": "master",
-                "rev": "master"
+                "rev": "master",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/bitbake-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "openembedded-core": {
             "git-remote": {
                 "uri": "https://git.openembedded.org/openembedded-core",
                 "branch": "master",
-                "rev": "master"
+                "rev": "master",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/openembedded-core-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "meta-yocto": {
             "git-remote": {
                 "uri": "https://git.yoctoproject.org/meta-yocto",
                 "branch": "master",
-                "rev": "master"
+                "rev": "master",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/meta-yocto-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "yocto-docs": {
default-registry/configurations/poky-whinlatter.conf.json +21 -3
index 4827ebe11..ba82c5ed6 100644
@@ -10,7 +10,13 @@
                     }
                 },
                 "branch": "2.16",
-                "rev": "2.16"
+                "rev": "2.16",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/bitbake-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "openembedded-core": {
@@ -21,7 +27,13 @@
                     }
                 },
                 "branch": "whinlatter",
-                "rev": "whinlatter"
+                "rev": "whinlatter",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/openembedded-core-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "meta-yocto": {
@@ -32,7 +44,13 @@
                     }
                 },
                 "branch": "whinlatter",
-                "rev": "whinlatter"
+                "rev": "whinlatter",
+                "extra-remotes": {
+                    "contrib": {
+                        "uri": "ssh://[email protected]/meta-yocto-contrib",
+                        "optional": true
+                    }
+                }
             }
         },
         "yocto-docs": {
Signature · 1 line
2.53.0
author
#9 lore raw

PATCH 4/4 bitbake-selftest: setup: add test_extra_remotes

In reply to AdrianF

From: Adrian Freihofer <[email protected]>

Test the extra-remotes feature added in the preceding commit:

1. Default 'non-optional' filter: the non-optional remote is added to the checked-out layer, the optional one is skipped.
2. --extra-remotes-filter=all: both optional and non-optional remotes are added.
3. --extra-remotes-filter=none: no extra remotes are added.
4. --extra-remotes-filter=<name>: only the explicitly named remote is added.
5. update re-applies extra remotes and calls 'git remote set-url' when the URI of an existing remote changes.

---
 lib/bb/tests/setup.py | 107 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)
lib/bb/tests/setup.py +107 -0
index 638d56d3b..7b259cc97 100644
@@ -726,3 +726,110 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
             self.assertEqual(f.read(), 'conflicting-upstream\n',
                              "re-cloned layer must contain the upstream content after conflict backup")
         del os.environ['BBPATH']
+
+    def test_extra_remotes(self):
+        """
+        Test that extra-remotes are added and filtered correctly during init and update.
+
+        Covers:
+          1. Default 'non-optional' filter: non-optional remote added, optional skipped.
+          2. --extra-remotes-filter=all: both optional and non-optional remotes added.
+          3. --extra-remotes-filter=none: no extra remotes added.
+          4. --extra-remotes-filter=<name>: only the explicitly named remote added.
+          5. update re-applies extra remotes and updates the URI of an existing remote.
+        """
+        if 'BBPATH' in os.environ:
+            del os.environ['BBPATH']
+        os.chdir(self.tempdir)
+
+        self.runbbsetup("settings set default registry 'git://{};protocol=file;branch=master;rev=master'".format(self.registrypath))
+        self.add_file_to_testrepo('test-file', 'initial\n')
+
+        # Two local repos used as extra remote targets (remote_a = initial URI, remote_b = updated URI)
+        remote_a = os.path.join(self.tempdir, 'extra-remote-a')
+        remote_b = os.path.join(self.tempdir, 'extra-remote-b')
+        for remote in (remote_a, remote_b):
+            os.makedirs(remote)
+            self.git_init(cwd=remote)
+            self.git('commit --allow-empty -m "Initial commit"', cwd=remote)
+
+        # Config with one non-optional and one optional extra-remote
+        sources_both = '''
+        "test-repo": {
+            "git-remote": {
+                "remotes": {"origin": {"uri": "file://%s"}},
+                "branch": "master",
+                "rev": "master",
+                "extra-remotes": {
+                    "required-remote": {"uri": "file://%s"},
+                    "optional-remote": {"uri": "file://%s", "optional": true}
+                }
+            }
+        }
+        ''' % (self.testrepopath, remote_a, remote_b)
+        self._add_json_config_to_registry_helper('er-test.conf.json', sources_both)
+
+        def get_remotes(layer_path):
+            return self.git('remote', cwd=layer_path).split()
+
+        # 1. Default filter 'non-optional': required-remote added, optional-remote skipped
+        out = self.runbbsetup("init --non-interactive er-test gadget")
+        setuppath = self.get_setup_path('er-test', 'gadget')
+        layer_path = os.path.join(setuppath, 'layers', 'test-repo')
+        remotes = get_remotes(layer_path)
+        self.assertIn('required-remote', remotes,
+                      "non-optional extra remote must be added with the default 'non-optional' filter")
+        self.assertNotIn('optional-remote', remotes,
+                         "optional extra remote must be skipped by the default 'non-optional' filter")
+        self.assertEqual(
+            self.git('remote get-url required-remote', cwd=layer_path).strip(),
+            'file://' + remote_a)
+        self.assertIn("Added extra remote 'required-remote'", out[0])
+
+        # 2. --extra-remotes-filter=all: both optional and non-optional remotes added
+        self.runbbsetup("init --non-interactive --extra-remotes-filter=all --setup-dir-name er-filter-all er-test gadget")
+        all_layer = os.path.join(self.tempdir, 'bitbake-builds', 'er-filter-all', 'layers', 'test-repo')
+        remotes = get_remotes(all_layer)
+        self.assertIn('required-remote', remotes)
+        self.assertIn('optional-remote', remotes)
+
+        # 3. --extra-remotes-filter=none: no extra remotes added
+        self.runbbsetup("init --non-interactive --extra-remotes-filter=none --setup-dir-name er-filter-none er-test gadget")
+        none_layer = os.path.join(self.tempdir, 'bitbake-builds', 'er-filter-none', 'layers', 'test-repo')
+        remotes = get_remotes(none_layer)
+        self.assertNotIn('required-remote', remotes)
+        self.assertNotIn('optional-remote', remotes)
+
+        # 4. --extra-remotes-filter=<name>: only the explicitly named remote added
+        self.runbbsetup("init --non-interactive --extra-remotes-filter=optional-remote --setup-dir-name er-filter-named er-test gadget")
+        named_layer = os.path.join(self.tempdir, 'bitbake-builds', 'er-filter-named', 'layers', 'test-repo')
+        remotes = get_remotes(named_layer)
+        self.assertNotIn('required-remote', remotes)
+        self.assertIn('optional-remote', remotes)
+
+        # 5. update re-applies extra remotes and updates the URI of an existing remote
+        sources_updated = '''
+        "test-repo": {
+            "git-remote": {
+                "remotes": {"origin": {"uri": "file://%s"}},
+                "branch": "master",
+                "rev": "master",
+                "extra-remotes": {
+                    "required-remote": {"uri": "file://%s"}
+                }
+            }
+        }
+        ''' % (self.testrepopath, remote_b)
+        config_path = os.path.join(self.registrypath, 'er-test.conf.json')
+        os.remove(config_path)
+        self._add_json_config_to_registry_helper('er-test.conf.json', sources_updated)
+
+        os.environ['BBPATH'] = os.path.join(setuppath, 'build')
+        out = self.runbbsetup("update --update-bb-conf='no'")
+        del os.environ['BBPATH']
+
+        self.assertEqual(
+            self.git('remote get-url required-remote', cwd=layer_path).strip(),
+            'file://' + remote_b,
+            "update must call 'git remote set-url' to update the existing remote to the new URI")
+        self.assertIn("Updated extra remote 'required-remote'", out[0])
Signature · 1 line
2.53.0
#10 lore raw
In reply to AdrianF
Quoted 6 lines · Adrian Freihofer via lists.openembedded.org

This series contains one small fix and a new feature that may warrant discussion before merging.

Fix (likely uncontroversial):
bitbake-setup: update vscode workspace always

Quoted 8 lines

The vscode workspace file is now updated unconditionally so that a manually changed build directory is always reflected. Previously it was skipped when the registry configuration had not changed.

New feature (may need discussion / could be postponed):
bitbake-setup: add support for extra-remotes in layer sources
bitbake-setup: add contrib extra-remotes to default-registry configs
bitbake-selftest: setup: add test_extra_remotes

Please do not bundle fixes and RFC proposals like that. Send one as regular patch, then the other as RFC set.

Alex