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

Commit 3b64ce14 authored by Daniel Norman's avatar Daniel Norman
Browse files

Adds --output-ota flag to enable building the OTA package.

This simplifies the use case for mixed build users. Instead of having to
remember to call ota_from_target_files.py after this script, they can
use this flag to automatically create the OTA package.

Bug: 129976345
Test: Ran merge_target_files.py using --output-ota and inspected the
resulting zip.

Change-Id: Icc95943c24b8f83b3221e845a7d69a34c1edb4fc
parent f0318255
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@ Usage: merge_target_files.py [args]
      file patterns to copy into the --output-dir. Required if providing
      the --output-dir flag.

  --output-ota output-ota-package
      The output ota package. This is a zip archive. Use of this flag may
      require passing the --path common flag; see common.py.

  --output-super-empty output-super-empty-image
      If provided, creates a super_empty.img file from the merged target
      files package and saves it at this path.
@@ -78,6 +82,7 @@ import zipfile
import add_img_to_target_files
import build_super_image
import common
import ota_from_target_files

logger = logging.getLogger(__name__)
OPTIONS = common.OPTIONS
@@ -90,6 +95,7 @@ OPTIONS.other_item_list = None
OPTIONS.output_target_files = None
OPTIONS.output_dir = None
OPTIONS.output_item_list = None
OPTIONS.output_ota = None
OPTIONS.output_super_empty = None
OPTIONS.rebuild_recovery = False
OPTIONS.keep_tmp = False
@@ -590,6 +596,7 @@ def merge_target_files(
    output_target_files,
    output_dir,
    output_item_list,
    output_ota,
    output_super_empty,
    rebuild_recovery):
  """Merge two target files packages together.
@@ -625,6 +632,8 @@ def merge_target_files(
    output_target_files: The name of the output zip archive target files
    package created by merging system and other.

    output_ota: The name of the output zip archive ota package.

    output_super_empty: If provided, creates a super_empty.img file from the
    merged target files package and saves it at this path.

@@ -770,6 +779,15 @@ def merge_target_files(
  logger.info('creating %s', output_target_files)
  common.RunAndWait(command, verbose=True)

  # Create the OTA package from the merged target files package.

  if output_ota:
    ota_from_target_files_args = [
        output_zip,
        output_ota,
    ]
    ota_from_target_files.main(ota_from_target_files_args)


def call_func_with_temp_dir(func, keep_tmp):
  """Manage the creation and cleanup of the temporary directory.
@@ -827,6 +845,8 @@ def main():
      OPTIONS.output_dir = a
    elif o == '--output-item-list':
      OPTIONS.output_item_list = a
    elif o == '--output-ota':
      OPTIONS.output_ota = a
    elif o == '--output-super-empty':
      OPTIONS.output_super_empty = a
    elif o == '--rebuild_recovery':
@@ -848,6 +868,7 @@ def main():
          'output-target-files=',
          'output-dir=',
          'output-item-list=',
          'output-ota=',
          'output-super-empty=',
          'rebuild_recovery',
          'keep-tmp',
@@ -901,6 +922,7 @@ def main():
          output_target_files=OPTIONS.output_target_files,
          output_dir=OPTIONS.output_dir,
          output_item_list=output_item_list,
          output_ota=OPTIONS.output_ota,
          output_super_empty=OPTIONS.output_super_empty,
          rebuild_recovery=OPTIONS.rebuild_recovery),
      OPTIONS.keep_tmp)