Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a95168b2 authored by Tao Bao's avatar Tao Bao Committed by android-build-merger
Browse files

Merge "releasetools: Refactor ota_from_target_files.py."

am: c1c01c65

* commit 'c1c01c65':
  releasetools: Refactor ota_from_target_files.py.
parents eb861a7b c1c01c65
Loading
Loading
Loading
Loading
+45 −45
Original line number Diff line number Diff line
@@ -1618,8 +1618,14 @@ def main(argv):
    raise common.ExternalError(
        "--- target build has specified no recovery ---")

  while True:
  # Use the default key to sign the package if not specified with package_key.
  if not OPTIONS.no_signing:
    if OPTIONS.package_key is None:
      OPTIONS.package_key = OPTIONS.info_dict.get(
          "default_system_dev_certificate",
          "build/target/product/security/testkey")

  # Set up the output zip. Create a temporary zip file if signing is needed.
  if OPTIONS.no_signing:
    if os.path.exists(args[1]):
      os.unlink(args[1])
@@ -1635,15 +1641,12 @@ def main(argv):
    print "--- can't determine the cache partition size ---"
  OPTIONS.cache_size = cache_size

  # Generate a full OTA.
  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")
      common.ZipClose(output_zip)
      break

  # Generate an incremental OTA. It will fall back to generate a full OTA on
  # failure unless no_fallback_to_full is specified.
  else:
    print "unzipping source target-files..."
    OPTIONS.source_tmp, source_zip = common.UnzipTemp(
@@ -1651,24 +1654,21 @@ def main(argv):
    OPTIONS.target_info_dict = OPTIONS.info_dict
    OPTIONS.source_info_dict = common.LoadInfoDict(source_zip,
                                                   OPTIONS.source_tmp)
      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)
        common.ZipClose(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
      WriteFullOTAPackage(input_zip, output_zip)

  common.ZipClose(output_zip)

  # Sign the generated zip package unless no_signing is specified.
  if not OPTIONS.no_signing:
    SignOutput(temp_zip_file.name, args[1])
    temp_zip_file.close()