summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/gitsm.py
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2019-03-27 13:40:42 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-18 11:31:10 +0100
commit2dd610cc27c606f731f83047b4766787aab6e6b2 (patch)
treed5b9c335f06d658c080968ba5995d2da424ba231 /bitbake/lib/bb/fetch2/gitsm.py
parent1f82ca67131694e2c85aeb15629ceb97e0bb9df4 (diff)
downloadpoky-2dd610cc27c606f731f83047b4766787aab6e6b2.tar.gz
bitbake: gitsm: Add need_update method to determine when we are going to a new SRCREV
If the system had previously fetched a source repository for use by gitsm, and then the SRCREV was updated and the new commit already existed, the system would not re-evaluate the submodules and update them accordingly. The cause of this issue was that need_update was being used, unmodified, from the base git fetcher. It did not have any knowledge, nor did it care if we were moving commits and needed to re-evaluate what was happening due to this switch. To fix the issue, during the download process we add all processed (by gitsm) srcrevs to the git config file, as bitbake.srcrev. This allows us to use a new need_update function that not only checks if the git commit is present, but if we have previously processed this commit to ensure all of the submodule components are also present. This approach is used, instead of iterating over the submodules in need_update to avoid a potential race condition that has affected us in the past. The need_update is called only with the parent locking. Any time we need to dive into the submodules, we need to lock, and unlock them, at each stage. This opens the possibility of errors in either the code, or unintended race conditions with rm_work. This issue was discovered by William A. Kennington III <wak@google.com>. The included test case was also written by him, and included unmodified. (Bitbake rev: 4ce92f43eeac6a4bfd06e8567fa6891614b5b3b0) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/gitsm.py')
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index 54f99b1036..a07eb7e7ee 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -147,6 +147,23 @@ class GitSM(Git):
147 147
148 return submodules != [] 148 return submodules != []
149 149
150 def need_update(self, ud, d):
151 if Git.need_update(self, ud, d):
152 return True
153
154 try:
155 # Check for the nugget dropped by the download operation
156 known_srcrevs = runfetchcmd("%s config --get-all bitbake.srcrev" % \
157 (ud.basecmd), d, workdir=ud.clonedir)
158
159 if ud.revisions[ud.names[0]] not in known_srcrevs.split():
160 return True
161 except bb.fetch2.FetchError:
162 # No srcrev nuggets, so this is new and needs to be updated
163 return True
164
165 return False
166
150 def download(self, ud, d): 167 def download(self, ud, d):
151 def download_submodule(ud, url, module, modpath, d): 168 def download_submodule(ud, url, module, modpath, d):
152 url += ";bareclone=1;nobranch=1" 169 url += ";bareclone=1;nobranch=1"
@@ -157,6 +174,9 @@ class GitSM(Git):
157 try: 174 try:
158 newfetch = Fetch([url], d, cache=False) 175 newfetch = Fetch([url], d, cache=False)
159 newfetch.download() 176 newfetch.download()
177 # Drop a nugget to add each of the srcrevs we've fetched (used by need_update)
178 runfetchcmd("%s config --add bitbake.srcrev %s" % \
179 (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=ud.clonedir)
160 except Exception as e: 180 except Exception as e:
161 logger.error('gitsm: submodule download failed: %s %s' % (type(e).__name__, str(e))) 181 logger.error('gitsm: submodule download failed: %s %s' % (type(e).__name__, str(e)))
162 raise 182 raise