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
This commit is contained in:
Tao Bao
2016-02-04 14:26:02 -08:00
parent db82f72752
commit d8d14bec0d
4 changed files with 54 additions and 14 deletions

View File

@@ -23,6 +23,7 @@ class EdifyGenerator(object):
def __init__(self, version, info, fstab=None):
self.script = []
self.mounts = set()
self._required_cache = 0
self.version = version
self.info = info
if fstab is None:
@@ -38,6 +39,11 @@ class EdifyGenerator(object):
x.mounts = self.mounts
return x
@property
def required_cache(self):
"""Return the minimum cache size to apply the update."""
return self._required_cache
@staticmethod
def WordWrap(cmd, linelen=80):
"""'cmd' should be a function call with null characters after each
@@ -171,6 +177,7 @@ class EdifyGenerator(object):
def CacheFreeSpaceCheck(self, amount):
"""Check that there's at least 'amount' space that can be made
available on /cache."""
self._required_cache = max(self._required_cache, amount)
self.script.append(('apply_patch_space(%d) || abort("Not enough free space '
'on /cache to apply patches.");') % (amount,))