diff options
author | Laurent Bonnans <laurent.bonnans@here.com> | 2018-10-01 16:52:14 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-10-04 23:00:24 +0100 |
commit | 41e6a3efac837c2ae812accf3371f7aad9ac21e4 (patch) | |
tree | d9bb00e3738e3965462ed490cbafec07b7bafa0e /bitbake/lib/bb/fetch2 | |
parent | c888446d1229b21bdf428332e8515bd92449b538 (diff) | |
download | poky-41e6a3efac837c2ae812accf3371f7aad9ac21e4.tar.gz |
bitbake: fetch2/gitsm: checkout submodules recursively
The new fetcher did not run 'git submodule update' recursively.
(Bitbake rev: 377ed943357b6d47d41d84edbf971741f44affa9)
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r-- | bitbake/lib/bb/fetch2/gitsm.py | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py index fd5089c075..4d3805a11c 100644 --- a/bitbake/lib/bb/fetch2/gitsm.py +++ b/bitbake/lib/bb/fetch2/gitsm.py | |||
@@ -44,6 +44,22 @@ class GitSM(Git): | |||
44 | """ | 44 | """ |
45 | return ud.type in ['gitsm'] | 45 | return ud.type in ['gitsm'] |
46 | 46 | ||
47 | @staticmethod | ||
48 | def parse_gitmodules(gitmodules): | ||
49 | modules = {} | ||
50 | module = "" | ||
51 | for line in gitmodules.splitlines(): | ||
52 | if line.startswith('[submodule'): | ||
53 | module = line.split('"')[1] | ||
54 | modules[module] = {} | ||
55 | elif module and line.strip().startswith('path'): | ||
56 | path = line.split('=')[1].strip() | ||
57 | modules[module]['path'] = path | ||
58 | elif module and line.strip().startswith('url'): | ||
59 | url = line.split('=')[1].strip() | ||
60 | modules[module]['url'] = url | ||
61 | return modules | ||
62 | |||
47 | def update_submodules(self, ud, d): | 63 | def update_submodules(self, ud, d): |
48 | submodules = [] | 64 | submodules = [] |
49 | paths = {} | 65 | paths = {} |
@@ -57,17 +73,10 @@ class GitSM(Git): | |||
57 | # No submodules to update | 73 | # No submodules to update |
58 | continue | 74 | continue |
59 | 75 | ||
60 | module = "" | 76 | for m, md in self.parse_gitmodules(gitmodules).items(): |
61 | for line in gitmodules.splitlines(): | 77 | submodules.append(m) |
62 | if line.startswith('[submodule'): | 78 | paths[m] = md['path'] |
63 | module = line.split('"')[1] | 79 | uris[m] = md['url'] |
64 | submodules.append(module) | ||
65 | elif module and line.strip().startswith('path'): | ||
66 | path = line.split('=')[1].strip() | ||
67 | paths[module] = path | ||
68 | elif module and line.strip().startswith('url'): | ||
69 | url = line.split('=')[1].strip() | ||
70 | uris[module] = url | ||
71 | 80 | ||
72 | for module in submodules: | 81 | for module in submodules: |
73 | module_hash = runfetchcmd("%s ls-tree -z -d %s %s" % (ud.basecmd, ud.revisions[name], paths[module]), d, quiet=True, workdir=ud.clonedir) | 82 | module_hash = runfetchcmd("%s ls-tree -z -d %s %s" % (ud.basecmd, ud.revisions[name], paths[module]), d, quiet=True, workdir=ud.clonedir) |
@@ -173,10 +182,7 @@ class GitSM(Git): | |||
173 | # No submodules to update | 182 | # No submodules to update |
174 | continue | 183 | continue |
175 | 184 | ||
176 | for line in gitmodules.splitlines(): | 185 | submodules = list(self.parse_gitmodules(gitmodules).keys()) |
177 | if line.startswith('[submodule'): | ||
178 | module = line.split('"')[1] | ||
179 | submodules.append(module) | ||
180 | 186 | ||
181 | self.copy_submodules(submodules, ud, dest, d) | 187 | self.copy_submodules(submodules, ud, dest, d) |
182 | 188 | ||
@@ -200,23 +206,25 @@ class GitSM(Git): | |||
200 | # No submodules to update | 206 | # No submodules to update |
201 | continue | 207 | continue |
202 | 208 | ||
203 | module = "" | 209 | for m, md in self.parse_gitmodules(gitmodules).items(): |
204 | for line in gitmodules.splitlines(): | 210 | submodules.append(m) |
205 | if line.startswith('[submodule'): | 211 | paths[m] = md['path'] |
206 | module = line.split('"')[1] | 212 | uris[m] = md['url'] |
207 | submodules.append(module) | ||
208 | elif module and line.strip().startswith('path'): | ||
209 | path = line.split('=')[1].strip() | ||
210 | paths[module] = path | ||
211 | elif module and line.strip().startswith('url'): | ||
212 | url = line.split('=')[1].strip() | ||
213 | uris[module] = url | ||
214 | 213 | ||
215 | self.copy_submodules(submodules, ud, ud.destdir, d) | 214 | self.copy_submodules(submodules, ud, ud.destdir, d) |
216 | 215 | ||
217 | for module in submodules: | 216 | submodules_queue = [(module, os.path.join(repo_conf, 'modules', module)) for module in submodules] |
218 | srcpath = os.path.join(ud.clonedir, 'modules', module) | 217 | while len(submodules_queue) != 0: |
219 | modpath = os.path.join(repo_conf, 'modules', module) | 218 | module, modpath = submodules_queue.pop() |
219 | |||
220 | # add submodule children recursively | ||
221 | try: | ||
222 | gitmodules = runfetchcmd("%s show HEAD:.gitmodules" % (ud.basecmd), d, quiet=True, workdir=modpath) | ||
223 | for m, md in self.parse_gitmodules(gitmodules).items(): | ||
224 | submodules_queue.append([m, os.path.join(modpath, 'modules', m)]) | ||
225 | except: | ||
226 | # no children | ||
227 | pass | ||
220 | 228 | ||
221 | # Determine (from the submodule) the correct url to reference | 229 | # Determine (from the submodule) the correct url to reference |
222 | try: | 230 | try: |
@@ -235,4 +243,4 @@ class GitSM(Git): | |||
235 | 243 | ||
236 | if submodules: | 244 | if submodules: |
237 | # Run submodule update, this sets up the directories -- without touching the config | 245 | # Run submodule update, this sets up the directories -- without touching the config |
238 | runfetchcmd("%s submodule update --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) | 246 | runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) |