diff options
author | Matt Hoosier <matt.hoosier@garmin.com> | 2021-01-19 14:59:34 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-01-21 23:25:53 +0000 |
commit | d59602c758db9eb2393719c27e25df9f135c1ecc (patch) | |
tree | db3e16d46f3b13edbecabe97178b68e15fe686c1 | |
parent | 2ee7b28c96e79749d314086a1f5ba33d345927c5 (diff) | |
download | poky-d59602c758db9eb2393719c27e25df9f135c1ecc.tar.gz |
bitbake: fetch/git: download LFS content too during do_fetch
Insert an explicit call-out to git-lfs to fetch all blobs needed by
each ref named in SRC_URI, during the fetch() function. This avoids
the default behavior of Git LFS to wait until 'git checkout' to
begin downloading the blobs pointed to by LFS records. Network
access is not allowed at that point in the recipe's lifecycle.
(Bitbake rev: 2a6a9e1653199be02c3b29c68d5b6b2cae33cb7b)
Signed-off-by: Matt Hoosier <matt.hoosier@garmin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index df9538a60d..c514c36812 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -384,6 +384,10 @@ class Git(FetchMethod): | |||
384 | if missing_rev: | 384 | if missing_rev: |
385 | raise bb.fetch2.FetchError("Unable to find revision %s even from upstream" % missing_rev) | 385 | raise bb.fetch2.FetchError("Unable to find revision %s even from upstream" % missing_rev) |
386 | 386 | ||
387 | if self._contains_lfs(ud, d, ud.clonedir) and self._need_lfs(ud): | ||
388 | for name in ud.names: | ||
389 | runfetchcmd("git-lfs fetch origin %s" % ud.revisions[name], d, workdir=ud.clonedir) | ||
390 | |||
387 | def build_mirror_data(self, ud, d): | 391 | def build_mirror_data(self, ud, d): |
388 | if ud.shallow and ud.write_shallow_tarballs: | 392 | if ud.shallow and ud.write_shallow_tarballs: |
389 | if not os.path.exists(ud.fullshallow): | 393 | if not os.path.exists(ud.fullshallow): |
@@ -479,7 +483,7 @@ class Git(FetchMethod): | |||
479 | if os.path.exists(destdir): | 483 | if os.path.exists(destdir): |
480 | bb.utils.prunedir(destdir) | 484 | bb.utils.prunedir(destdir) |
481 | 485 | ||
482 | need_lfs = ud.parm.get("lfs", "1") == "1" | 486 | need_lfs = self._need_lfs(ud) |
483 | 487 | ||
484 | if not need_lfs: | 488 | if not need_lfs: |
485 | ud.basecmd = "GIT_LFS_SKIP_SMUDGE=1 " + ud.basecmd | 489 | ud.basecmd = "GIT_LFS_SKIP_SMUDGE=1 " + ud.basecmd |
@@ -568,6 +572,9 @@ class Git(FetchMethod): | |||
568 | raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output)) | 572 | raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output)) |
569 | return output.split()[0] != "0" | 573 | return output.split()[0] != "0" |
570 | 574 | ||
575 | def _need_lfs(self, ud): | ||
576 | return ud.parm.get("lfs", "1") == "1" | ||
577 | |||
571 | def _contains_lfs(self, ud, d, wd): | 578 | def _contains_lfs(self, ud, d, wd): |
572 | """ | 579 | """ |
573 | Check if the repository has 'lfs' (large file) content | 580 | Check if the repository has 'lfs' (large file) content |
@@ -578,8 +585,14 @@ class Git(FetchMethod): | |||
578 | else: | 585 | else: |
579 | branchname = "master" | 586 | branchname = "master" |
580 | 587 | ||
581 | cmd = "%s grep lfs origin/%s:.gitattributes | wc -l" % ( | 588 | # The bare clonedir doesn't use the remote names; it has the branch immediately. |
582 | ud.basecmd, ud.branches[ud.names[0]]) | 589 | if wd == ud.clonedir: |
590 | refname = ud.branches[ud.names[0]] | ||
591 | else: | ||
592 | refname = "origin/%s" % ud.branches[ud.names[0]] | ||
593 | |||
594 | cmd = "%s grep lfs %s:.gitattributes | wc -l" % ( | ||
595 | ud.basecmd, refname) | ||
583 | 596 | ||
584 | try: | 597 | try: |
585 | output = runfetchcmd(cmd, d, quiet=True, workdir=wd) | 598 | output = runfetchcmd(cmd, d, quiet=True, workdir=wd) |