Merge "releasetools: Support generating downgrade A/B OTAs." into nyc-dev am: 5a4508bcef
am: e7847765a6
am: a7dcbfb2d8
am: 00f2147e70
Change-Id: Ic7b779c390f9611d31d644b0dbf0914521a479ca
This commit is contained in:
commit
aaabaf74d6
1 changed files with 33 additions and 41 deletions
|
@ -839,6 +839,32 @@ def AddToKnownPaths(filename, known_paths):
|
||||||
dirs.pop()
|
dirs.pop()
|
||||||
|
|
||||||
|
|
||||||
|
def HandleDowngradeMetadata(metadata):
|
||||||
|
# Only incremental OTAs are allowed to reach here.
|
||||||
|
assert OPTIONS.incremental_source is not None
|
||||||
|
|
||||||
|
post_timestamp = GetBuildProp("ro.build.date.utc", OPTIONS.target_info_dict)
|
||||||
|
pre_timestamp = GetBuildProp("ro.build.date.utc", OPTIONS.source_info_dict)
|
||||||
|
is_downgrade = long(post_timestamp) < long(pre_timestamp)
|
||||||
|
|
||||||
|
if OPTIONS.downgrade:
|
||||||
|
metadata["ota-downgrade"] = "yes"
|
||||||
|
if not is_downgrade:
|
||||||
|
raise RuntimeError("--downgrade specified but no downgrade detected: "
|
||||||
|
"pre: %s, post: %s" % (pre_timestamp, post_timestamp))
|
||||||
|
else:
|
||||||
|
if is_downgrade:
|
||||||
|
# Non-fatal here to allow generating such a package which may require
|
||||||
|
# manual work to adjust the post-timestamp. A legit use case is that we
|
||||||
|
# cut a new build C (after having A and B), but want to enfore the
|
||||||
|
# update path of A -> C -> B. Specifying --downgrade may not help since
|
||||||
|
# that would enforce a data wipe for C -> B update.
|
||||||
|
print("\nWARNING: downgrade detected: pre: %s, post: %s.\n"
|
||||||
|
"The package may not be deployed properly. "
|
||||||
|
"Try --downgrade?\n" % (pre_timestamp, post_timestamp))
|
||||||
|
metadata["post-timestamp"] = post_timestamp
|
||||||
|
|
||||||
|
|
||||||
def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
||||||
# TODO(tbao): We should factor out the common parts between
|
# TODO(tbao): We should factor out the common parts between
|
||||||
# WriteBlockIncrementalOTAPackage() and WriteIncrementalOTAPackage().
|
# WriteBlockIncrementalOTAPackage() and WriteIncrementalOTAPackage().
|
||||||
|
@ -866,26 +892,7 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
||||||
"ota-type": "BLOCK",
|
"ota-type": "BLOCK",
|
||||||
}
|
}
|
||||||
|
|
||||||
post_timestamp = GetBuildProp("ro.build.date.utc", OPTIONS.target_info_dict)
|
HandleDowngradeMetadata(metadata)
|
||||||
pre_timestamp = GetBuildProp("ro.build.date.utc", OPTIONS.source_info_dict)
|
|
||||||
is_downgrade = long(post_timestamp) < long(pre_timestamp)
|
|
||||||
|
|
||||||
if OPTIONS.downgrade:
|
|
||||||
metadata["ota-downgrade"] = "yes"
|
|
||||||
if not is_downgrade:
|
|
||||||
raise RuntimeError("--downgrade specified but no downgrade detected: "
|
|
||||||
"pre: %s, post: %s" % (pre_timestamp, post_timestamp))
|
|
||||||
else:
|
|
||||||
if is_downgrade:
|
|
||||||
# Non-fatal here to allow generating such a package which may require
|
|
||||||
# manual work to adjust the post-timestamp. A legit use case is that we
|
|
||||||
# cut a new build C (after having A and B), but want to enfore the
|
|
||||||
# update path of A -> C -> B. Specifying --downgrade may not help since
|
|
||||||
# that would enforce a data wipe for C -> B update.
|
|
||||||
print("\nWARNING: downgrade detected: pre: %s, post: %s.\n"
|
|
||||||
"The package may not be deployed properly. "
|
|
||||||
"Try --downgrade?\n" % (pre_timestamp, post_timestamp))
|
|
||||||
metadata["post-timestamp"] = post_timestamp
|
|
||||||
|
|
||||||
device_specific = common.DeviceSpecificParams(
|
device_specific = common.DeviceSpecificParams(
|
||||||
source_zip=source_zip,
|
source_zip=source_zip,
|
||||||
|
@ -1274,7 +1281,6 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file,
|
||||||
"pre-device": GetOemProperty("ro.product.device", oem_props,
|
"pre-device": GetOemProperty("ro.product.device", oem_props,
|
||||||
oem_dicts and oem_dicts[0],
|
oem_dicts and oem_dicts[0],
|
||||||
OPTIONS.info_dict),
|
OPTIONS.info_dict),
|
||||||
"post-timestamp": GetBuildProp("ro.build.date.utc", OPTIONS.info_dict),
|
|
||||||
"ota-required-cache": "0",
|
"ota-required-cache": "0",
|
||||||
"ota-type": "AB",
|
"ota-type": "AB",
|
||||||
}
|
}
|
||||||
|
@ -1286,6 +1292,11 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file,
|
||||||
metadata["pre-build-incremental"] = GetBuildProp(
|
metadata["pre-build-incremental"] = GetBuildProp(
|
||||||
"ro.build.version.incremental", OPTIONS.source_info_dict)
|
"ro.build.version.incremental", OPTIONS.source_info_dict)
|
||||||
|
|
||||||
|
HandleDowngradeMetadata(metadata)
|
||||||
|
else:
|
||||||
|
metadata["post-timestamp"] = GetBuildProp(
|
||||||
|
"ro.build.date.utc", OPTIONS.info_dict)
|
||||||
|
|
||||||
# 1. Generate payload.
|
# 1. Generate payload.
|
||||||
payload_file = common.MakeTempFile(prefix="payload-", suffix=".bin")
|
payload_file = common.MakeTempFile(prefix="payload-", suffix=".bin")
|
||||||
cmd = ["brillo_update_payload", "generate",
|
cmd = ["brillo_update_payload", "generate",
|
||||||
|
@ -1560,26 +1571,7 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
||||||
"ota-type": "FILE",
|
"ota-type": "FILE",
|
||||||
}
|
}
|
||||||
|
|
||||||
post_timestamp = GetBuildProp("ro.build.date.utc", OPTIONS.target_info_dict)
|
HandleDowngradeMetadata(metadata)
|
||||||
pre_timestamp = GetBuildProp("ro.build.date.utc", OPTIONS.source_info_dict)
|
|
||||||
is_downgrade = long(post_timestamp) < long(pre_timestamp)
|
|
||||||
|
|
||||||
if OPTIONS.downgrade:
|
|
||||||
metadata["ota-downgrade"] = "yes"
|
|
||||||
if not is_downgrade:
|
|
||||||
raise RuntimeError("--downgrade specified but no downgrade detected: "
|
|
||||||
"pre: %s, post: %s" % (pre_timestamp, post_timestamp))
|
|
||||||
else:
|
|
||||||
if is_downgrade:
|
|
||||||
# Non-fatal here to allow generating such a package which may require
|
|
||||||
# manual work to adjust the post-timestamp. A legit use case is that we
|
|
||||||
# cut a new build C (after having A and B), but want to enfore the
|
|
||||||
# update path of A -> C -> B. Specifying --downgrade may not help since
|
|
||||||
# that would enforce a data wipe for C -> B update.
|
|
||||||
print("\nWARNING: downgrade detected: pre: %s, post: %s.\n"
|
|
||||||
"The package may not be deployed properly. "
|
|
||||||
"Try --downgrade?\n" % (pre_timestamp, post_timestamp))
|
|
||||||
metadata["post-timestamp"] = post_timestamp
|
|
||||||
|
|
||||||
device_specific = common.DeviceSpecificParams(
|
device_specific = common.DeviceSpecificParams(
|
||||||
source_zip=source_zip,
|
source_zip=source_zip,
|
||||||
|
|
Loading…
Reference in a new issue