Support regenerating partition table with bpttool in sign_target_files_apks

For Android Things targets (or any other target which has
BOARD_BPT_INPUT_FILES defined), add_img_to_target_files will generate a
partition-table.img using bpttool. It also adds the final combined .bpt
definition file into target-files in IMAGES/partition-table.bpt.

When we're signing using sign_target_files_apks, add_img_to_target_files
needs to regenerate the partition table, but META/misc_info.txt still
contains the original list of bpt input files from the build that aren't
available. This change extracts the final bpt from the input
target-files, adds it to META/ in the output target-files, and then
updates the board_bpt_input_files property to point to it.

Bug: 72837107
Test: Local sign_target_files_apks run of locally built target-files
Change-Id: Id79125208f31c78b1ac2079172f9c91a9203849b
This commit is contained in:
Bryan Henry 2018-04-14 23:10:32 -07:00
parent 69d3feb23a
commit 2a40cc6996
3 changed files with 19 additions and 0 deletions

View File

@ -2352,6 +2352,7 @@ OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
$(HOST_OUT_EXECUTABLES)/delta_generator \
$(AVBTOOL) \
$(BLK_ALLOC_TO_BASE_FS) \
$(BPTTOOL) \
$(BROTLI) \
$(BUILD_VERITY_METADATA) \
$(BUILD_VERITY_TREE)

View File

@ -222,6 +222,15 @@ def LoadInfoDict(input_file, input_dir=None):
vendor_base_fs_file,))
del d["vendor_base_fs_file"]
# If board_bpt_input_files property is defined then bpttool is being used to
# generate the partition table. When signing target-files, the combined
# partition table definition is copied into META/partition-table.bpt since
# the original input files aren't available.
if "board_bpt_input_files" in d:
board_bpt_input_files = os.path.join(input_dir, "META", "partition-table.bpt")
if os.path.exists(board_bpt_input_files):
d["board_bpt_input_files"] = board_bpt_input_files
def makeint(key):
if key in d:
d[key] = int(d[key], 0)

View File

@ -248,6 +248,15 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info,
system_root_image = misc_info.get("system_root_image") == "true"
for info in input_tf_zip.infolist():
# If it exists, copy bpt partition table definition into META/ to use when
# recreating partition table.
if (info.filename == "IMAGES/partition-table.bpt"):
data = input_tf_zip.read(info.filename)
out_info = copy.copy(info)
out_info.filename = "META/partition-table.bpt"
common.ZipWriteStr(output_tf_zip, out_info, data)
# Skip all other files in IMAGES/
if info.filename.startswith("IMAGES/"):
continue