diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2006-04-16 22:11:50 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2006-04-16 22:11:50 +0000 |
commit | eae1d47349f0527200f607d49f1ce5752ab90ed9 (patch) | |
tree | 39b54e85ed61e9dcf9f2be2b3ad45b21259a0674 | |
parent | 3122f2d579cc5443a12e50d0ca84bed8fed72811 (diff) | |
download | bitbake-eae1d47349f0527200f607d49f1ce5752ab90ed9.tar.gz |
bitbake/lib/bb/cache.py:
* Add cache version handling to allow cache format changes in
the future.
-rw-r--r-- | lib/bb/cache.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/bb/cache.py b/lib/bb/cache.py index eb4ae856c..3bb14c99d 100644 --- a/lib/bb/cache.py +++ b/lib/bb/cache.py @@ -40,6 +40,8 @@ except ImportError: import pickle print "NOTE: Importing cPickle failed. Falling back to a very slow implementation." +__cache_version__ = "123" + class Cache: """ BitBake Cache implementation @@ -65,8 +67,17 @@ class Cache: bb.mkdirhier( self.cachedir ) if (self.mtime(self.cachefile)): - p = pickle.Unpickler( file(self.cachefile,"rb")) - self.depends_cache = p.load() + try: + p = pickle.Unpickler( file(self.cachefile,"rb")) + self.depends_cache, version_data = p.load() + if version_data['CACHE_VER'] != __cache_version__: + raise ValueError, 'Cache Version Mismatch' + if version_data['BITBAKE_VER'] != bb.__version__: + raise ValueError, 'Bitbake Version Mismatch' + except (ValueError, KeyError): + bb.note("Invalid cache found, rebuilding...") + self.depends_cache = {} + if self.depends_cache: for fn in self.depends_cache.keys(): self.clean[fn] = "" @@ -223,8 +234,13 @@ class Cache: Save the cache Called from the parser when complete (or exitting) """ + + version_data = {} + version_data['CACHE_VER'] = __cache_version__ + version_data['BITBAKE_VER'] = bb.__version__ + p = pickle.Pickler(file(self.cachefile, "wb" ), -1 ) - p.dump(self.depends_cache) + p.dump([self.depends_cache, version_data]) def mtime(self, cachefile): try: |