diff options
Diffstat (limited to 'bitbake/lib/bb/fetch2/gitsm.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/gitsm.py | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py index a4527bf364..f7f3af7212 100644 --- a/bitbake/lib/bb/fetch2/gitsm.py +++ b/bitbake/lib/bb/fetch2/gitsm.py | |||
@@ -88,9 +88,9 @@ class GitSM(Git): | |||
88 | subrevision[m] = module_hash.split()[2] | 88 | subrevision[m] = module_hash.split()[2] |
89 | 89 | ||
90 | # Convert relative to absolute uri based on parent uri | 90 | # Convert relative to absolute uri based on parent uri |
91 | if uris[m].startswith('..'): | 91 | if uris[m].startswith('..') or uris[m].startswith('./'): |
92 | newud = copy.copy(ud) | 92 | newud = copy.copy(ud) |
93 | newud.path = os.path.realpath(os.path.join(newud.path, uris[m])) | 93 | newud.path = os.path.normpath(os.path.join(newud.path, uris[m])) |
94 | uris[m] = Git._get_repo_url(self, newud) | 94 | uris[m] = Git._get_repo_url(self, newud) |
95 | 95 | ||
96 | for module in submodules: | 96 | for module in submodules: |
@@ -115,10 +115,21 @@ class GitSM(Git): | |||
115 | # This has to be a file reference | 115 | # This has to be a file reference |
116 | proto = "file" | 116 | proto = "file" |
117 | url = "gitsm://" + uris[module] | 117 | url = "gitsm://" + uris[module] |
118 | if url.endswith("{}{}".format(ud.host, ud.path)): | ||
119 | raise bb.fetch2.FetchError("Submodule refers to the parent repository. This will cause deadlock situation in current version of Bitbake." \ | ||
120 | "Consider using git fetcher instead.") | ||
118 | 121 | ||
119 | url += ';protocol=%s' % proto | 122 | url += ';protocol=%s' % proto |
120 | url += ";name=%s" % module | 123 | url += ";name=%s" % module |
121 | url += ";subpath=%s" % module | 124 | url += ";subpath=%s" % module |
125 | url += ";nobranch=1" | ||
126 | url += ";lfs=%s" % self._need_lfs(ud) | ||
127 | # Note that adding "user=" here to give credentials to the | ||
128 | # submodule is not supported. Since using SRC_URI to give git:// | ||
129 | # URL a password is not supported, one have to use one of the | ||
130 | # recommended way (eg. ~/.netrc or SSH config) which does specify | ||
131 | # the user (See comment in git.py). | ||
132 | # So, we will not take patches adding "user=" support here. | ||
122 | 133 | ||
123 | ld = d.createCopy() | 134 | ld = d.createCopy() |
124 | # Not necessary to set SRC_URI, since we're passing the URI to | 135 | # Not necessary to set SRC_URI, since we're passing the URI to |
@@ -140,16 +151,6 @@ class GitSM(Git): | |||
140 | if Git.need_update(self, ud, d): | 151 | if Git.need_update(self, ud, d): |
141 | return True | 152 | return True |
142 | 153 | ||
143 | try: | ||
144 | # Check for the nugget dropped by the download operation | ||
145 | known_srcrevs = runfetchcmd("%s config --get-all bitbake.srcrev" % \ | ||
146 | (ud.basecmd), d, workdir=ud.clonedir) | ||
147 | |||
148 | if ud.revisions[ud.names[0]] in known_srcrevs.split(): | ||
149 | return False | ||
150 | except bb.fetch2.FetchError: | ||
151 | pass | ||
152 | |||
153 | need_update_list = [] | 154 | need_update_list = [] |
154 | def need_update_submodule(ud, url, module, modpath, workdir, d): | 155 | def need_update_submodule(ud, url, module, modpath, workdir, d): |
155 | url += ";bareclone=1;nobranch=1" | 156 | url += ";bareclone=1;nobranch=1" |
@@ -172,13 +173,8 @@ class GitSM(Git): | |||
172 | shutil.rmtree(tmpdir) | 173 | shutil.rmtree(tmpdir) |
173 | else: | 174 | else: |
174 | self.process_submodules(ud, ud.clonedir, need_update_submodule, d) | 175 | self.process_submodules(ud, ud.clonedir, need_update_submodule, d) |
175 | if len(need_update_list) == 0: | ||
176 | # We already have the required commits of all submodules. Drop | ||
177 | # a nugget so we don't need to check again. | ||
178 | runfetchcmd("%s config --add bitbake.srcrev %s" % \ | ||
179 | (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=ud.clonedir) | ||
180 | 176 | ||
181 | if len(need_update_list) > 0: | 177 | if need_update_list: |
182 | logger.debug('gitsm: Submodules requiring update: %s' % (' '.join(need_update_list))) | 178 | logger.debug('gitsm: Submodules requiring update: %s' % (' '.join(need_update_list))) |
183 | return True | 179 | return True |
184 | 180 | ||
@@ -209,9 +205,6 @@ class GitSM(Git): | |||
209 | shutil.rmtree(tmpdir) | 205 | shutil.rmtree(tmpdir) |
210 | else: | 206 | else: |
211 | self.process_submodules(ud, ud.clonedir, download_submodule, d) | 207 | self.process_submodules(ud, ud.clonedir, download_submodule, d) |
212 | # Drop a nugget for the srcrev we've fetched (used by need_update) | ||
213 | runfetchcmd("%s config --add bitbake.srcrev %s" % \ | ||
214 | (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=ud.clonedir) | ||
215 | 208 | ||
216 | def unpack(self, ud, destdir, d): | 209 | def unpack(self, ud, destdir, d): |
217 | def unpack_submodules(ud, url, module, modpath, workdir, d): | 210 | def unpack_submodules(ud, url, module, modpath, workdir, d): |
@@ -225,6 +218,10 @@ class GitSM(Git): | |||
225 | 218 | ||
226 | try: | 219 | try: |
227 | newfetch = Fetch([url], d, cache=False) | 220 | newfetch = Fetch([url], d, cache=False) |
221 | # modpath is needed by unpack tracer to calculate submodule | ||
222 | # checkout dir | ||
223 | new_ud = newfetch.ud[url] | ||
224 | new_ud.modpath = modpath | ||
228 | newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', module))) | 225 | newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', module))) |
229 | except Exception as e: | 226 | except Exception as e: |
230 | logger.error('gitsm: submodule unpack failed: %s %s' % (type(e).__name__, str(e))) | 227 | logger.error('gitsm: submodule unpack failed: %s %s' % (type(e).__name__, str(e))) |
@@ -250,10 +247,12 @@ class GitSM(Git): | |||
250 | ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d) | 247 | ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d) |
251 | 248 | ||
252 | if not ud.bareclone and ret: | 249 | if not ud.bareclone and ret: |
253 | # All submodules should already be downloaded and configured in the tree. This simply sets | 250 | # All submodules should already be downloaded and configured in the tree. This simply |
254 | # up the configuration and checks out the files. The main project config should remain | 251 | # sets up the configuration and checks out the files. The main project config should |
255 | # unmodified, and no download from the internet should occur. | 252 | # remain unmodified, and no download from the internet should occur. As such, lfs smudge |
256 | runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) | 253 | # should also be skipped as these files were already smudged in the fetch stage if lfs |
254 | # was enabled. | ||
255 | runfetchcmd("GIT_LFS_SKIP_SMUDGE=1 %s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) | ||
257 | 256 | ||
258 | def implicit_urldata(self, ud, d): | 257 | def implicit_urldata(self, ud, d): |
259 | import shutil, subprocess, tempfile | 258 | import shutil, subprocess, tempfile |