bitbake-setup: _has_local_modifications fix user case when add/remove/add layer
PATCH v2 1/1 bitbake-setup: _has_local_modifications fix user case when add/remove/add layer
While develop a registry configuration adding a new layer and then back to previous configuration without the _has_local_modifications breaks because the code expects the layer to be in sources-fixed-revisions.json.
This can be reproduced with next steps:
- Call bitbake-setup with configX.
- Remove a LayerY from the configX.
- Call bitbake-setup with configX.
- Add the layerY again to configX.
- Call bitbake-setup with configX (break).
Fixes:
```
File "/workspaces/ls/meta-ls/bitbake/bin/bitbake-setup", line 1137, in <module>
main()
~~~~^^
File "/workspaces/ls/meta-ls/bitbake/bin/bitbake-setup", line 1130, in main
args.func(top_dir, all_settings, args, d)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/ls/meta-ls/bitbake/bin/bitbake-setup", line 735, in build_update
build_status(top_dir, settings, args, d, update=True)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/ls/meta-ls/bitbake/bin/bitbake-setup", line 719, in build_status
update_build(new_upstream_config, confdir, setupdir, layerdir, d,
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
update_bb_conf=args.update_bb_conf)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/ls/meta-ls/bitbake/bin/bitbake-setup", line 408, in update_build
sources_fixed_revisions = checkout_layers(layer_config, confdir, layerdir, d)
File "/workspaces/ls/meta-ls/bitbake/bin/bitbake-setup", line 184, in checkout_layers
elif _has_local_modifications(r_name, repodir_path):
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/ls/meta-ls/bitbake/bin/bitbake-setup", line 143, in _has_local_modifications
rev = fixed_revisions['sources'][r_name]['git-remote']['rev']
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'meta-freescale'
```--- bin/bitbake-setup | 6 ++++++ 1 file changed, 6 insertions(+)
bin/bitbake-setup +6 -0
@@ -140,6 +140,12 @@ def checkout_layers(layers, confdir, layerdir, d): def _has_local_modifications(r_name, r_path): fixed_revisions = json.load(open(os.path.join(confdir, "sources-fixed-revisions.json"))) + + if not r_name in fixed_revisions['sources']: + logger.warning("""Source {} in {} doesn't have an entry in sources-fixed-revisions.json, + Source {} was previously remove from configuration.""".format(r_name, r_path, r_name)) + return True + rev = fixed_revisions['sources'][r_name]['git-remote']['rev'] status = bb.process.run('git -C {} status --porcelain'.format(r_path))[0] if status:
Signature · 1 line
2.51.0
bin/bitbake-setup def checkout_layers(layers, confdir, layerdir, d): · line 147
Quoted 4 lines · Anibal Limon via lists.openembedded.org
bin/bitbake-setup +4
-0+ if not r_name in fixed_revisions['sources']: + logger.warning("""Source {} in {} doesn't have an entry in sources-fixed-revisions.json, + Source {} was previously remove from configuration.""".format(r_name, r_path, r_name)) + return True
I think what this needs to say is "Source {} is added with path {}. This path already exists, but it has no entry in a fixed revisions record. To ensure possible local modifications are not lost, it will be preserved in a backup directory."
Othewise lgtm.
Alex