diff options
Diffstat (limited to 'meta/lib/bblayers/makesetup.py')
-rw-r--r-- | meta/lib/bblayers/makesetup.py | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/meta/lib/bblayers/makesetup.py b/meta/lib/bblayers/makesetup.py index 4f27c565ee..4199b5f069 100644 --- a/meta/lib/bblayers/makesetup.py +++ b/meta/lib/bblayers/makesetup.py | |||
@@ -9,7 +9,6 @@ import os | |||
9 | import sys | 9 | import sys |
10 | 10 | ||
11 | import bb.utils | 11 | import bb.utils |
12 | import bb.process | ||
13 | 12 | ||
14 | from bblayers.common import LayerPlugin | 13 | from bblayers.common import LayerPlugin |
15 | 14 | ||
@@ -24,25 +23,12 @@ def plugin_init(plugins): | |||
24 | 23 | ||
25 | class MakeSetupPlugin(LayerPlugin): | 24 | class MakeSetupPlugin(LayerPlugin): |
26 | 25 | ||
27 | def _get_repo_path(self, layer_path): | 26 | def _get_remotes_with_url(self, repo_path): |
28 | repo_path, _ = bb.process.run('git rev-parse --show-toplevel', cwd=layer_path) | ||
29 | return repo_path.strip() | ||
30 | |||
31 | def _get_remotes(self, repo_path): | ||
32 | remotes = {} | 27 | remotes = {} |
33 | remotes_list,_ = bb.process.run('git remote', cwd=repo_path) | 28 | for r in oe.buildcfg.get_metadata_git_remotes(repo_path): |
34 | for r in remotes_list.split(): | 29 | remotes[r] = {'uri':oe.buildcfg.get_metadata_git_remote_url(repo_path, r)} |
35 | uri,_ = bb.process.run('git remote get-url {r}'.format(r=r), cwd=repo_path) | ||
36 | remotes[r] = {'uri':uri.strip()} | ||
37 | return remotes | 30 | return remotes |
38 | 31 | ||
39 | def _get_describe(self, repo_path): | ||
40 | try: | ||
41 | describe,_ = bb.process.run('git describe --tags', cwd=repo_path) | ||
42 | except bb.process.ExecutionError: | ||
43 | return "" | ||
44 | return describe.strip() | ||
45 | |||
46 | def _is_submodule(self, repo_path): | 32 | def _is_submodule(self, repo_path): |
47 | # This is slightly brittle: git does not offer a way to tell whether | 33 | # This is slightly brittle: git does not offer a way to tell whether |
48 | # a given repo dir is a submodule checkout, so we need to rely on .git | 34 | # a given repo dir is a submodule checkout, so we need to rely on .git |
@@ -56,28 +42,27 @@ class MakeSetupPlugin(LayerPlugin): | |||
56 | available here. """ | 42 | available here. """ |
57 | repos = {} | 43 | repos = {} |
58 | layers = oe.buildcfg.get_layer_revisions(self.tinfoil.config_data) | 44 | layers = oe.buildcfg.get_layer_revisions(self.tinfoil.config_data) |
59 | try: | 45 | destdir_repo = oe.buildcfg.get_metadata_git_toplevel(destdir) |
60 | destdir_repo = self._get_repo_path(destdir) | ||
61 | except bb.process.ExecutionError: | ||
62 | destdir_repo = None | ||
63 | 46 | ||
64 | for (l_path, l_name, l_branch, l_rev, l_ismodified) in layers: | 47 | for (l_path, l_name, l_branch, l_rev, l_ismodified) in layers: |
65 | if l_name == 'workspace': | 48 | if l_name == 'workspace': |
66 | continue | 49 | continue |
67 | if l_ismodified: | 50 | if l_ismodified: |
68 | logger.error("Layer {name} in {path} has uncommitted modifications or is not in a git repository.".format(name=l_name,path=l_path)) | 51 | e = "Layer {name} in {path} has uncommitted modifications or is not in a git repository.".format(name=l_name,path=l_path) |
69 | return | 52 | logger.error(e) |
70 | repo_path = self._get_repo_path(l_path) | 53 | raise Exception(e) |
54 | repo_path = oe.buildcfg.get_metadata_git_toplevel(l_path) | ||
71 | 55 | ||
72 | if self._is_submodule(repo_path): | 56 | if self._is_submodule(repo_path): |
73 | continue | 57 | continue |
74 | if repo_path not in repos.keys(): | 58 | if repo_path not in repos.keys(): |
75 | 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)}} | 59 | repos[repo_path] = {'path':os.path.basename(repo_path),'git-remote':{ |
60 | 'rev':l_rev, | ||
61 | 'branch':l_branch, | ||
62 | 'remotes':self._get_remotes_with_url(repo_path), | ||
63 | 'describe':oe.buildcfg.get_metadata_git_describe(repo_path)}} | ||
76 | if repo_path == destdir_repo: | 64 | if repo_path == destdir_repo: |
77 | repos[repo_path]['contains_this_file'] = True | 65 | repos[repo_path]['contains_this_file'] = True |
78 | if not repos[repo_path]['git-remote']['remotes'] and not repos[repo_path]['contains_this_file']: | ||
79 | logger.error("Layer repository in {path} does not have any remotes configured. Please add at least one with 'git remote add'.".format(path=repo_path)) | ||
80 | return | ||
81 | 66 | ||
82 | top_path = os.path.commonpath([os.path.dirname(r) for r in repos.keys()]) | 67 | top_path = os.path.commonpath([os.path.dirname(r) for r in repos.keys()]) |
83 | 68 | ||
@@ -87,6 +72,7 @@ class MakeSetupPlugin(LayerPlugin): | |||
87 | repos_nopaths[r_nopath] = repos[r] | 72 | repos_nopaths[r_nopath] = repos[r] |
88 | r_relpath = os.path.relpath(r, top_path) | 73 | r_relpath = os.path.relpath(r, top_path) |
89 | repos_nopaths[r_nopath]['path'] = r_relpath | 74 | repos_nopaths[r_nopath]['path'] = r_relpath |
75 | repos_nopaths[r_nopath]['originpath'] = r | ||
90 | return repos_nopaths | 76 | return repos_nopaths |
91 | 77 | ||
92 | def do_make_setup(self, args): | 78 | def do_make_setup(self, args): |