diff options
author | Christopher Larson <chris_larson@mentor.com> | 2019-10-21 22:09:53 +0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-10-28 05:31:53 +0000 |
commit | d52cb2f01aba670c9fc8c5087484246126de5649 (patch) | |
tree | adbddef4d604ab156649b0d9539baf0744a4fff2 /bitbake/lib | |
parent | 5107dce38e6b4e8b30b125113abdcb1c19ec9664 (diff) | |
download | poky-d52cb2f01aba670c9fc8c5087484246126de5649.tar.gz |
bitbake: fetch2/git: fetch shallow revs when needed
When bitbake determines if a git clone needs updating, it only checks for the
needed srcrevs, not the revs listed in BB_GIT_SHALLOW_REVS, which will fail if
using shallow and the needed rev was added to the upstream git repo after a
previous fetch. Ensure that we also check for shallow revs.
[YOCTO #13586]
(Bitbake rev: 93b65e3c6ca64f644946953980595c44fbbcc748)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 2d1d2cabd5..fa41b078f1 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -292,11 +292,21 @@ class Git(FetchMethod): | |||
292 | def clonedir_need_update(self, ud, d): | 292 | def clonedir_need_update(self, ud, d): |
293 | if not os.path.exists(ud.clonedir): | 293 | if not os.path.exists(ud.clonedir): |
294 | return True | 294 | return True |
295 | if ud.shallow and ud.write_shallow_tarballs and self.clonedir_need_shallow_revs(ud, d): | ||
296 | return True | ||
295 | for name in ud.names: | 297 | for name in ud.names: |
296 | if not self._contains_ref(ud, d, name, ud.clonedir): | 298 | if not self._contains_ref(ud, d, name, ud.clonedir): |
297 | return True | 299 | return True |
298 | return False | 300 | return False |
299 | 301 | ||
302 | def clonedir_need_shallow_revs(self, ud, d): | ||
303 | for rev in ud.shallow_revs: | ||
304 | try: | ||
305 | runfetchcmd('%s rev-parse -q --verify %s' % (ud.basecmd, rev), d, quiet=True, workdir=ud.clonedir) | ||
306 | except bb.fetch2.FetchError: | ||
307 | return rev | ||
308 | return None | ||
309 | |||
300 | def shallow_tarball_need_update(self, ud): | 310 | def shallow_tarball_need_update(self, ud): |
301 | return ud.shallow and ud.write_shallow_tarballs and not os.path.exists(ud.fullshallow) | 311 | return ud.shallow and ud.write_shallow_tarballs and not os.path.exists(ud.fullshallow) |
302 | 312 | ||
@@ -339,13 +349,7 @@ class Git(FetchMethod): | |||
339 | runfetchcmd(clone_cmd, d, log=progresshandler) | 349 | runfetchcmd(clone_cmd, d, log=progresshandler) |
340 | 350 | ||
341 | # Update the checkout if needed | 351 | # Update the checkout if needed |
342 | needupdate = False | 352 | if self.clonedir_need_update(ud, d): |
343 | for name in ud.names: | ||
344 | if not self._contains_ref(ud, d, name, ud.clonedir): | ||
345 | needupdate = True | ||
346 | break | ||
347 | |||
348 | if needupdate: | ||
349 | output = runfetchcmd("%s remote" % ud.basecmd, d, quiet=True, workdir=ud.clonedir) | 353 | output = runfetchcmd("%s remote" % ud.basecmd, d, quiet=True, workdir=ud.clonedir) |
350 | if "origin" in output: | 354 | if "origin" in output: |
351 | runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir) | 355 | runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir) |
@@ -369,6 +373,11 @@ class Git(FetchMethod): | |||
369 | if not self._contains_ref(ud, d, name, ud.clonedir): | 373 | if not self._contains_ref(ud, d, name, ud.clonedir): |
370 | raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name])) | 374 | raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name])) |
371 | 375 | ||
376 | if ud.shallow and ud.write_shallow_tarballs: | ||
377 | missing_rev = self.clonedir_need_shallow_revs(ud, d) | ||
378 | if missing_rev: | ||
379 | raise bb.fetch2.FetchError("Unable to find revision %s even from upstream" % missing_rev) | ||
380 | |||
372 | def build_mirror_data(self, ud, d): | 381 | def build_mirror_data(self, ud, d): |
373 | if ud.shallow and ud.write_shallow_tarballs: | 382 | if ud.shallow and ud.write_shallow_tarballs: |
374 | if not os.path.exists(ud.fullshallow): | 383 | if not os.path.exists(ud.fullshallow): |