summaryrefslogtreecommitdiffstats
path: root/tools/releasetools/ota_from_target_files.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/releasetools/ota_from_target_files.py')
-rwxr-xr-xtools/releasetools/ota_from_target_files.py40
1 files changed, 24 insertions, 16 deletions
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index eab3daa..82d6313 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -92,7 +92,6 @@ if sys.hexversion < 0x02070000:
print >> sys.stderr, "Python 2.7 or newer is required."
sys.exit(1)
-import copy
import multiprocessing
import os
import tempfile
@@ -371,6 +370,7 @@ def CopyPartitionFiles(itemset, input_zip, output_zip=None, substitute=None):
symlinks.append((input_zip.read(info.filename),
"/" + partition + "/" + basefilename))
else:
+ import copy
info2 = copy.copy(info)
fn = info2.filename = partition + "/" + basefilename
if substitute and fn in substitute and substitute[fn] is None:
@@ -380,7 +380,7 @@ def CopyPartitionFiles(itemset, input_zip, output_zip=None, substitute=None):
data = substitute[fn]
else:
data = input_zip.read(info.filename)
- output_zip.writestr(info2, data)
+ common.ZipWriteStr(output_zip, info2, data)
if fn.endswith("/"):
itemset.Get(fn[:-1], is_dir=True)
else:
@@ -475,13 +475,20 @@ def GetImage(which, tmpdir, info_dict):
path = add_img_to_target_files.BuildVendor(
tmpdir, info_dict, block_list=mappath)
- return sparse_img.SparseImage(path, mappath)
+ # Bug: http://b/20939131
+ # In ext4 filesystems, block 0 might be changed even being mounted
+ # R/O. We add it to clobbered_blocks so that it will be written to the
+ # target unconditionally. Note that they are still part of care_map.
+ clobbered_blocks = "0"
+
+ return sparse_img.SparseImage(path, mappath, clobbered_blocks)
def WriteFullOTAPackage(input_zip, output_zip):
# TODO: how to determine this? We don't know what version it will
- # be installed on top of. For now, we expect the API just won't
- # change very often.
+ # be installed on top of. For now, we expect the API just won't
+ # change very often. Similarly for fstab, it might have changed
+ # in the target build.
script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict)
oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
@@ -721,8 +728,9 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
if source_version == 0:
print ("WARNING: generating edify script for a source that "
"can't install it.")
- script = edify_generator.EdifyGenerator(source_version,
- OPTIONS.target_info_dict)
+ script = edify_generator.EdifyGenerator(
+ source_version, OPTIONS.target_info_dict,
+ fstab=OPTIONS.source_info_dict["fstab"])
metadata = {
"pre-device": GetBuildProp("ro.product.device",
@@ -773,7 +781,6 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
OPTIONS.info_dict.get("blockimgdiff_versions", "1").split(","))
system_diff = common.BlockDifference("system", system_tgt, system_src,
- check_first_block=True,
version=blockimgdiff_version)
if HasVendorPartition(target_zip):
@@ -784,13 +791,12 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
vendor_tgt = GetImage("vendor", OPTIONS.target_tmp,
OPTIONS.target_info_dict)
vendor_diff = common.BlockDifference("vendor", vendor_tgt, vendor_src,
- check_first_block=True,
version=blockimgdiff_version)
else:
vendor_diff = None
oem_props = OPTIONS.target_info_dict.get("oem_fingerprint_properties")
- recovery_mount_options = OPTIONS.target_info_dict.get(
+ recovery_mount_options = OPTIONS.source_info_dict.get(
"recovery_mount_options")
oem_dict = None
if oem_props is not None and len(oem_props) > 0:
@@ -1110,11 +1116,13 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
if source_version == 0:
print ("WARNING: generating edify script for a source that "
"can't install it.")
- script = edify_generator.EdifyGenerator(source_version,
- OPTIONS.target_info_dict)
+ script = edify_generator.EdifyGenerator(
+ source_version, OPTIONS.target_info_dict,
+ fstab=OPTIONS.source_info_dict["fstab"])
oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
- recovery_mount_options = OPTIONS.info_dict.get("recovery_mount_options")
+ recovery_mount_options = OPTIONS.source_info_dict.get(
+ "recovery_mount_options")
oem_dict = None
if oem_props is not None and len(oem_props) > 0:
if OPTIONS.oem_source is None:
@@ -1581,6 +1589,7 @@ def main(argv):
OPTIONS.package_key = OPTIONS.info_dict.get(
"default_system_dev_certificate",
"build/target/product/security/testkey")
+ common.ZipClose(output_zip)
break
else:
@@ -1601,15 +1610,14 @@ def main(argv):
common.DumpInfoDict(OPTIONS.source_info_dict)
try:
WriteIncrementalOTAPackage(input_zip, source_zip, output_zip)
+ common.ZipClose(output_zip)
break
except ValueError:
if not OPTIONS.fallback_to_full:
raise
print "--- failed to build incremental; falling back to full ---"
OPTIONS.incremental_source = None
- output_zip.close()
-
- output_zip.close()
+ common.ZipClose(output_zip)
if not OPTIONS.no_signing:
SignOutput(temp_zip_file.name, args[1])