summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
authorMatt Hoosier <matt.hoosier@garmin.com>2021-01-22 10:55:13 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-01-23 17:10:46 +0000
commit45c02843d181b5f1872ad30f4d847c395233a676 (patch)
tree1b61559ebf14f9b5a97b283b6860dd795024b674 /bitbake/lib/bb/tests/fetch.py
parent8e92ec78322909ca5ad6ceda582b611fa77a9964 (diff)
downloadpoky-45c02843d181b5f1872ad30f4d847c395233a676.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: 0efac66043662e7a2027192f50e92e982db2ba1c) Signed-off-by: Matt Hoosier <matt.hoosier@garmin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-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 20beab3855..7b2dac7b86 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2108,13 +2108,14 @@ class GitLfsTest(FetcherTest):
2108 cwd = self.gitdir 2108 cwd = self.gitdir
2109 return bb.process.run(cmd, cwd=cwd)[0] 2109 return bb.process.run(cmd, cwd=cwd)[0]
2110 2110
2111 def fetch(self, uri=None): 2111 def fetch(self, uri=None, download=True):
2112 uris = self.d.getVar('SRC_URI').split() 2112 uris = self.d.getVar('SRC_URI').split()
2113 uri = uris[0] 2113 uri = uris[0]
2114 d = self.d 2114 d = self.d
2115 2115
2116 fetcher = bb.fetch2.Fetch(uris, d) 2116 fetcher = bb.fetch2.Fetch(uris, d)
2117 fetcher.download() 2117 if download:
2118 fetcher.download()
2118 ud = fetcher.ud[uri] 2119 ud = fetcher.ud[uri]
2119 return fetcher, ud 2120 return fetcher, ud
2120 2121
@@ -2124,16 +2125,21 @@ class GitLfsTest(FetcherTest):
2124 uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir 2125 uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir
2125 self.d.setVar('SRC_URI', uri) 2126 self.d.setVar('SRC_URI', uri)
2126 2127
2127 fetcher, ud = self.fetch() 2128 # Careful: suppress initial attempt at downloading until
2129 # we know whether git-lfs is installed.
2130 fetcher, ud = self.fetch(uri=None, download=False)
2128 self.assertIsNotNone(ud.method._find_git_lfs) 2131 self.assertIsNotNone(ud.method._find_git_lfs)
2129 2132
2130 # If git-lfs can be found, the unpack should be successful 2133 # If git-lfs can be found, the unpack should be successful. Only
2131 ud.method._find_git_lfs = lambda d: True 2134 # attempt this with the real live copy of git-lfs installed.
2132 shutil.rmtree(self.gitdir, ignore_errors=True) 2135 if ud.method._find_git_lfs(self.d):
2133 fetcher.unpack(self.d.getVar('WORKDIR')) 2136 fetcher.download()
2137 shutil.rmtree(self.gitdir, ignore_errors=True)
2138 fetcher.unpack(self.d.getVar('WORKDIR'))
2134 2139
2135 # If git-lfs cannot be found, the unpack should throw an error 2140 # If git-lfs cannot be found, the unpack should throw an error
2136 with self.assertRaises(bb.fetch2.FetchError): 2141 with self.assertRaises(bb.fetch2.FetchError):
2142 fetcher.download()
2137 ud.method._find_git_lfs = lambda d: False 2143 ud.method._find_git_lfs = lambda d: False
2138 shutil.rmtree(self.gitdir, ignore_errors=True) 2144 shutil.rmtree(self.gitdir, ignore_errors=True)
2139 fetcher.unpack(self.d.getVar('WORKDIR')) 2145 fetcher.unpack(self.d.getVar('WORKDIR'))
@@ -2144,10 +2150,16 @@ class GitLfsTest(FetcherTest):
2144 uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir 2150 uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir
2145 self.d.setVar('SRC_URI', uri) 2151 self.d.setVar('SRC_URI', uri)
2146 2152
2153 # In contrast to test_lfs_enabled(), allow the implicit download
2154 # done by self.fetch() to occur here. The point of this test case
2155 # is to verify that the fetcher can survive even if the source
2156 # repository has Git LFS usage configured.
2147 fetcher, ud = self.fetch() 2157 fetcher, ud = self.fetch()
2148 self.assertIsNotNone(ud.method._find_git_lfs) 2158 self.assertIsNotNone(ud.method._find_git_lfs)
2149 2159
2150 # If git-lfs can be found, the unpack should be successful 2160 # If git-lfs can be found, the unpack should be successful. A
2161 # live copy of git-lfs is not required for this case, so
2162 # unconditionally forge its presence.
2151 ud.method._find_git_lfs = lambda d: True 2163 ud.method._find_git_lfs = lambda d: True
2152 shutil.rmtree(self.gitdir, ignore_errors=True) 2164 shutil.rmtree(self.gitdir, ignore_errors=True)
2153 fetcher.unpack(self.d.getVar('WORKDIR')) 2165 fetcher.unpack(self.d.getVar('WORKDIR'))