summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2020-03-09 13:42:46 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-11 14:43:25 +0000
commit6932c9757c870b6338e2a525696791bf3de6f703 (patch)
tree09d90084d34d07100c19ffaf1ddc614e9fb921f4 /bitbake
parent4cae3324bd362829dbb1c122342f2c7854a27899 (diff)
downloadpoky-6932c9757c870b6338e2a525696791bf3de6f703.tar.gz
bitbake: fetch2/gitsm: Unpack shallow mirror tarballs
When a shallow mirror tarball is used to satisfy a gitsm URI it needs to be unpacked temporarily so that the .gitmodules file can be examined. (Bitbake rev: 3987db953e414255ce278bc25a5f6cec0f2a30c7) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index aa121cbee1..e7083001da 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -20,6 +20,8 @@ NOTE: Switching a SRC_URI from "git://" to "gitsm://" requires a clean of your r
20import os 20import os
21import bb 21import bb
22import copy 22import copy
23import shutil
24import tempfile
23from bb.fetch2.git import Git 25from bb.fetch2.git import Git
24from bb.fetch2 import runfetchcmd 26from bb.fetch2 import runfetchcmd
25from bb.fetch2 import logger 27from bb.fetch2 import logger
@@ -130,7 +132,7 @@ class GitSM(Git):
130 ld.setVar('SRCPV', d.getVar('SRCPV')) 132 ld.setVar('SRCPV', d.getVar('SRCPV'))
131 ld.setVar('SRCREV_FORMAT', module) 133 ld.setVar('SRCREV_FORMAT', module)
132 134
133 function(ud, url, module, paths[module], ld) 135 function(ud, url, module, paths[module], workdir, ld)
134 136
135 return submodules != [] 137 return submodules != []
136 138
@@ -152,7 +154,7 @@ class GitSM(Git):
152 return False 154 return False
153 155
154 def download(self, ud, d): 156 def download(self, ud, d):
155 def download_submodule(ud, url, module, modpath, d): 157 def download_submodule(ud, url, module, modpath, workdir, d):
156 url += ";bareclone=1;nobranch=1" 158 url += ";bareclone=1;nobranch=1"
157 159
158 # Is the following still needed? 160 # Is the following still needed?
@@ -163,16 +165,25 @@ class GitSM(Git):
163 newfetch.download() 165 newfetch.download()
164 # Drop a nugget to add each of the srcrevs we've fetched (used by need_update) 166 # Drop a nugget to add each of the srcrevs we've fetched (used by need_update)
165 runfetchcmd("%s config --add bitbake.srcrev %s" % \ 167 runfetchcmd("%s config --add bitbake.srcrev %s" % \
166 (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=ud.clonedir) 168 (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=workdir)
167 except Exception as e: 169 except Exception as e:
168 logger.error('gitsm: submodule download failed: %s %s' % (type(e).__name__, str(e))) 170 logger.error('gitsm: submodule download failed: %s %s' % (type(e).__name__, str(e)))
169 raise 171 raise
170 172
171 Git.download(self, ud, d) 173 Git.download(self, ud, d)
172 self.process_submodules(ud, ud.clonedir, download_submodule, d) 174
175 # If we're using a shallow mirror tarball it needs to be unpacked
176 # temporarily so that we can examine the .gitmodules file
177 if ud.shallow and os.path.exists(ud.fullshallow) and self.need_update(ud, d):
178 tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR"))
179 runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir)
180 self.process_submodules(ud, tmpdir, download_submodule, d)
181 shutil.rmtree(tmpdir)
182 else:
183 self.process_submodules(ud, ud.clonedir, download_submodule, d)
173 184
174 def unpack(self, ud, destdir, d): 185 def unpack(self, ud, destdir, d):
175 def unpack_submodules(ud, url, module, modpath, d): 186 def unpack_submodules(ud, url, module, modpath, workdir, d):
176 url += ";bareclone=1;nobranch=1" 187 url += ";bareclone=1;nobranch=1"
177 188
178 # Figure out where we clone over the bare submodules... 189 # Figure out where we clone over the bare submodules...