forked from openkylin/platform_build
Merge "releasetools: Add two new entries to metadata."
am: 8290ba9e0d
* commit '8290ba9e0df3e6f4ef8c21e3964862f90944ead2':
releasetools: Add two new entries to metadata.
This commit is contained in:
commit
214773499c
|
@ -271,6 +271,7 @@ class BlockImageDiff(object):
|
|||
self.transfers = []
|
||||
self.src_basenames = {}
|
||||
self.src_numpatterns = {}
|
||||
self._max_stashed_size = 0
|
||||
|
||||
assert version in (1, 2, 3, 4)
|
||||
|
||||
|
@ -288,6 +289,10 @@ class BlockImageDiff(object):
|
|||
self.AssertPartition(src.care_map, src.file_map.values())
|
||||
self.AssertPartition(tgt.care_map, tgt.file_map.values())
|
||||
|
||||
@property
|
||||
def max_stashed_size(self):
|
||||
return self._max_stashed_size
|
||||
|
||||
def Compute(self, prefix):
|
||||
# When looking for a source file to use as the diff input for a
|
||||
# target file, we try:
|
||||
|
@ -558,17 +563,17 @@ class BlockImageDiff(object):
|
|||
f.write(i)
|
||||
|
||||
if self.version >= 2:
|
||||
max_stashed_size = max_stashed_blocks * self.tgt.blocksize
|
||||
self._max_stashed_size = max_stashed_blocks * self.tgt.blocksize
|
||||
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))
|
||||
max_stashed_blocks, self._max_stashed_size, max_allowed,
|
||||
self._max_stashed_size * 100.0 / max_allowed))
|
||||
else:
|
||||
print("max stashed blocks: %d (%d bytes), limit: <unknown>\n" % (
|
||||
max_stashed_blocks, max_stashed_size))
|
||||
max_stashed_blocks, self._max_stashed_size))
|
||||
|
||||
def ReviseStashSize(self):
|
||||
print("Revising stash size...")
|
||||
|
|
|
@ -30,7 +30,6 @@ import time
|
|||
import zipfile
|
||||
|
||||
import blockimgdiff
|
||||
import rangelib
|
||||
|
||||
from hashlib import sha1 as sha1
|
||||
|
||||
|
@ -1255,6 +1254,7 @@ class BlockDifference(object):
|
|||
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 @@ class BlockDifference(object):
|
|||
_, 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
|
||||
|
|
|
@ -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,))
|
||||
|
||||
|
|
|
@ -542,6 +542,8 @@ def WriteFullOTAPackage(input_zip, output_zip):
|
|||
has_recovery_patch = HasRecoveryPatch(input_zip)
|
||||
block_based = OPTIONS.block_based and has_recovery_patch
|
||||
|
||||
metadata["ota-type"] = "BLOCK" if block_based else "FILE"
|
||||
|
||||
if not OPTIONS.omit_prereq:
|
||||
ts = GetBuildProp("ro.build.date.utc", OPTIONS.info_dict)
|
||||
ts_text = GetBuildProp("ro.build.date", OPTIONS.info_dict)
|
||||
|
@ -697,6 +699,8 @@ endif;
|
|||
endif;
|
||||
""" % bcb_dev)
|
||||
script.AddToZip(input_zip, output_zip, input_path=OPTIONS.updater_binary)
|
||||
|
||||
metadata["ota-required-cache"] = str(script.required_cache)
|
||||
WriteMetadata(metadata, output_zip)
|
||||
|
||||
|
||||
|
@ -773,6 +777,7 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
|||
OPTIONS.source_info_dict),
|
||||
"post-timestamp": GetBuildProp("ro.build.date.utc",
|
||||
OPTIONS.target_info_dict),
|
||||
"ota-type": "BLOCK",
|
||||
}
|
||||
|
||||
device_specific = common.DeviceSpecificParams(
|
||||
|
@ -815,7 +820,7 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
|||
# Check first block of system partition for remount R/W only if
|
||||
# disk type is ext4
|
||||
system_partition = OPTIONS.source_info_dict["fstab"]["/system"]
|
||||
check_first_block = system_partition.fs_type=="ext4"
|
||||
check_first_block = system_partition.fs_type == "ext4"
|
||||
system_diff = common.BlockDifference("system", system_tgt, system_src,
|
||||
check_first_block,
|
||||
version=blockimgdiff_version)
|
||||
|
@ -831,7 +836,7 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
|||
# Check first block of vendor partition for remount R/W only if
|
||||
# disk type is ext4
|
||||
vendor_partition = OPTIONS.source_info_dict["fstab"]["/vendor"]
|
||||
check_first_block = vendor_partition.fs_type=="ext4"
|
||||
check_first_block = vendor_partition.fs_type == "ext4"
|
||||
vendor_diff = common.BlockDifference("vendor", vendor_tgt, vendor_src,
|
||||
check_first_block,
|
||||
version=blockimgdiff_version)
|
||||
|
@ -910,6 +915,13 @@ else if get_stage("%(bcb_dev)s") != "3/3" then
|
|||
GetBuildProp("ro.build.thumbprint", OPTIONS.target_info_dict),
|
||||
GetBuildProp("ro.build.thumbprint", OPTIONS.source_info_dict))
|
||||
|
||||
# Check the required cache size (i.e. stashed blocks).
|
||||
size = []
|
||||
if system_diff:
|
||||
size.append(system_diff.required_cache)
|
||||
if vendor_diff:
|
||||
size.append(vendor_diff.required_cache)
|
||||
|
||||
if updating_boot:
|
||||
boot_type, boot_device = common.GetTypeAndDevice(
|
||||
"/boot", OPTIONS.source_info_dict)
|
||||
|
@ -930,6 +942,10 @@ else if get_stage("%(bcb_dev)s") != "3/3" then
|
|||
(boot_type, boot_device,
|
||||
source_boot.size, source_boot.sha1,
|
||||
target_boot.size, target_boot.sha1))
|
||||
size.append(target_boot.size)
|
||||
|
||||
if size:
|
||||
script.CacheFreeSpaceCheck(max(size))
|
||||
|
||||
device_specific.IncrementalOTA_VerifyEnd()
|
||||
|
||||
|
@ -1003,6 +1019,7 @@ endif;
|
|||
|
||||
script.SetProgress(1)
|
||||
script.AddToZip(target_zip, output_zip, input_path=OPTIONS.updater_binary)
|
||||
metadata["ota-required-cache"] = str(script.required_cache)
|
||||
WriteMetadata(metadata, output_zip)
|
||||
|
||||
|
||||
|
@ -1076,6 +1093,7 @@ def WriteVerifyPackage(input_zip, output_zip):
|
|||
|
||||
script.SetProgress(1.0)
|
||||
script.AddToZip(input_zip, output_zip, input_path=OPTIONS.updater_binary)
|
||||
metadata["ota-required-cache"] = str(script.required_cache)
|
||||
WriteMetadata(metadata, output_zip)
|
||||
|
||||
|
||||
|
@ -1119,6 +1137,8 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file,
|
|||
"pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
|
||||
OPTIONS.info_dict),
|
||||
"post-timestamp": GetBuildProp("ro.build.date.utc", OPTIONS.info_dict),
|
||||
"ota-required-cache": "0",
|
||||
"ota-type": "AB",
|
||||
}
|
||||
|
||||
if source_file is not None:
|
||||
|
@ -1374,6 +1394,7 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
|||
OPTIONS.source_info_dict),
|
||||
"post-timestamp": GetBuildProp("ro.build.date.utc",
|
||||
OPTIONS.target_info_dict),
|
||||
"ota-type": "FILE",
|
||||
}
|
||||
|
||||
device_specific = common.DeviceSpecificParams(
|
||||
|
@ -1487,6 +1508,13 @@ else if get_stage("%(bcb_dev)s") != "3/3" then
|
|||
if vendor_diff:
|
||||
so_far += vendor_diff.EmitVerification(script)
|
||||
|
||||
size = []
|
||||
if system_diff.patch_list:
|
||||
size.append(system_diff.largest_source_size)
|
||||
if vendor_diff:
|
||||
if vendor_diff.patch_list:
|
||||
size.append(vendor_diff.largest_source_size)
|
||||
|
||||
if updating_boot:
|
||||
d = common.Difference(target_boot, source_boot)
|
||||
_, _, d = d.ComputePatch()
|
||||
|
@ -1503,14 +1531,9 @@ else if get_stage("%(bcb_dev)s") != "3/3" then
|
|||
source_boot.size, source_boot.sha1,
|
||||
target_boot.size, target_boot.sha1))
|
||||
so_far += source_boot.size
|
||||
size.append(target_boot.size)
|
||||
|
||||
size = []
|
||||
if system_diff.patch_list:
|
||||
size.append(system_diff.largest_source_size)
|
||||
if vendor_diff:
|
||||
if vendor_diff.patch_list:
|
||||
size.append(vendor_diff.largest_source_size)
|
||||
if size or updating_recovery or updating_boot:
|
||||
if size:
|
||||
script.CacheFreeSpaceCheck(max(size))
|
||||
|
||||
device_specific.IncrementalOTA_VerifyEnd()
|
||||
|
@ -1723,6 +1746,7 @@ endif;
|
|||
vendor_diff.EmitExplicitTargetVerification(script)
|
||||
script.AddToZip(target_zip, output_zip, input_path=OPTIONS.updater_binary)
|
||||
|
||||
metadata["ota-required-cache"] = str(script.required_cache)
|
||||
WriteMetadata(metadata, output_zip)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue