| Message ID | 20251219161255.2293450-1-corentin.guillevic@smile.fr |
|---|---|
| State | Accepted, archived |
| Commit | 7941a5dc4dba81ab2141531b8af94371a923b32b |
| Headers | show |
| Series | [v4,1/4] bitbake-setup: add inline URI | expand |
On Fri Dec 19, 2025 at 5:12 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", > ... > } > } > > These properties can be used together. > > Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr> > --- > > Changes in v4: > - Fix a wrong indentation in the file bitbake-user-manual-environment-setup.rst > > bin/bitbake-setup | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) > > diff --git a/bin/bitbake-setup b/bin/bitbake-setup > index 73f734e73..809077518 100755 > --- a/bin/bitbake-setup > +++ b/bin/bitbake-setup > @@ -89,14 +89,30 @@ 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: > + for remote in r_remote['remotes']: > + remotes.append(r_remote['remotes'][remote]['uri']) > + > + if 'uri' in r_remote: > + remotes.append(r_remote['uri']) > + > + return remotes > + > def checkout_layers(layers, layerdir, d): > def _checkout_git_remote(r_remote, repodir, layers_fixed_revisions): > rev = r_remote['rev'] > branch = r_remote.get('branch', None) > - remotes = r_remote['remotes'] > + > + remotes = _get_remotes(r_remote) > > for remote in remotes: > - prot,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"]) > + prot,host,path,user,pswd,params = bb.fetch.decodeurl(remote) > fetchuri = bb.fetch.encodeurl(('git',host,path,user,pswd,params)) > logger.plain(" {}".format(r_name)) > if branch: > @@ -600,7 +616,8 @@ def are_layers_changed(layers, layerdir, d): > changed = False > rev = r_remote['rev'] > branch = r_remote.get('branch', None) > - remotes = r_remote['remotes'] > + > + remotes = _get_remotes(r_remote) > > for remote in remotes: > type,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"]) Hi Corentin, Thanks for your patch. It looks like this is breaking a bitbake-selftest: ERROR: test_setup (bb.tests.setup.BitbakeSetupTest.test_setup) ---------------------------------------------------------------------- Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/lib/bb/tests/setup.py", line 318, in test_setup out = self.runbbsetup("status") File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/lib/bb/tests/setup.py", line 90, in runbbsetup return bb.process.run("{} --global-settings {} {}".format(bbsetup, os.path.join(self.tempdir, 'global-config'), cmd)) ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/lib/bb/process.py", line 189, in run raise ExecutionError(cmd, pipe.returncode, stdout, stderr) bb.process.ExecutionError: Execution of '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup --global-settings /tmp/bitbake-fetch-fb2c75qw/global-config status' failed with exit code 1: Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 1059, in <module> main() ~~~~^^ File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 1052, in main args.func(top_dir, all_settings, args, d) ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 675, in build_status if are_layers_changed(current_upstream_config["data"]["sources"], layerdir, d): ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 644, in are_layers_changed changed = changed | _is_git_remote_changed(git_remote, repodir) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/bin/bitbake-setup", line 623, in _is_git_remote_changed type,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"]) ~~~~~~~^^^^^^^^ TypeError: list indices must be integers or slices, not str https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3016 https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2879 https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2774 Can you have a look at this failure? Thanks, Mathieu
diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 73f734e73..809077518 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -89,14 +89,30 @@ 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: + for remote in r_remote['remotes']: + remotes.append(r_remote['remotes'][remote]['uri']) + + if 'uri' in r_remote: + remotes.append(r_remote['uri']) + + return remotes + def checkout_layers(layers, layerdir, d): def _checkout_git_remote(r_remote, repodir, layers_fixed_revisions): rev = r_remote['rev'] branch = r_remote.get('branch', None) - remotes = r_remote['remotes'] + + remotes = _get_remotes(r_remote) for remote in remotes: - prot,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"]) + prot,host,path,user,pswd,params = bb.fetch.decodeurl(remote) fetchuri = bb.fetch.encodeurl(('git',host,path,user,pswd,params)) logger.plain(" {}".format(r_name)) if branch: @@ -600,7 +616,8 @@ def are_layers_changed(layers, layerdir, d): changed = False rev = r_remote['rev'] branch = r_remote.get('branch', None) - remotes = r_remote['remotes'] + + remotes = _get_remotes(r_remote) for remote in remotes: type,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"])
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", ... } } These properties can be used together. Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr> --- Changes in v4: - Fix a wrong indentation in the file bitbake-user-manual-environment-setup.rst bin/bitbake-setup | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)