consolidate target_files metadata into one key-value file
Instead of separate files for recovery api version, tool extensions,
and mkyaffs2 options, put those all in the generic key-value file.
Change-Id: Ib642311632844d52e4895fd4747093fc7e86232d
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 89caa5c..37715bc 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -347,7 +347,7 @@
device_specific = common.DeviceSpecificParams(
input_zip=input_zip,
- input_version=GetRecoveryAPIVersion(input_zip),
+ input_version=OPTIONS.info_dict["recovery_api_version"],
output_zip=output_zip,
script=script,
input_tmp=OPTIONS.input_tmp,
@@ -382,7 +382,7 @@
Item.GetMetadata(input_zip)
Item.Get("system").SetPermissions(script)
- common.CheckSize(boot_img.data, "boot.img")
+ common.CheckSize(boot_img.data, "boot.img", OPTIONS.info_dict)
common.ZipWriteStr(output_zip, "boot.img", boot_img.data)
script.ShowProgress(0.2, 0)
@@ -432,25 +432,9 @@
return m.group(1).strip()
-def GetRecoveryAPIVersion(zip):
- """Returns the version of the recovery API. Version 0 is the older
- amend code (no separate binary)."""
- try:
- version = zip.read("META/recovery-api-version.txt")
- return int(version)
- except KeyError:
- try:
- # version one didn't have the recovery-api-version.txt file, but
- # it did include an updater binary.
- zip.getinfo("OTA/bin/updater")
- return 1
- except KeyError:
- return 0
-
-
def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
- source_version = GetRecoveryAPIVersion(source_zip)
- target_version = GetRecoveryAPIVersion(target_zip)
+ source_version = OPTIONS.source_info_dict["recovery_api_version"]
+ target_version = OPTIONS.target_info_dict["recovery_api_version"]
if source_version == 0:
print ("WARNING: generating edify script for a source that "
@@ -738,33 +722,19 @@
print "unzipping target target-files..."
OPTIONS.input_tmp = common.UnzipTemp(args[0])
- if OPTIONS.device_specific is None:
- # look for the device-specific tools extension location in the input
- try:
- f = open(os.path.join(OPTIONS.input_tmp, "META", "tool-extensions.txt"))
- ds = f.read().strip()
- f.close()
- if ds:
- ds = os.path.normpath(ds)
- print "using device-specific extensions in", ds
- OPTIONS.device_specific = ds
- except IOError, e:
- if e.errno == errno.ENOENT:
- # nothing specified in the file
- pass
- else:
- raise
-
- OPTIONS.info_dict = common.LoadInfoDict()
- common.LoadMaxSizes(OPTIONS.info_dict)
- if not OPTIONS.max_image_size:
- print
- print " WARNING: Failed to load max image sizes; will not enforce"
- print " image size limits."
- print
-
OPTIONS.target_tmp = OPTIONS.input_tmp
input_zip = zipfile.ZipFile(args[0], "r")
+ OPTIONS.info_dict = common.LoadInfoDict(input_zip)
+ if OPTIONS.verbose:
+ print "--- target info ---"
+ common.DumpInfoDict(OPTIONS.info_dict)
+
+ if OPTIONS.device_specific is None:
+ OPTIONS.device_specific = OPTIONS.info_dict.get("tool_extensions", None)
+ if OPTIONS.device_specific is not None:
+ OPTIONS.device_specific = os.path.normpath(OPTIONS.device_specific)
+ print "using device-specific extensions in", OPTIONS.device_specific
+
if OPTIONS.package_key:
temp_zip_file = tempfile.NamedTemporaryFile()
output_zip = zipfile.ZipFile(temp_zip_file, "w",
@@ -779,6 +749,11 @@
print "unzipping source target-files..."
OPTIONS.source_tmp = common.UnzipTemp(OPTIONS.incremental_source)
source_zip = zipfile.ZipFile(OPTIONS.incremental_source, "r")
+ OPTIONS.target_info_dict = OPTIONS.info_dict
+ OPTIONS.source_info_dict = common.LoadInfoDict(source_zip)
+ if OPTIONS.verbose:
+ print "--- source info ---"
+ common.DumpInfoDict(OPTIONS.source_info_dict)
WriteIncrementalOTAPackage(input_zip, source_zip, output_zip)
output_zip.close()