diff mbox series

[RFC,04/10] bblayers/makesetup: move check for existence of git remotes to oe-setup-layers plugin

Message ID 20240223120134.3713127-4-alex@linutronix.de
State New
Headers show
Series [RFC,01/10] scripts/oe-setup-build: write a build environment initialization one-liner into the build directory | expand

Commit Message

Alexander Kanavin Feb. 23, 2024, 12:01 p.m. UTC
This helps when making a local copy of all the layers: it's fine to
not have any remotes configured in that case.

Also correct the mistake in accessing 'contains_this_file' property:
it may not necessarily exist, and if so, it should default to False.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/lib/bblayers/makesetup.py                    | 4 ----
 meta/lib/bblayers/setupwriters/oe-setup-layers.py | 3 +++
 2 files changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/bblayers/makesetup.py b/meta/lib/bblayers/makesetup.py
index 814cbb6357c..ebe6bd5440a 100644
--- a/meta/lib/bblayers/makesetup.py
+++ b/meta/lib/bblayers/makesetup.py
@@ -76,10 +76,6 @@  class MakeSetupPlugin(LayerPlugin):
                 repos[repo_path] = {'path':os.path.basename(repo_path),'git-remote':{'rev':l_rev, 'branch':l_branch, 'remotes':self._get_remotes(repo_path), 'describe':self._get_describe(repo_path)}}
                 if repo_path == destdir_repo:
                     repos[repo_path]['contains_this_file'] = True
-                if not repos[repo_path]['git-remote']['remotes'] and not repos[repo_path]['contains_this_file']:
-                    e = "Layer repository in {path} does not have any remotes configured. Please add at least one with 'git remote add'.".format(path=repo_path)
-                    logger.error(e)
-                    raise Exception(e)
 
         top_path = os.path.commonpath([os.path.dirname(r) for r in repos.keys()])
 
diff --git a/meta/lib/bblayers/setupwriters/oe-setup-layers.py b/meta/lib/bblayers/setupwriters/oe-setup-layers.py
index 56c929471e6..8faeabfabc8 100644
--- a/meta/lib/bblayers/setupwriters/oe-setup-layers.py
+++ b/meta/lib/bblayers/setupwriters/oe-setup-layers.py
@@ -86,6 +86,9 @@  class OeSetupLayersWriter():
                 os.makedirs(args.destdir)
             repos = parent.make_repo_config(args.destdir)
             for r in repos.values():
+                if not r['git-remote']['remotes'] and not r.get('contains_this_file', False):
+                    e = "Layer repository in {path} does not have any remotes configured. Please add at least one with 'git remote add'.".format(path=r['originpath'])
+                    raise Exception(e)
                 del r['originpath']
             json = {"version":"1.0","sources":repos}
             if not repos: