load SYSTEM/build.prop into the info_dict
Change-Id: Ic747106ba11773ffc9c2eebc163cfd22b1d7a4d5
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index b8fe68c..3cd271a 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -303,8 +303,8 @@
whole_file=True)
-def AppendAssertions(script, input_zip):
- device = GetBuildProp("ro.product.device", input_zip)
+def AppendAssertions(script, info_dict):
+ device = GetBuildProp("ro.product.device", info_dict)
script.AssertDevice(device)
@@ -358,9 +358,12 @@
# change very often.
script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict)
- metadata = {"post-build": GetBuildProp("ro.build.fingerprint", input_zip),
- "pre-device": GetBuildProp("ro.product.device", input_zip),
- "post-timestamp": GetBuildProp("ro.build.date.utc", input_zip),
+ metadata = {"post-build": GetBuildProp("ro.build.fingerprint",
+ OPTIONS.info_dict),
+ "pre-device": GetBuildProp("ro.product.device",
+ OPTIONS.info_dict),
+ "post-timestamp": GetBuildProp("ro.build.date.utc",
+ OPTIONS.info_dict),
}
device_specific = common.DeviceSpecificParams(
@@ -373,10 +376,10 @@
info_dict=OPTIONS.info_dict)
if not OPTIONS.omit_prereq:
- ts = GetBuildProp("ro.build.date.utc", input_zip)
+ ts = GetBuildProp("ro.build.date.utc", OPTIONS.info_dict)
script.AssertOlderBuild(ts)
- AppendAssertions(script, input_zip)
+ AppendAssertions(script, OPTIONS.info_dict)
device_specific.FullOTA_Assertions()
device_specific.FullOTA_InstallBegin()
@@ -446,16 +449,12 @@
return out
-def GetBuildProp(property, z):
- """Return the fingerprint of the build of a given target-files
- ZipFile object."""
- bp = z.read("SYSTEM/build.prop")
- if not property:
- return bp
- m = re.search(re.escape(property) + r"=(.*)\n", bp)
- if not m:
+def GetBuildProp(prop, info_dict):
+ """Return the fingerprint of the build of a given target-files info_dict."""
+ try:
+ return info_dict.get("build.prop", {})[prop]
+ except KeyError:
raise common.ExternalError("couldn't find %s in build.prop" % (property,))
- return m.group(1).strip()
def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
@@ -465,10 +464,13 @@
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)
- metadata = {"pre-device": GetBuildProp("ro.product.device", source_zip),
- "post-timestamp": GetBuildProp("ro.build.date.utc", target_zip),
+ metadata = {"pre-device": GetBuildProp("ro.product.device",
+ OPTIONS.source_info_dict),
+ "post-timestamp": GetBuildProp("ro.build.date.utc",
+ OPTIONS.target_info_dict),
}
device_specific = common.DeviceSpecificParams(
@@ -522,8 +524,8 @@
patch_list.append((tf.name, tf, sf, tf.size, common.sha1(d).hexdigest()))
largest_source_size = max(largest_source_size, sf.size)
- source_fp = GetBuildProp("ro.build.fingerprint", source_zip)
- target_fp = GetBuildProp("ro.build.fingerprint", target_zip)
+ source_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.source_info_dict)
+ target_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.target_info_dict)
metadata["pre-build"] = source_fp
metadata["post-build"] = target_fp
@@ -550,7 +552,7 @@
# 0.1 for unpacking verbatim files, symlinking, and doing the
# device-specific commands.
- AppendAssertions(script, target_zip)
+ AppendAssertions(script, OPTIONS.target_info_dict)
device_specific.IncrementalOTA_Assertions()
script.Print("Verifying current system...")