summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/cache.py55
1 files changed, 33 insertions, 22 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index b5be37ea8c..b3c632b81c 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -183,22 +183,34 @@ class Cache(object):
183 newest_mtime = max(old_mtimes) 183 newest_mtime = max(old_mtimes)
184 184
185 if bb.parse.cached_mtime_noerror(self.cachefile) >= newest_mtime: 185 if bb.parse.cached_mtime_noerror(self.cachefile) >= newest_mtime:
186 self.load_cachefile()
187 elif os.path.isfile(self.cachefile):
188 logger.info("Out of date cache found, rebuilding...")
189
190 def load_cachefile(self):
191 with open(self.cachefile, "rb") as cachefile:
192 pickled = pickle.Unpickler(cachefile)
186 try: 193 try:
187 p = pickle.Unpickler(file(self.cachefile, "rb")) 194 cache_ver = pickled.load()
188 self.depends_cache, version_data = p.load() 195 bitbake_ver = pickled.load()
189 if version_data['CACHE_VER'] != __cache_version__: 196 except Exception:
190 raise ValueError('Cache Version Mismatch') 197 logger.info('Invalid cache, rebuilding...')
191 if version_data['BITBAKE_VER'] != bb.__version__: 198 return
192 raise ValueError('Bitbake Version Mismatch') 199
193 except EOFError: 200 if cache_ver != __cache_version__:
194 logger.info("Truncated cache found, rebuilding...") 201 logger.info('Cache version mismatch, rebuilding...')
195 self.depends_cache = {} 202 return
196 except: 203 elif bitbake_ver != bb.__version__:
197 logger.info("Invalid cache found, rebuilding...") 204 logger.info('Bitbake version mismatch, rebuilding...')
198 self.depends_cache = {} 205 return
199 else: 206
200 if os.path.isfile(self.cachefile): 207 while cachefile:
201 logger.info("Out of date cache found, rebuilding...") 208 try:
209 key = pickled.load()
210 value = pickled.load()
211 except Exception:
212 break
213 self.depends_cache[key] = value
202 214
203 @staticmethod 215 @staticmethod
204 def virtualfn2realfn(virtualfn): 216 def virtualfn2realfn(virtualfn):
@@ -406,14 +418,13 @@ class Cache(object):
406 logger.debug(2, "Cache is clean, not saving.") 418 logger.debug(2, "Cache is clean, not saving.")
407 return 419 return
408 420
409 version_data = {
410 'CACHE_VER': __cache_version__,
411 'BITBAKE_VER': bb.__version__,
412 }
413
414 with open(self.cachefile, "wb") as cachefile: 421 with open(self.cachefile, "wb") as cachefile:
415 pickle.Pickler(cachefile, -1).dump([self.depends_cache, 422 pickler = pickle.Pickler(cachefile, pickle.HIGHEST_PROTOCOL)
416 version_data]) 423 pickler.dump(__cache_version__)
424 pickler.dump(bb.__version__)
425 for key, value in self.depends_cache.iteritems():
426 pickler.dump(key)
427 pickler.dump(value)
417 428
418 del self.depends_cache 429 del self.depends_cache
419 430