diff options
| -rw-r--r-- | bitbake/lib/bb/fetch2/gitsm.py | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py index f7f3af7212..17aac6357c 100644 --- a/bitbake/lib/bb/fetch2/gitsm.py +++ b/bitbake/lib/bb/fetch2/gitsm.py | |||
| @@ -147,6 +147,17 @@ class GitSM(Git): | |||
| 147 | 147 | ||
| 148 | return submodules != [] | 148 | return submodules != [] |
| 149 | 149 | ||
| 150 | def call_process_submodules(self, ud, d, extra_check, subfunc): | ||
| 151 | # If we're using a shallow mirror tarball it needs to be | ||
| 152 | # unpacked temporarily so that we can examine the .gitmodules file | ||
| 153 | if ud.shallow and os.path.exists(ud.fullshallow) and extra_check: | ||
| 154 | tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR")) | ||
| 155 | runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir) | ||
| 156 | self.process_submodules(ud, tmpdir, subfunc, d) | ||
| 157 | shutil.rmtree(tmpdir) | ||
| 158 | else: | ||
| 159 | self.process_submodules(ud, ud.clonedir, subfunc, d) | ||
| 160 | |||
| 150 | def need_update(self, ud, d): | 161 | def need_update(self, ud, d): |
| 151 | if Git.need_update(self, ud, d): | 162 | if Git.need_update(self, ud, d): |
| 152 | return True | 163 | return True |
| @@ -164,15 +175,7 @@ class GitSM(Git): | |||
| 164 | logger.error('gitsm: submodule update check failed: %s %s' % (type(e).__name__, str(e))) | 175 | logger.error('gitsm: submodule update check failed: %s %s' % (type(e).__name__, str(e))) |
| 165 | need_update_result = True | 176 | need_update_result = True |
| 166 | 177 | ||
| 167 | # If we're using a shallow mirror tarball it needs to be unpacked | 178 | self.call_process_submodules(ud, d, not os.path.exists(ud.clonedir), need_update_submodule) |
| 168 | # temporarily so that we can examine the .gitmodules file | ||
| 169 | if ud.shallow and os.path.exists(ud.fullshallow) and not os.path.exists(ud.clonedir): | ||
| 170 | tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR")) | ||
| 171 | runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir) | ||
| 172 | self.process_submodules(ud, tmpdir, need_update_submodule, d) | ||
| 173 | shutil.rmtree(tmpdir) | ||
| 174 | else: | ||
| 175 | self.process_submodules(ud, ud.clonedir, need_update_submodule, d) | ||
| 176 | 179 | ||
| 177 | if need_update_list: | 180 | if need_update_list: |
| 178 | logger.debug('gitsm: Submodules requiring update: %s' % (' '.join(need_update_list))) | 181 | logger.debug('gitsm: Submodules requiring update: %s' % (' '.join(need_update_list))) |
| @@ -195,16 +198,7 @@ class GitSM(Git): | |||
| 195 | raise | 198 | raise |
| 196 | 199 | ||
| 197 | Git.download(self, ud, d) | 200 | Git.download(self, ud, d) |
| 198 | 201 | self.call_process_submodules(ud, d, self.need_update(ud, d), download_submodule) | |
| 199 | # If we're using a shallow mirror tarball it needs to be unpacked | ||
| 200 | # temporarily so that we can examine the .gitmodules file | ||
| 201 | if ud.shallow and os.path.exists(ud.fullshallow) and self.need_update(ud, d): | ||
| 202 | tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR")) | ||
| 203 | runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir) | ||
| 204 | self.process_submodules(ud, tmpdir, download_submodule, d) | ||
| 205 | shutil.rmtree(tmpdir) | ||
| 206 | else: | ||
| 207 | self.process_submodules(ud, ud.clonedir, download_submodule, d) | ||
| 208 | 202 | ||
| 209 | def unpack(self, ud, destdir, d): | 203 | def unpack(self, ud, destdir, d): |
| 210 | def unpack_submodules(ud, url, module, modpath, workdir, d): | 204 | def unpack_submodules(ud, url, module, modpath, workdir, d): |
| @@ -263,14 +257,6 @@ class GitSM(Git): | |||
| 263 | newfetch = Fetch([url], d, cache=False) | 257 | newfetch = Fetch([url], d, cache=False) |
| 264 | urldata.extend(newfetch.expanded_urldata()) | 258 | urldata.extend(newfetch.expanded_urldata()) |
| 265 | 259 | ||
| 266 | # If we're using a shallow mirror tarball it needs to be unpacked | 260 | self.call_process_submodules(ud, d, ud.method.need_update(ud, d), add_submodule) |
| 267 | # temporarily so that we can examine the .gitmodules file | ||
| 268 | if ud.shallow and os.path.exists(ud.fullshallow) and ud.method.need_update(ud, d): | ||
| 269 | tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR")) | ||
| 270 | subprocess.check_call("tar -xzf %s" % ud.fullshallow, cwd=tmpdir, shell=True) | ||
| 271 | self.process_submodules(ud, tmpdir, add_submodule, d) | ||
| 272 | shutil.rmtree(tmpdir) | ||
| 273 | else: | ||
| 274 | self.process_submodules(ud, ud.clonedir, add_submodule, d) | ||
| 275 | 261 | ||
| 276 | return urldata | 262 | return urldata |
