with temporary=True) to this one."""
self.script.extend(other.script)
+ def AssertOemProperty(self, name, value):
+ """Assert that a property on the OEM paritition matches a value."""
+ if not name:
+ raise ValueError("must specify an OEM property")
+ if not value:
+ raise ValueError("must specify the OEM value")
+ cmd = ('file_getprop("/oem/oem.prop", "%s") == "%s" || '
+ 'abort("This package expects the value \\"%s\\" for '
+ '\\"%s\\" on the OEM partition; '
+ 'this has value \\"" + file_getprop("/oem/oem.prop") + "\\".");'
+ ) % (name, value, name, value)
+ self.script.append(cmd)
+
def AssertSomeFingerprint(self, *fp):
"""Assert that the current system build fingerprint is one of *fp."""
if not fp:
) % (" or ".join(fp),)
self.script.append(cmd)
- def AssertRecoveryFingerprint(self, *fp):
- """Assert that the current recovery build fingerprint is one of *fp."""
+ def AssertSomeThumbprint(self, *fp):
+ """Assert that the current system build thumbprint is one of *fp."""
if not fp:
- raise ValueError("must specify some fingerprints")
+ raise ValueError("must specify some thumbprints")
cmd = (
- ' ||\n '.join([('getprop("ro.build.fingerprint") == "%s"')
+ ' ||\n '.join([('file_getprop("/system/build.prop", '
+ '"ro.build.thumbprint") == "%s"')
% i for i in fp]) +
- ' ||\n abort("Package expects build fingerprint of %s; this '
- 'device has " + getprop("ro.build.fingerprint") + ".");'
+ ' ||\n abort("Package expects build thumbprint of %s; this '
+ 'device has " + getprop("ro.build.thumbprint") + ".");'
) % (" or ".join(fp),)
self.script.append(cmd)
Generate an incremental OTA using the given target-files zip as
the starting build.
+ -o (--oem_settings) <file>
+ Use the file to specify the expected OEM-specific properties
+ on the OEM partition of the intended device.
+
-w (--wipe_user_data)
Generate an OTA package that will wipe the user data partition
when installed.
OPTIONS.no_signing = False
OPTIONS.block_based = False
OPTIONS.updater_binary = None
+OPTIONS.oem_source = None
def MostPopularKey(d, default):
"""Given a dict, return the key corresponding to the largest
whole_file=True)
-def AppendAssertions(script, info_dict):
- device = GetBuildProp("ro.product.device", info_dict)
- script.AssertDevice(device)
+def AppendAssertions(script, info_dict, oem_dict):
+ oem_props = info_dict.get("oem_fingerprint_properties")
+ if oem_props is None:
+ device = GetBuildProp("ro.product.device", info_dict)
+ script.AssertDevice(device)
+ else:
+ if oem_dict is None:
+ raise common.ExternalError("No OEM file provided to answer expected assertions")
+ for prop in oem_props.split():
+ if oem_dict.get(prop) is None:
+ raise common.ExternalError("The OEM file is missing the property %s" % prop)
+ script.AssertOemProperty(prop, oem_dict.get(prop))
def HasRecoveryPatch(target_files_zip):
except KeyError:
return False
+def GetOemProperty(name, oem_props, oem_dict, info_dict):
+ if oem_props is not None and name in oem_props:
+ return oem_dict[name]
+ return GetBuildProp(name, info_dict)
+
+
+def CalculateFingerprint(oem_props, oem_dict, info_dict):
+ if oem_props is None:
+ return GetBuildProp("ro.build.fingerprint", info_dict)
+ return "%s/%s/%s:%s" % (
+ GetOemProperty("ro.product.brand", oem_props, oem_dict, info_dict),
+ GetOemProperty("ro.product.name", oem_props, oem_dict, info_dict),
+ GetOemProperty("ro.product.device", oem_props, oem_dict, info_dict),
+ GetBuildProp("ro.build.thumbprint", info_dict))
def WriteFullOTAPackage(input_zip, output_zip):
# TODO: how to determine this? We don't know what version it will
# change very often.
script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict)
- metadata = {"post-build": GetBuildProp("ro.build.fingerprint",
- OPTIONS.info_dict),
- "pre-device": GetBuildProp("ro.product.device",
+ oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
+ oem_dict = None
+ if oem_props is not None:
+ if OPTIONS.oem_source is None:
+ raise common.ExternalError("OEM source required for this build")
+ script.Mount("/oem")
+ oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines())
+
+ metadata = {"post-build": CalculateFingerprint(
+ oem_props, oem_dict, OPTIONS.info_dict),
+ "pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
OPTIONS.info_dict),
"post-timestamp": GetBuildProp("ro.build.date.utc",
OPTIONS.info_dict),
ts_text = GetBuildProp("ro.build.date", OPTIONS.info_dict)
script.AssertOlderBuild(ts, ts_text)
- AppendAssertions(script, OPTIONS.info_dict)
+ AppendAssertions(script, OPTIONS.info_dict, oem_dict)
device_specific.FullOTA_Assertions()
# Two-step package strategy (in chronological order, which is *not*
script = edify_generator.EdifyGenerator(source_version,
OPTIONS.target_info_dict)
- metadata = {"pre-device": GetBuildProp("ro.product.device",
+ oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
+ oem_dict = None
+ if oem_props is not None:
+ if OPTIONS.oem_source is None:
+ raise common.ExternalError("OEM source required for this build")
+ script.Mount("/oem")
+ oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines())
+
+ metadata = {"pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
OPTIONS.source_info_dict),
"post-timestamp": GetBuildProp("ro.build.date.utc",
OPTIONS.target_info_dict),
patch_list.append((tf, sf, tf.size, common.sha1(d).hexdigest()))
largest_source_size = max(largest_source_size, sf.size)
- source_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.source_info_dict)
- target_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.target_info_dict)
+ script.Mount("/system")
+
+ target_fp = CalculateFingerprint(oem_props, oem_dict, OPTIONS.target_info_dict)
+ source_fp = CalculateFingerprint(oem_props, oem_dict, OPTIONS.source_info_dict)
+
+ if oem_props is None:
+ script.AssertSomeFingerprint(source_fp, target_fp)
+ else:
+ script.AssertSomeThumbprint(
+ GetBuildProp("ro.build.thumbprint", OPTIONS.target_info_dict),
+ GetBuildProp("ro.build.thumbprint", OPTIONS.source_info_dict))
+
metadata["pre-build"] = source_fp
metadata["post-build"] = target_fp
- script.Mount("/system")
- script.AssertSomeFingerprint(source_fp, target_fp)
-
source_boot = common.GetBootableImage(
"/tmp/boot.img", "boot.img", OPTIONS.source_tmp, "BOOT",
OPTIONS.source_info_dict)
# 0.1 for unpacking verbatim files, symlinking, and doing the
# device-specific commands.
- AppendAssertions(script, OPTIONS.target_info_dict)
+ AppendAssertions(script, OPTIONS.target_info_dict, oem_dict)
device_specific.IncrementalOTA_Assertions()
# Two-step incremental package strategy (in chronological order,
OPTIONS.wipe_user_data = True
elif o in ("-n", "--no_prereq"):
OPTIONS.omit_prereq = True
+ elif o in ("-o", "--oem_settings"):
+ OPTIONS.oem_source = a
elif o in ("-e", "--extra_script"):
OPTIONS.extra_script = a
elif o in ("-a", "--aslr_mode"):
return True
args = common.ParseOptions(argv, __doc__,
- extra_opts="b:k:i:d:wne:a:2",
+ extra_opts="b:k:i:d:wne:a:2o:",
extra_long_opts=["board_config=",
"package_key=",
"incremental_from=",
"no_signing",
"block",
"binary=",
+ "oem_settings=",
],
extra_option_handler=option_handler)