Merge "releasetools: Remove the obsolete path in GetImage()."

This commit is contained in:
Tao Bao 2017-03-07 06:20:04 +00:00 committed by Gerrit Code Review
commit 7dc54e9761
1 changed files with 17 additions and 34 deletions

View File

@ -556,36 +556,21 @@ def CalculateFingerprint(oem_props, oem_dict, info_dict):
GetBuildProp("ro.build.thumbprint", info_dict)) GetBuildProp("ro.build.thumbprint", info_dict))
def GetImage(which, tmpdir, info_dict): def GetImage(which, tmpdir):
# Return an image object (suitable for passing to BlockImageDiff) """Returns an image object suitable for passing to BlockImageDiff.
# for the 'which' partition (most be "system" or "vendor"). If a
# prebuilt image and file map are found in tmpdir they are used, 'which' partition must be "system" or "vendor". A prebuilt image and file
# otherwise they are reconstructed from the individual files. map must already exist in tmpdir.
"""
assert which in ("system", "vendor") assert which in ("system", "vendor")
path = os.path.join(tmpdir, "IMAGES", which + ".img") path = os.path.join(tmpdir, "IMAGES", which + ".img")
mappath = os.path.join(tmpdir, "IMAGES", which + ".map") mappath = os.path.join(tmpdir, "IMAGES", which + ".map")
if os.path.exists(path) and os.path.exists(mappath):
print("using %s.img from target-files" % (which,))
# This is a 'new' target-files, which already has the image in it.
else: # The image and map files must have been created prior to calling
print("building %s.img from target-files" % (which,)) # ota_from_target_files.py (since LMP).
assert os.path.exists(path) and os.path.exists(mappath)
# This is an 'old' target-files, which does not contain images
# already built. Build them.
mappath = tempfile.mkstemp()[1]
OPTIONS.tempfiles.append(mappath)
import add_img_to_target_files
if which == "system":
path = add_img_to_target_files.BuildSystem(
tmpdir, info_dict, block_list=mappath)
elif which == "vendor":
path = add_img_to_target_files.BuildVendor(
tmpdir, info_dict, block_list=mappath)
# Bug: http://b/20939131 # Bug: http://b/20939131
# In ext4 filesystems, block 0 might be changed even being mounted # In ext4 filesystems, block 0 might be changed even being mounted
@ -712,7 +697,7 @@ else if get_stage("%(bcb_dev)s") == "3/3" then
# image. This has the effect of writing new data from the package # image. This has the effect of writing new data from the package
# to the entire partition, but lets us reuse the updater code that # to the entire partition, but lets us reuse the updater code that
# writes incrementals to do it. # writes incrementals to do it.
system_tgt = GetImage("system", OPTIONS.input_tmp, OPTIONS.info_dict) system_tgt = GetImage("system", OPTIONS.input_tmp)
system_tgt.ResetFileMap() system_tgt.ResetFileMap()
system_diff = common.BlockDifference("system", system_tgt, src=None) system_diff = common.BlockDifference("system", system_tgt, src=None)
system_diff.WriteScript(script, output_zip) system_diff.WriteScript(script, output_zip)
@ -745,7 +730,7 @@ else if get_stage("%(bcb_dev)s") == "3/3" then
script.ShowProgress(0.1, 0) script.ShowProgress(0.1, 0)
if block_based: if block_based:
vendor_tgt = GetImage("vendor", OPTIONS.input_tmp, OPTIONS.info_dict) vendor_tgt = GetImage("vendor", OPTIONS.input_tmp)
vendor_tgt.ResetFileMap() vendor_tgt.ResetFileMap()
vendor_diff = common.BlockDifference("vendor", vendor_tgt) vendor_diff = common.BlockDifference("vendor", vendor_tgt)
vendor_diff.WriteScript(script, output_zip) vendor_diff.WriteScript(script, output_zip)
@ -934,8 +919,8 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
target_recovery = common.GetBootableImage( target_recovery = common.GetBootableImage(
"/tmp/recovery.img", "recovery.img", OPTIONS.target_tmp, "RECOVERY") "/tmp/recovery.img", "recovery.img", OPTIONS.target_tmp, "RECOVERY")
system_src = GetImage("system", OPTIONS.source_tmp, OPTIONS.source_info_dict) system_src = GetImage("system", OPTIONS.source_tmp)
system_tgt = GetImage("system", OPTIONS.target_tmp, OPTIONS.target_info_dict) system_tgt = GetImage("system", OPTIONS.target_tmp)
blockimgdiff_version = 1 blockimgdiff_version = 1
if OPTIONS.info_dict: if OPTIONS.info_dict:
@ -962,10 +947,8 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
if HasVendorPartition(target_zip): if HasVendorPartition(target_zip):
if not HasVendorPartition(source_zip): if not HasVendorPartition(source_zip):
raise RuntimeError("can't generate incremental that adds /vendor") raise RuntimeError("can't generate incremental that adds /vendor")
vendor_src = GetImage("vendor", OPTIONS.source_tmp, vendor_src = GetImage("vendor", OPTIONS.source_tmp)
OPTIONS.source_info_dict) vendor_tgt = GetImage("vendor", OPTIONS.target_tmp)
vendor_tgt = GetImage("vendor", OPTIONS.target_tmp,
OPTIONS.target_info_dict)
# Check first block of vendor partition for remount R/W only if # Check first block of vendor partition for remount R/W only if
# disk type is ext4 # disk type is ext4
@ -1235,13 +1218,13 @@ def WriteVerifyPackage(input_zip, output_zip):
recovery_type, recovery_device, recovery_img.size, recovery_img.sha1)) recovery_type, recovery_device, recovery_img.size, recovery_img.sha1))
script.AppendExtra("") script.AppendExtra("")
system_tgt = GetImage("system", OPTIONS.input_tmp, OPTIONS.info_dict) system_tgt = GetImage("system", OPTIONS.input_tmp)
system_tgt.ResetFileMap() system_tgt.ResetFileMap()
system_diff = common.BlockDifference("system", system_tgt, src=None) system_diff = common.BlockDifference("system", system_tgt, src=None)
system_diff.WriteStrictVerifyScript(script) system_diff.WriteStrictVerifyScript(script)
if HasVendorPartition(input_zip): if HasVendorPartition(input_zip):
vendor_tgt = GetImage("vendor", OPTIONS.input_tmp, OPTIONS.info_dict) vendor_tgt = GetImage("vendor", OPTIONS.input_tmp)
vendor_tgt.ResetFileMap() vendor_tgt.ResetFileMap()
vendor_diff = common.BlockDifference("vendor", vendor_tgt, src=None) vendor_diff = common.BlockDifference("vendor", vendor_tgt, src=None)
vendor_diff.WriteStrictVerifyScript(script) vendor_diff.WriteStrictVerifyScript(script)