Exemplo n.º 1
0
def WriteSuperImages(input_tmp, output_zip):
  """
  Write super images from the unzipped input and write to output_zip. This is
  only done if super_image_in_update_package is set to "true".

  - For retrofit dynamic partition devices, copy split super images from target
    files package.
  - For devices launched with dynamic partitions, build super image from target
    files package.

  Args:
    input_tmp: path to the unzipped input.
    output_zip: a ZipFile instance to write images to.
  """
  if not OPTIONS.build_super or not OPTIONS.put_super:
    return

  if OPTIONS.retrofit_dap:
    # retrofit devices already have split super images under OTA/
    images_path = os.path.join(input_tmp, "OTA")
    for device in OPTIONS.super_device_list:
      image = "super_%s.img" % device
      image_path = os.path.join(images_path, image)
      assert os.path.exists(image_path)
      logger.info("writing %s to archive...", os.path.join("OTA", image))
      common.ZipWrite(output_zip, image_path, image)
  else:
    # super image for non-retrofit devices aren't in target files package,
    # so build it.
    super_file = common.MakeTempFile("super_", ".img")
    logger.info("building super image %s...", super_file)
    BuildSuperImage(input_tmp, super_file)
    logger.info("writing super.img to archive...")
    common.ZipWrite(output_zip, super_file, "super.img")
Exemplo n.º 2
0
def RebuildAndWriteSuperImages(input_file, output_file):
    """Builds and writes super images to the output file."""
    logger.info('Building super image...')

    # We need files under IMAGES/, OTA/, META/ for img_from_target_files.py.
    # However, common.LoadInfoDict() may read additional files under BOOT/,
    # RECOVERY/ and ROOT/. So unzip everything from the target_files.zip.
    input_tmp = common.UnzipTemp(input_file)

    super_file = common.MakeTempFile('super_', '.img')
    BuildSuperImage(input_tmp, super_file)

    logger.info('Writing super.img to archive...')
    with zipfile.ZipFile(output_file,
                         'a',
                         compression=zipfile.ZIP_DEFLATED,
                         allowZip64=True) as output_zip:
        common.ZipWrite(output_zip, super_file, 'super.img')