bitbake-1.4/lib/bb/cache.py:
authorHolger Hans Peter Freyther <zecke@selfish.org>
Sat, 29 Apr 2006 17:33:54 +0000 (17:33 +0000)
committerHolger Hans Peter Freyther <zecke@selfish.org>
Sat, 29 Apr 2006 17:33:54 +0000 (17:33 +0000)
    Apply patch from http://bugs.openembedded.org/attachment.cgi?id=681
    bug #891, #895 to not fail if CACHE is not set at all

lib/bb/cache.py

index fc6f75d..d4be9d7 100644 (file)
@@ -48,17 +48,21 @@ class Cache:
     """
     def __init__(self, cooker):
 
     """
     def __init__(self, cooker):
 
+
         self.cachedir = bb.data.getVar("CACHE", cooker.configuration.data, True)
         self.cachedir = bb.data.getVar("CACHE", cooker.configuration.data, True)
-        self.cachefile = os.path.join(self.cachedir,"bb_cache.dat")
         self.clean = {}
         self.depends_cache = {}
         self.data = None
         self.data_fn = None
 
         if self.cachedir in [None, '']:
         self.clean = {}
         self.depends_cache = {}
         self.data = None
         self.data_fn = None
 
         if self.cachedir in [None, '']:
+            self.has_cache = False
             if cooker.cb is not None:
                 print "NOTE: Not using a cache. Set CACHE = <directory> to enable."
         else:
             if cooker.cb is not None:
                 print "NOTE: Not using a cache. Set CACHE = <directory> to enable."
         else:
+            self.has_cache = True
+            self.cachefile = os.path.join(self.cachedir,"bb_cache.dat")
+            
             if cooker.cb is not None:
                 print "NOTE: Using cache in '%s'" % self.cachedir
             try:
             if cooker.cb is not None:
                 print "NOTE: Using cache in '%s'" % self.cachedir
             try:
@@ -66,7 +70,7 @@ class Cache:
             except OSError:
                 bb.mkdirhier( self.cachedir )
 
             except OSError:
                 bb.mkdirhier( self.cachedir )
 
-        if (self.mtime(self.cachefile)):
+        if self.has_cache and (self.mtime(self.cachefile)):
             try:
                 p = pickle.Unpickler( file(self.cachefile,"rb"))
                 self.depends_cache, version_data = p.load()
             try:
                 p = pickle.Unpickler( file(self.cachefile,"rb"))
                 self.depends_cache, version_data = p.load()
@@ -153,7 +157,7 @@ class Cache:
         Fast version, no timestamps checked.
         """
         # Is cache enabled?
         Fast version, no timestamps checked.
         """
         # Is cache enabled?
-        if self.cachedir in [None, '']:
+        if not self.has_cache:
             return False
         if fn in self.clean:
             return True
             return False
         if fn in self.clean:
             return True
@@ -165,7 +169,7 @@ class Cache:
         Make thorough (slower) checks including timestamps.
         """
         # Is cache enabled?
         Make thorough (slower) checks including timestamps.
         """
         # Is cache enabled?
-        if self.cachedir in [None, '']:
+        if not self.has_cache:
             return False
 
         # Check file still exists
             return False
 
         # Check file still exists
@@ -231,6 +235,9 @@ class Cache:
         Called from the parser when complete (or exitting)
         """
 
         Called from the parser when complete (or exitting)
         """
 
+        if not self.has_cache:
+            return
+
         version_data = {}
         version_data['CACHE_VER'] = __cache_version__
         version_data['BITBAKE_VER'] = bb.__version__
         version_data = {}
         version_data['CACHE_VER'] = __cache_version__
         version_data['BITBAKE_VER'] = bb.__version__