diff options
author | Doug Zongker <dougz@google.com> | 2014-08-04 16:06:43 -0700 |
---|---|---|
committer | Doug Zongker <dougz@google.com> | 2014-08-04 16:06:43 -0700 |
commit | 62d4f18a30aeade677ca814cf6f2aa329cf5066d (patch) | |
tree | 8c9b1a23d2f79f30f8c7567d1510c689fd8e4b80 /tools/releasetools/ota_from_target_files | |
parent | 4dfb5580c2e33eebda24e377c5ce2a73a93d4258 (diff) | |
download | build-62d4f18a30aeade677ca814cf6f2aa329cf5066d.zip build-62d4f18a30aeade677ca814cf6f2aa329cf5066d.tar.gz build-62d4f18a30aeade677ca814cf6f2aa329cf5066d.tar.bz2 |
fall back to generating full OTA if incremental fails
Block incremental OTA generation can currently fail on some
target-files pairs. Fall back to generating a full OTA so that the
script succeeds rather than failing.
Change-Id: Ide70395d1f3759aa2076bd173836f6a5e5b397c0
Diffstat (limited to 'tools/releasetools/ota_from_target_files')
-rwxr-xr-x | tools/releasetools/ota_from_target_files | 74 |
1 files changed, 45 insertions, 29 deletions
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index 5f2354c..b281de4 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -118,6 +118,7 @@ OPTIONS.no_signing = False OPTIONS.block_based = False OPTIONS.updater_binary = None OPTIONS.oem_source = None +OPTIONS.fallback_to_full = True def MostPopularKey(d, default): """Given a dict, return the key corresponding to the largest @@ -1439,6 +1440,8 @@ def main(argv): OPTIONS.block_based = True elif o in ("-b", "--binary"): OPTIONS.updater_binary = a + elif o in ("--no_fallback_to_full",): + OPTIONS.fallback_to_full = False else: return False return True @@ -1458,6 +1461,7 @@ def main(argv): "block", "binary=", "oem_settings=", + "no_fallback_to_full", ], extra_option_handler=option_handler) @@ -1504,35 +1508,47 @@ def main(argv): if OPTIONS.device_specific is not None: OPTIONS.device_specific = os.path.abspath(OPTIONS.device_specific) - if OPTIONS.no_signing: - output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED) - else: - temp_zip_file = tempfile.NamedTemporaryFile() - output_zip = zipfile.ZipFile(temp_zip_file, "w", - compression=zipfile.ZIP_DEFLATED) - - if OPTIONS.incremental_source is None: - WriteFullOTAPackage(input_zip, output_zip) - if OPTIONS.package_key is None: - OPTIONS.package_key = OPTIONS.info_dict.get( - "default_system_dev_certificate", - "build/target/product/security/testkey") - else: - print "unzipping source target-files..." - OPTIONS.source_tmp, source_zip = common.UnzipTemp(OPTIONS.incremental_source) - OPTIONS.target_info_dict = OPTIONS.info_dict - OPTIONS.source_info_dict = common.LoadInfoDict(source_zip) - if "selinux_fc" in OPTIONS.source_info_dict: - OPTIONS.source_info_dict["selinux_fc"] = os.path.join(OPTIONS.source_tmp, "BOOT", "RAMDISK", - "file_contexts") - if OPTIONS.package_key is None: - OPTIONS.package_key = OPTIONS.source_info_dict.get( - "default_system_dev_certificate", - "build/target/product/security/testkey") - if OPTIONS.verbose: - print "--- source info ---" - common.DumpInfoDict(OPTIONS.source_info_dict) - WriteIncrementalOTAPackage(input_zip, source_zip, output_zip) + while True: + + if OPTIONS.no_signing: + if os.path.exists(args[1]): os.unlink(args[1]) + output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED) + else: + temp_zip_file = tempfile.NamedTemporaryFile() + output_zip = zipfile.ZipFile(temp_zip_file, "w", + compression=zipfile.ZIP_DEFLATED) + + if OPTIONS.incremental_source is None: + WriteFullOTAPackage(input_zip, output_zip) + if OPTIONS.package_key is None: + OPTIONS.package_key = OPTIONS.info_dict.get( + "default_system_dev_certificate", + "build/target/product/security/testkey") + break + + else: + print "unzipping source target-files..." + OPTIONS.source_tmp, source_zip = common.UnzipTemp(OPTIONS.incremental_source) + OPTIONS.target_info_dict = OPTIONS.info_dict + OPTIONS.source_info_dict = common.LoadInfoDict(source_zip) + if "selinux_fc" in OPTIONS.source_info_dict: + OPTIONS.source_info_dict["selinux_fc"] = os.path.join(OPTIONS.source_tmp, "BOOT", "RAMDISK", + "file_contexts") + if OPTIONS.package_key is None: + OPTIONS.package_key = OPTIONS.source_info_dict.get( + "default_system_dev_certificate", + "build/target/product/security/testkey") + if OPTIONS.verbose: + print "--- source info ---" + common.DumpInfoDict(OPTIONS.source_info_dict) + try: + WriteIncrementalOTAPackage(input_zip, source_zip, output_zip) + break + except ValueError: + if not OPTIONS.fallback_to_full: raise + print "--- failed to build incremental; falling back to full ---" + OPTIONS.incremental_source = None + output_zip.close() output_zip.close() |