summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2019-10-21 22:09:53 +0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-11-25 21:26:12 +0000
commit2d6a3655e93279179efccc5caaceefdcf3584e2d (patch)
treeb8bf01e2e6a7523d1c973a982eabb44133879835 /bitbake/lib
parent0275e68b0576cdefc19718e4b1977044f9f43f48 (diff)
downloadpoky-2d6a3655e93279179efccc5caaceefdcf3584e2d.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: 24e3c7189e7d41bcbb46078a41c3a9daf391202a) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/fetch2/git.py23
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):