summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py39
1 files changed, 35 insertions, 4 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index 175dee05c0..d6e5c5c050 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -143,12 +143,43 @@ class GitSM(Git):
143 try: 143 try:
144 # Check for the nugget dropped by the download operation 144 # Check for the nugget dropped by the download operation
145 known_srcrevs = runfetchcmd("%s config --get-all bitbake.srcrev" % \ 145 known_srcrevs = runfetchcmd("%s config --get-all bitbake.srcrev" % \
146 (ud.basecmd), d, workdir=ud.clonedir) 146 (ud.basecmd), d, workdir=ud.clonedir)
147 147
148 if ud.revisions[ud.names[0]] not in known_srcrevs.split(): 148 if ud.revisions[ud.names[0]] in known_srcrevs.split():
149 return True 149 return False
150 except bb.fetch2.FetchError: 150 except bb.fetch2.FetchError:
151 # No srcrev nuggets, so this is new and needs to be updated 151 pass
152
153 need_update_list = []
154 def need_update_submodule(ud, url, module, modpath, workdir, d):
155 url += ";bareclone=1;nobranch=1"
156
157 try:
158 newfetch = Fetch([url], d, cache=False)
159 new_ud = newfetch.ud[url]
160 if new_ud.method.need_update(new_ud, d):
161 need_update_list.append(modpath)
162 except Exception as e:
163 logger.error('gitsm: submodule update check failed: %s %s' % (type(e).__name__, str(e)))
164 need_update_result = True
165
166 # If we're using a shallow mirror tarball it needs to be unpacked
167 # temporarily so that we can examine the .gitmodules file
168 if ud.shallow and os.path.exists(ud.fullshallow) and not os.path.exists(ud.clonedir):
169 tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR"))
170 runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir)
171 self.process_submodules(ud, tmpdir, need_update_submodule, d)
172 shutil.rmtree(tmpdir)
173 else:
174 self.process_submodules(ud, ud.clonedir, need_update_submodule, d)
175 if len(need_update_list) == 0:
176 # We already have the required commits of all submodules. Drop
177 # a nugget so we don't need to check again.
178 runfetchcmd("%s config --add bitbake.srcrev %s" % \
179 (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=ud.clonedir)
180
181 if len(need_update_list) > 0:
182 logger.debug(1, 'gitsm: Submodules requiring update: %s' % (' '.join(need_update_list)))
152 return True 183 return True
153 184
154 return False 185 return False