diff mbox series

[v5,1/2] oe-setup-layers: support inline URI

Message ID 20260123172613.3305069-1-corentin.guillevic@smile.fr
State Under Review
Headers show
Series [v5,1/2] oe-setup-layers: support inline URI | expand

Commit Message

Corentin Guillevic Jan. 23, 2026, 5:26 p.m. UTC
Most of the time, when we describe a remote, the layer data (also used by
the script bitbake-setup) 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

",
        ...
    }
}

These properties can be used together.

Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr>
---

Notes:
    Changes in v5:
    - Rebase, no change since v4

 scripts/oe-setup-layers | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

Comments

Mathieu Dubois-Briand Jan. 27, 2026, 1:59 p.m. UTC | #1
On Fri Jan 23, 2026 at 6:26 PM CET, Corentin Guillevic via lists.openembedded.org wrote:
> Most of the time, when we describe a remote, the layer data (also used by
> the script bitbake-setup) 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
>
> ",
>         ...
>     }
> }
>
> These properties can be used together.
>
> Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr>
> ---

Hi Corentin,

Thanks for the new version.

It's been some time, so I have a doubt now: does this path have any
dependency on another series? So far I have this failing selftest:

2026-01-27 09:30:15,277 - oe-selftest - INFO - bblayers.BitbakeLayers.test_validate_examplelayersjson (subunit.RemotedTestCase)
2026-01-27 09:30:15,282 - oe-selftest - INFO -  ... FAIL
...
2026-01-27 09:30:15,282 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/bblayers.py", line 163, in test_validate_examplelayersjson
    self.validate_layersjson(json)
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/bblayers.py", line 159, in validate_layersjson
    self.validate_json(json, "layers.schema.json")
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/bblayers.py", line 152, in validate_json
    result = runCmd(
  File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/utils/commands.py", line 214, in runCmd
    raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
AssertionError: Command '/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-845522/tmp/work/x86_64-linux/python3-jsonschema-native/4.26.0/recipe-sysroot-native/usr/bin/nativepython3 /srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-845522/tmp/work/x86_64-linux/python3-jsonschema-native/4.26.0/recipe-sysroot-native/usr/bin/jsonschema -i /srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/files/layers.example.json --base-uri file:///srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/bitbake/bin/../setup-schema/ /srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/bitbake/bin/../setup-schema/layers.schema.json' returned non-zero exit status 1:
/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-845522/tmp/work/x86_64-linux/python3-jsonschema-native/4.26.0/recipe-sysroot-native/usr/bin/jsonschema:5: DeprecationWarning: The jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead, which can be installed from https://pypi.org/project/check-jsonschema/
  from jsonschema.cli import main
{'branch': 'master', 'describe': '', 'uri': 'https://github.com/kanavin/meta-alex', 'rev': '05b25605fb8b2399e4706d7323828676bf0da0b5'}: Additional properties are not allowed ('uri' was unexpected)
{'branch': 'master', 'describe': '15.0-hardknott-3.3-310-g0a96edae', 'uri': 'git://git.yoctoproject.org/meta-intel', 'rev': '0a96edae609a3f48befac36af82cf1eed6786b4a'}: Additional properties are not allowed ('uri' was unexpected)

https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/3102
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2998

Can you have a look at the issue?

Thanks,
Mathieu
Alexander Kanavin Jan. 27, 2026, 5:49 p.m. UTC | #2
On Tue, 27 Jan 2026 at 14:59, Mathieu Dubois-Briand via
lists.openembedded.org
<mathieu.dubois-briand=bootlin.com@lists.openembedded.org> wrote:
>   from jsonschema.cli import main
> {'branch': 'master', 'describe': '', 'uri': 'https://github.com/kanavin/meta-alex', 'rev': '05b25605fb8b2399e4706d7323828676bf0da0b5'}: Additional properties are not allowed ('uri' was unexpected)
> {'branch': 'master', 'describe': '15.0-hardknott-3.3-310-g0a96edae', 'uri': 'git://git.yoctoproject.org/meta-intel', 'rev': '0a96edae609a3f48befac36af82cf1eed6786b4a'}: Additional properties are not allowed ('uri' was unexpected)
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/3102
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2998

The schema needs to be updated with the corresponding bitbake
patchset, so these two patchsets must be tested in lockstep.

Alex
Mathieu Dubois-Briand Jan. 27, 2026, 6:50 p.m. UTC | #3
On Tue Jan 27, 2026 at 6:49 PM CET, Alexander Kanavin wrote:
> On Tue, 27 Jan 2026 at 14:59, Mathieu Dubois-Briand via
> lists.openembedded.org
> <mathieu.dubois-briand=bootlin.com@lists.openembedded.org> wrote:
>>   from jsonschema.cli import main
>> {'branch': 'master', 'describe': '', 'uri': 'https://github.com/kanavin/meta-alex', 'rev': '05b25605fb8b2399e4706d7323828676bf0da0b5'}: Additional properties are not allowed ('uri' was unexpected)
>> {'branch': 'master', 'describe': '15.0-hardknott-3.3-310-g0a96edae', 'uri': 'git://git.yoctoproject.org/meta-intel', 'rev': '0a96edae609a3f48befac36af82cf1eed6786b4a'}: Additional properties are not allowed ('uri' was unexpected)
>>
>> https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/3102
>> https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2998
>
> The schema needs to be updated with the corresponding bitbake
> patchset, so these two patchsets must be tested in lockstep.
>
> Alex

Yes, of course now I do remember this series. Thanks!

So the bitbake one got come comments, but I believe I will still take it
into my branch in order to test this series.

Thanks,
Mathieu
diff mbox series

Patch

diff --git a/scripts/oe-setup-layers b/scripts/oe-setup-layers
index 31cb963251..4813d6f9dc 100755
--- a/scripts/oe-setup-layers
+++ b/scripts/oe-setup-layers
@@ -60,6 +60,34 @@  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 _get_remotes(r_remote):
+    remotes = {}
+
+    if not 'remotes' in r_remote and not 'uri' in r_remote:
+        raise Exception("Expected key(s): 'remotes', 'uri'")
+
+    if 'remotes' in r_remote:
+        remotes = r_remote['remotes'].copy()
+
+    if 'uri' in r_remote:
+        r_name = ''
+
+        if 'remotes' in r_remote:
+            if not 'origin' in r_remote['remotes']:
+                r_name = 'origin'
+            else:
+                import itertools
+                for i in itertools.count(start=1):
+                    if not 'origin-{}'.format(i) in r_remote['remotes']:
+                        r_name = 'origin-{}'.format(i)
+                        break
+        else:
+            r_name = 'origin'
+
+        remotes.update({r_name: {'uri': r_remote['uri']}})
+
+    return remotes
+
 def _do_checkout(args, json):
     repos = json['sources']
     repodirs = []
@@ -80,7 +108,8 @@  def _do_checkout(args, json):
         if not desc:
             desc = rev[:10]
         branch = r_remote['branch']
-        remotes = r_remote['remotes']
+
+        remotes = _get_remotes(r_remote)
 
         print('\nSetting up source {}, revision {}, branch {}'.format(r_name, desc, branch))
         if not _is_repo_git_repo(repodir):