diff mbox series

[1/2] bitbake-setup: add inline URI

Message ID 20251202160402.819060-1-corentin.guillevic@smile.fr
State New
Headers show
Series [1/2] bitbake-setup: add inline URI | expand

Commit Message

Corentin GUILLEVIC Dec. 2, 2025, 4:04 p.m. UTC
Most of the time, when we describe a remote, a bitbake-setup source looks like this:

"bitbake": {
    "git-remote": {
        "remotes": {
            "origin": {
                "uri": "https://git.openembedded.org/bitbake"
            }
        },
        ...
    }
}

i.e. an URI with the common name 'origin'. Alternatively, we could simplify this, by
using a shorter structure with the property 'uri' only:

"bitbake": {
    "git-remote": {
        "uri": "https://git.openembedded.org/bitbake",
        ...
    }
}

'uri' and 'remote' are then mutually exclusive.

Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr>
---
 bin/bitbake-setup | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Alexander Kanavin Dec. 2, 2025, 4:10 p.m. UTC | #1
On Tue, 2 Dec 2025 at 17:04, Corentin Guillevic via
lists.openembedded.org
<corentin.guillevic=smile.fr@lists.openembedded.org> wrote:
> +
> +        _handle_uri_shortcut(r_remote)
> +
>          remotes = r_remote['remotes']

Rather than have a function that does mutable 'magic' to r_remote so
that it can be used somewhere else, it's a lot better to:

remotes = get_remotes(r_remote)

and then you can append the shortcut (if present) in that helper function.

Alex
Antonin Godard Dec. 2, 2025, 4:30 p.m. UTC | #2
Hi,

On Tue Dec 2, 2025 at 5:04 PM CET, Corentin Guillevic via lists.openembedded.org wrote:
> Most of the time, when we describe a remote, a bitbake-setup source looks like this:
>
> "bitbake": {
>     "git-remote": {
>         "remotes": {
>             "origin": {
>                 "uri": "https://git.openembedded.org/bitbake"
>             }
>         },
>         ...
>     }
> }
>
> i.e. an URI with the common name 'origin'. Alternatively, we could simplify this, by
> using a shorter structure with the property 'uri' only:
>
> "bitbake": {
>     "git-remote": {
>         "uri": "https://git.openembedded.org/bitbake",
>         ...
>     }
> }
>
> 'uri' and 'remote' are then mutually exclusive.
>

If this is accepted, please also document this new syntax in
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst.

Thanks,
Antonin
Alexander Kanavin Dec. 2, 2025, 4:38 p.m. UTC | #3
On Tue, 2 Dec 2025 at 17:30, Antonin Godard via lists.openembedded.org
<antonin.godard=bootlin.com@lists.openembedded.org> wrote:

> If this is accepted, please also document this new syntax in
> doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst.

I'd say standard configurations in default-registry/ should be updated too.

Alex
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 75be90940..390918d32 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -89,6 +89,14 @@  def _write_layer_list(dest, repodirs):
     with open(layers_f, 'w') as f:
         json.dump({"version":"1.0","layers":layers}, f, sort_keys=True, indent=4)
 
+def _handle_uri_shortcut(r_remote):
+    if 'remotes' in r_remote and 'uri' in r_remote:
+        raise Exception("Keys 'remotes' and 'uri' are mutually exclusive")
+
+    if 'uri' in r_remote:
+        r_remote['remotes'] = {'origin': {'uri': r_remote['uri']}}
+        del r_remote['uri']
+
 def checkout_layers(layers, layerdir, d):
     layers_fixed_revisions = copy.deepcopy(layers)
     repodirs = []
@@ -102,6 +110,9 @@  def checkout_layers(layers, layerdir, d):
         r_remote = r_data['git-remote']
         rev = r_remote['rev']
         branch = r_remote.get('branch', None)
+
+        _handle_uri_shortcut(r_remote)
+
         remotes = r_remote['remotes']
 
         for remote in remotes:
@@ -571,6 +582,9 @@  def are_layers_changed(layers, layerdir, d):
         r_remote = r_data['git-remote']
         rev = r_remote['rev']
         branch = r_remote.get('branch', None)
+
+        _handle_uri_shortcut(r_remote)
+
         remotes = r_remote['remotes']
 
         for remote in remotes: