summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2018-10-31 15:21:44 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-07 23:08:55 +0000
commita042179a784bab6a6f4bd5d63db80c1c02624b1c (patch)
tree2bc35303b801f74d2dea5a725fa86a88e00718dd
parenta28637abbceb05b52a6e38ab2340d3da9d0b1b37 (diff)
downloadpoky-a042179a784bab6a6f4bd5d63db80c1c02624b1c.tar.gz
bitbake: fetch2/gitsm.py: Fix the references when the module and path are different
Git does not require the module and target path to be the same in the .gitmodules file. This incorrect assumption was being made previously causing various unpack failures. An example .gitmodule showing this issue: [submodule "plugins/WaveShaper/Libs/inih"] path = plugins/wolf-shaper/Libs/inih url = https://github.com/pdesaulniers/inih.git The unpack function also needed to work in a loop on the overall submodules_queue. Before it could have missed items that were not in the primary repository. (Bitbake rev: 5a7009c204f4d2254e3b2d83ad9319ac23f1cf4d) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py69
1 files changed, 34 insertions, 35 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index dbfa3a4f73..35729dbc0f 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -152,9 +152,9 @@ class GitSM(Git):
152 if submodules and not os.path.exists(os.path.join(repo_conf, 'modules')): 152 if submodules and not os.path.exists(os.path.join(repo_conf, 'modules')):
153 os.mkdir(os.path.join(repo_conf, 'modules')) 153 os.mkdir(os.path.join(repo_conf, 'modules'))
154 154
155 for module in submodules: 155 for module, md in submodules.items():
156 srcpath = os.path.join(ud.clonedir, 'modules', module) 156 srcpath = os.path.join(ud.clonedir, 'modules', md['path'])
157 modpath = os.path.join(repo_conf, 'modules', module) 157 modpath = os.path.join(repo_conf, 'modules', md['path'])
158 158
159 if os.path.exists(srcpath): 159 if os.path.exists(srcpath):
160 if os.path.exists(os.path.join(srcpath, '.git')): 160 if os.path.exists(os.path.join(srcpath, '.git')):
@@ -187,9 +187,8 @@ class GitSM(Git):
187 # No submodules to update 187 # No submodules to update
188 continue 188 continue
189 189
190 submodules = list(self.parse_gitmodules(gitmodules).keys()) 190 submodules = self.parse_gitmodules(gitmodules)
191 191 self.copy_submodules(submodules, ud, dest, d)
192 self.copy_submodules(submodules, ud, dest, d)
193 192
194 def unpack(self, ud, destdir, d): 193 def unpack(self, ud, destdir, d):
195 Git.unpack(self, ud, destdir, d) 194 Git.unpack(self, ud, destdir, d)
@@ -200,7 +199,7 @@ class GitSM(Git):
200 else: 199 else:
201 repo_conf = os.path.join(ud.destdir, '.git') 200 repo_conf = os.path.join(ud.destdir, '.git')
202 201
203 submodules = [] 202 update_submodules = False
204 paths = {} 203 paths = {}
205 uris = {} 204 uris = {}
206 local_paths = {} 205 local_paths = {}
@@ -211,41 +210,41 @@ class GitSM(Git):
211 # No submodules to update 210 # No submodules to update
212 continue 211 continue
213 212
214 for m, md in self.parse_gitmodules(gitmodules).items(): 213 submodules = self.parse_gitmodules(gitmodules)
215 submodules.append(m) 214 self.copy_submodules(submodules, ud, ud.destdir, d)
216 paths[m] = md['path'] 215
217 uris[m] = md['url'] 216 submodules_queue = [(module, os.path.join(repo_conf, 'modules', md['path'])) for module, md in submodules.items()]
217 while len(submodules_queue) != 0:
218 module, modpath = submodules_queue.pop()
218 219
219 self.copy_submodules(submodules, ud, ud.destdir, d) 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', md['path'])])
225 except:
226 # no children
227 pass
220 228
221 submodules_queue = [(module, os.path.join(repo_conf, 'modules', module)) for module in submodules]
222 while len(submodules_queue) != 0:
223 module, modpath = submodules_queue.pop()
224 229
225 # add submodule children recursively 230 # There are submodules to update
226 try: 231 update_submodules = True
227 gitmodules = runfetchcmd("%s show HEAD:.gitmodules" % (ud.basecmd), d, quiet=True, workdir=modpath)
228 for m, md in self.parse_gitmodules(gitmodules).items():
229 submodules_queue.append([m, os.path.join(modpath, 'modules', m)])
230 except:
231 # no children
232 pass
233 232
234 # Determine (from the submodule) the correct url to reference 233 # Determine (from the submodule) the correct url to reference
235 try: 234 try:
236 output = runfetchcmd("%(basecmd)s config remote.origin.url" % {'basecmd': ud.basecmd}, d, workdir=modpath) 235 output = runfetchcmd("%(basecmd)s config remote.origin.url" % {'basecmd': ud.basecmd}, d, workdir=modpath)
237 except bb.fetch2.FetchError as e: 236 except bb.fetch2.FetchError as e:
238 # No remote url defined in this submodule 237 # No remote url defined in this submodule
239 continue 238 continue
240 239
241 local_paths[module] = output 240 local_paths[module] = output
242 241
243 # Setup the local URL properly (like git submodule init or sync would do...) 242 # Setup the local URL properly (like git submodule init or sync would do...)
244 runfetchcmd("%(basecmd)s config submodule.%(module)s.url %(url)s" % {'basecmd': ud.basecmd, 'module': module, 'url' : local_paths[module]}, d, workdir=ud.destdir) 243 runfetchcmd("%(basecmd)s config submodule.%(module)s.url %(url)s" % {'basecmd': ud.basecmd, 'module': module, 'url' : local_paths[module]}, d, workdir=ud.destdir)
245 244
246 # Ensure the submodule repository is NOT set to bare, since we're checking it out... 245 # Ensure the submodule repository is NOT set to bare, since we're checking it out...
247 runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=modpath) 246 runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=modpath)
248 247
249 if submodules: 248 if update_submodules:
250 # Run submodule update, this sets up the directories -- without touching the config 249 # Run submodule update, this sets up the directories -- without touching the config
251 runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) 250 runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir)