From 116977c7dba5ff79d1119a30966f918d72efedeb Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 7 Aug 2015 19:49:45 -0700 Subject: [PATCH] DO NOT MERGE Change the cache partition size check into warnings. 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: Ia90531e3455d4888cfac6510cab879c50883be53 (cherry picked from commit 575d68a48edc90d655509f2980dacc69958948de) --- tools/releasetools/blockimgdiff.py | 16 +++++++++++----- tools/releasetools/common.py | 3 +++ tools/releasetools/ota_from_target_files.py | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py index cb6fc8582a..a6c6bd8747 100644 --- a/tools/releasetools/blockimgdiff.py +++ b/tools/releasetools/blockimgdiff.py @@ -483,7 +483,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 @@ -524,10 +524,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: \n" % ( + max_stashed_blocks, max_stashed_size)) def ReviseStashSize(self): print("Revising stash size...") diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 2965fa8045..0e8923b4ae 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -62,6 +62,9 @@ class Options(object): self.source_info_dict = None self.target_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() diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index c5c16b408a..7a470e9272 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -1634,7 +1634,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: