releasetools: Add two new entries to metadata.
Add "ota-required-cache" into the metadata file in an OTA package,
which shows the minimum free space on /cache to apply the update.
Add "ota-type" into the metadata file, which shows the OTA type for
this package (i.e. one of FILE, BLOCK and AB).
Also add the cache free space check into updater-script when generating
block-based incremental OTAs (we only had such lines for file-based
incrementals before).
Bug: 26731903
Change-Id: Id6ff0fc4cdfb1443636b0b3800b0f8bddb5bb1d0
(cherry picked from commit d8d14bec0d9fb604060634729b4a09c7898d0c9a)
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 95aeb62..403c67d 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -30,7 +30,6 @@
import zipfile
import blockimgdiff
-import rangelib
from hashlib import sha1 as sha1
@@ -1255,6 +1254,7 @@
OPTIONS.tempfiles.append(tmpdir)
self.path = os.path.join(tmpdir, partition)
b.Compute(self.path)
+ self._required_cache = b.max_stashed_size
if src is None:
_, self.device = GetTypeAndDevice("/" + partition, OPTIONS.info_dict)
@@ -1262,6 +1262,10 @@
_, self.device = GetTypeAndDevice("/" + partition,
OPTIONS.source_info_dict)
+ @property
+ def required_cache(self):
+ return self._required_cache
+
def WriteScript(self, script, output_zip, progress=None):
if not self.src:
# write the output unconditionally