summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorMatt Hoosier <matt.hoosier@garmin.com>2021-02-03 04:22:09 -1000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-02-05 12:18:38 +0000
commit977b7268bf4fd425cb86d4a57500350c9b829162 (patch)
treee1430bb0ce01b6f4a0b1d577e8b579b4135b47d5 /bitbake/lib/bb/tests
parent1f4ca119bef0e06b8ed18f6c7878a3704014ec71 (diff)
downloadpoky-977b7268bf4fd425cb86d4a57500350c9b829162.tar.gz
bitbake: fetch/git: download LFS content too during do_fetch
Insert an explicit pass to fetch all blobs needed by Git LFS, 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. [YOCTO #14191] (Bitbake rev: 2351b496bb63b96920d4ae67bec816f00d510df2) Signed-off-by: Matt Hoosier <matt.hoosier@garmin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 0efac66043662e7a2027192f50e92e982db2ba1c) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/fetch.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 4702c99a7e..9453c90d2b 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2046,13 +2046,14 @@ class GitLfsTest(FetcherTest):
2046 cwd = self.gitdir 2046 cwd = self.gitdir
2047 return bb.process.run(cmd, cwd=cwd)[0] 2047 return bb.process.run(cmd, cwd=cwd)[0]
2048 2048
2049 def fetch(self, uri=None): 2049 def fetch(self, uri=None, download=True):
2050 uris = self.d.getVar('SRC_URI').split() 2050 uris = self.d.getVar('SRC_URI').split()
2051 uri = uris[0] 2051 uri = uris[0]
2052 d = self.d 2052 d = self.d
2053 2053
2054 fetcher = bb.fetch2.Fetch(uris, d) 2054 fetcher = bb.fetch2.Fetch(uris, d)
2055 fetcher.download() 2055 if download:
2056 fetcher.download()
2056 ud = fetcher.ud[uri] 2057 ud = fetcher.ud[uri]
2057 return fetcher, ud 2058 return fetcher, ud
2058 2059
@@ -2062,16 +2063,21 @@ class GitLfsTest(FetcherTest):
2062 uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir 2063 uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir
2063 self.d.setVar('SRC_URI', uri) 2064 self.d.setVar('SRC_URI', uri)
2064 2065
2065 fetcher, ud = self.fetch() 2066 # Careful: suppress initial attempt at downloading until
2067 # we know whether git-lfs is installed.
2068 fetcher, ud = self.fetch(uri=None, download=False)
2066 self.assertIsNotNone(ud.method._find_git_lfs) 2069 self.assertIsNotNone(ud.method._find_git_lfs)
2067 2070
2068 # If git-lfs can be found, the unpack should be successful 2071 # If git-lfs can be found, the unpack should be successful. Only
2069 ud.method._find_git_lfs = lambda d: True 2072 # attempt this with the real live copy of git-lfs installed.
2070 shutil.rmtree(self.gitdir, ignore_errors=True) 2073 if ud.method._find_git_lfs(self.d):
2071 fetcher.unpack(self.d.getVar('WORKDIR')) 2074 fetcher.download()
2075 shutil.rmtree(self.gitdir, ignore_errors=True)
2076 fetcher.unpack(self.d.getVar('WORKDIR'))
2072 2077
2073 # If git-lfs cannot be found, the unpack should throw an error 2078 # If git-lfs cannot be found, the unpack should throw an error
2074 with self.assertRaises(bb.fetch2.FetchError): 2079 with self.assertRaises(bb.fetch2.FetchError):
2080 fetcher.download()
2075 ud.method._find_git_lfs = lambda d: False 2081 ud.method._find_git_lfs = lambda d: False
2076 shutil.rmtree(self.gitdir, ignore_errors=True) 2082 shutil.rmtree(self.gitdir, ignore_errors=True)
2077 fetcher.unpack(self.d.getVar('WORKDIR')) 2083 fetcher.unpack(self.d.getVar('WORKDIR'))
@@ -2082,10 +2088,16 @@ class GitLfsTest(FetcherTest):
2082 uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir 2088 uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir
2083 self.d.setVar('SRC_URI', uri) 2089 self.d.setVar('SRC_URI', uri)
2084 2090
2091 # In contrast to test_lfs_enabled(), allow the implicit download
2092 # done by self.fetch() to occur here. The point of this test case
2093 # is to verify that the fetcher can survive even if the source
2094 # repository has Git LFS usage configured.
2085 fetcher, ud = self.fetch() 2095 fetcher, ud = self.fetch()
2086 self.assertIsNotNone(ud.method._find_git_lfs) 2096 self.assertIsNotNone(ud.method._find_git_lfs)
2087 2097
2088 # If git-lfs can be found, the unpack should be successful 2098 # If git-lfs can be found, the unpack should be successful. A
2099 # live copy of git-lfs is not required for this case, so
2100 # unconditionally forge its presence.
2089 ud.method._find_git_lfs = lambda d: True 2101 ud.method._find_git_lfs = lambda d: True
2090 shutil.rmtree(self.gitdir, ignore_errors=True) 2102 shutil.rmtree(self.gitdir, ignore_errors=True)
2091 fetcher.unpack(self.d.getVar('WORKDIR')) 2103 fetcher.unpack(self.d.getVar('WORKDIR'))