OSDN Git Service

Change the cache partition size check into warnings.
authorTao Bao <tbao@google.com>
Sat, 8 Aug 2015 02:49:45 +0000 (19:49 -0700)
committerTao Bao <tbao@google.com>
Sat, 8 Aug 2015 02:49:45 +0000 (19:49 -0700)
For some old builds, we may not define cache partition size. Change the
exception into a warning to make the script backward compatible.

Change-Id: Ie94c7fbb1a9f3a7db3f16e8d845e493a534aac5b

tools/releasetools/blockimgdiff.py
tools/releasetools/common.py
tools/releasetools/ota_from_target_files.py

index a007f81..a32c6b1 100644 (file)
@@ -461,7 +461,7 @@ class BlockImageDiff(object):
       if free_string:
         out.append("".join(free_string))
 
-      if self.version >= 2:
+      if self.version >= 2 and common.OPTIONS.cache_size is not None:
         # Sanity check: abort if we're going to need more stash space than
         # the allowed size (cache_size * threshold). There are two purposes
         # of having a threshold here. a) Part of the cache may have been
@@ -502,10 +502,16 @@ class BlockImageDiff(object):
 
     if self.version >= 2:
       max_stashed_size = max_stashed_blocks * self.tgt.blocksize
-      max_allowed = common.OPTIONS.cache_size * common.OPTIONS.stash_threshold
-      print("max stashed blocks: %d  (%d bytes), limit: %d bytes (%.2f%%)\n" % (
-          max_stashed_blocks, max_stashed_size, max_allowed,
-          max_stashed_size * 100.0 / max_allowed))
+      OPTIONS = common.OPTIONS
+      if OPTIONS.cache_size is not None:
+        max_allowed = OPTIONS.cache_size * OPTIONS.stash_threshold
+        print("max stashed blocks: %d  (%d bytes), "
+              "limit: %d bytes (%.2f%%)\n" % (
+              max_stashed_blocks, max_stashed_size, max_allowed,
+              max_stashed_size * 100.0 / max_allowed))
+      else:
+        print("max stashed blocks: %d  (%d bytes), limit: <unknown>\n" % (
+              max_stashed_blocks, max_stashed_size))
 
   def ComputePatches(self, prefix):
     print("Reticulating splines...")
index a67f044..051a22d 100644 (file)
@@ -57,6 +57,9 @@ class Options(object):
     self.extras = {}
     self.info_dict = None
     self.worker_threads = None
+    # Stash size cannot exceed cache_size * threshold.
+    self.cache_size = None
+    self.stash_threshold = 0.8
 
 
 OPTIONS = Options()
index 03b7e05..e40d06a 100755 (executable)
@@ -125,9 +125,6 @@ OPTIONS.updater_binary = None
 OPTIONS.oem_source = None
 OPTIONS.fallback_to_full = True
 OPTIONS.full_radio = False
-# Stash size cannot exceed cache_size * threshold.
-OPTIONS.cache_size = None
-OPTIONS.stash_threshold = 0.8
 
 
 def MostPopularKey(d, default):
@@ -1594,7 +1591,7 @@ def main(argv):
 
     cache_size = OPTIONS.info_dict.get("cache_size", None)
     if cache_size is None:
-      raise RuntimeError("can't determine the cache partition size")
+      print "--- can't determine the cache partition size ---"
     OPTIONS.cache_size = cache_size
 
     if OPTIONS.incremental_source is None: