Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright (C) 2019 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 6 | # use this file except in compliance with the License. You may obtain a copy of |
| 7 | # the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations under |
| 15 | # the License. |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 16 | # |
| 17 | """This script merges two partial target files packages. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 18 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 19 | One package contains framework files, and the other contains vendor files. |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 20 | It produces a complete target files package that can be used to generate an |
| 21 | OTA package. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 22 | |
| 23 | Usage: merge_target_files.py [args] |
| 24 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 25 | --framework-target-files framework-target-files-zip-archive |
| 26 | The input target files package containing framework bits. This is a zip |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 27 | archive. |
| 28 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 29 | --framework-item-list framework-item-list-file |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 30 | The optional path to a newline-separated config file that replaces the |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 31 | contents of DEFAULT_FRAMEWORK_ITEM_LIST if provided. |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 32 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 33 | --framework-misc-info-keys framework-misc-info-keys-file |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 34 | The optional path to a newline-separated config file that replaces the |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 35 | contents of DEFAULT_FRAMEWORK_MISC_INFO_KEYS if provided. |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 36 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 37 | --vendor-target-files vendor-target-files-zip-archive |
| 38 | The input target files package containing vendor bits. This is a zip |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 39 | archive. |
| 40 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 41 | --vendor-item-list vendor-item-list-file |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 42 | The optional path to a newline-separated config file that replaces the |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 43 | contents of DEFAULT_VENDOR_ITEM_LIST if provided. |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 44 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 45 | --output-target-files output-target-files-package |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 46 | If provided, the output merged target files package. Also a zip archive. |
| 47 | |
| 48 | --output-dir output-directory |
| 49 | If provided, the destination directory for saving merged files. Requires |
| 50 | the --output-item-list flag. |
| 51 | Can be provided alongside --output-target-files, or by itself. |
| 52 | |
| 53 | --output-item-list output-item-list-file. |
| 54 | The optional path to a newline-separated config file that specifies the |
| 55 | file patterns to copy into the --output-dir. Required if providing |
| 56 | the --output-dir flag. |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 57 | |
Daniel Norman | 3b64ce1 | 2019-04-16 16:11:35 -0700 | [diff] [blame] | 58 | --output-ota output-ota-package |
| 59 | The output ota package. This is a zip archive. Use of this flag may |
| 60 | require passing the --path common flag; see common.py. |
| 61 | |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 62 | --output-img output-img-package |
| 63 | The output img package, suitable for use with 'fastboot update'. Use of |
| 64 | this flag may require passing the --path common flag; see common.py. |
| 65 | |
Daniel Norman | f031825 | 2019-04-15 11:34:56 -0700 | [diff] [blame] | 66 | --output-super-empty output-super-empty-image |
| 67 | If provided, creates a super_empty.img file from the merged target |
| 68 | files package and saves it at this path. |
| 69 | |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 70 | --rebuild_recovery |
Bill Peckham | e868aec | 2019-09-17 17:06:47 -0700 | [diff] [blame] | 71 | Deprecated; does nothing. |
Bill Peckham | 364c1cc | 2019-03-29 18:27:23 -0700 | [diff] [blame] | 72 | |
| 73 | --keep-tmp |
| 74 | Keep tempoary files for debugging purposes. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 75 | """ |
| 76 | |
| 77 | from __future__ import print_function |
| 78 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 79 | import fnmatch |
| 80 | import logging |
| 81 | import os |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 82 | import shutil |
Bill Peckham | 540d91a | 2019-04-25 14:18:16 -0700 | [diff] [blame] | 83 | import subprocess |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 84 | import sys |
| 85 | import zipfile |
| 86 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 87 | import add_img_to_target_files |
Daniel Norman | f031825 | 2019-04-15 11:34:56 -0700 | [diff] [blame] | 88 | import build_super_image |
Yifan Hong | ade0d3f | 2019-08-21 16:37:11 -0700 | [diff] [blame] | 89 | import check_target_files_vintf |
Daniel Norman | f031825 | 2019-04-15 11:34:56 -0700 | [diff] [blame] | 90 | import common |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 91 | import img_from_target_files |
Daniel Norman | 3b64ce1 | 2019-04-16 16:11:35 -0700 | [diff] [blame] | 92 | import ota_from_target_files |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 93 | |
| 94 | logger = logging.getLogger(__name__) |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 95 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 96 | OPTIONS = common.OPTIONS |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 97 | OPTIONS.framework_target_files = None |
| 98 | OPTIONS.framework_item_list = None |
| 99 | OPTIONS.framework_misc_info_keys = None |
| 100 | OPTIONS.vendor_target_files = None |
| 101 | OPTIONS.vendor_item_list = None |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 102 | OPTIONS.output_target_files = None |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 103 | OPTIONS.output_dir = None |
| 104 | OPTIONS.output_item_list = None |
Daniel Norman | 3b64ce1 | 2019-04-16 16:11:35 -0700 | [diff] [blame] | 105 | OPTIONS.output_ota = None |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 106 | OPTIONS.output_img = None |
Daniel Norman | f031825 | 2019-04-15 11:34:56 -0700 | [diff] [blame] | 107 | OPTIONS.output_super_empty = None |
Bill Peckham | e868aec | 2019-09-17 17:06:47 -0700 | [diff] [blame] | 108 | # TODO(b/132730255): Remove this option. |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 109 | OPTIONS.rebuild_recovery = False |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 110 | OPTIONS.keep_tmp = False |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 111 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 112 | # DEFAULT_FRAMEWORK_ITEM_LIST is a list of items to extract from the partial |
| 113 | # framework target files package as is, meaning these items will land in the |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 114 | # output target files package exactly as they appear in the input partial |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 115 | # framework target files package. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 116 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 117 | DEFAULT_FRAMEWORK_ITEM_LIST = ( |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 118 | 'META/apkcerts.txt', |
| 119 | 'META/filesystem_config.txt', |
| 120 | 'META/root_filesystem_config.txt', |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 121 | 'META/update_engine_config.txt', |
| 122 | 'PRODUCT/*', |
| 123 | 'ROOT/*', |
| 124 | 'SYSTEM/*', |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 125 | ) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 126 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 127 | # FRAMEWORK_EXTRACT_SPECIAL_ITEM_LIST is a list of items to extract from the |
| 128 | # partial framework target files package that need some special processing, such |
| 129 | # as some sort of combination with items from the partial vendor target files |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 130 | # package. |
| 131 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 132 | FRAMEWORK_EXTRACT_SPECIAL_ITEM_LIST = ('META/*',) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 133 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 134 | # DEFAULT_FRAMEWORK_MISC_INFO_KEYS is a list of keys to obtain from the |
| 135 | # framework instance of META/misc_info.txt. The remaining keys from the |
| 136 | # vendor instance. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 137 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 138 | DEFAULT_FRAMEWORK_MISC_INFO_KEYS = ( |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 139 | 'avb_system_hashtree_enable', |
| 140 | 'avb_system_add_hashtree_footer_args', |
| 141 | 'avb_system_key_path', |
| 142 | 'avb_system_algorithm', |
| 143 | 'avb_system_rollback_index_location', |
| 144 | 'avb_product_hashtree_enable', |
| 145 | 'avb_product_add_hashtree_footer_args', |
Justin Yun | 6151e3f | 2019-06-25 15:58:13 +0900 | [diff] [blame] | 146 | 'avb_system_ext_hashtree_enable', |
| 147 | 'avb_system_ext_add_hashtree_footer_args', |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 148 | 'system_root_image', |
| 149 | 'root_dir', |
| 150 | 'ab_update', |
| 151 | 'default_system_dev_certificate', |
| 152 | 'system_size', |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 153 | ) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 154 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 155 | # DEFAULT_VENDOR_ITEM_LIST is a list of items to extract from the partial |
| 156 | # vendor target files package as is, meaning these items will land in the output |
| 157 | # target files package exactly as they appear in the input partial vendor target |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 158 | # files package. |
| 159 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 160 | DEFAULT_VENDOR_ITEM_LIST = ( |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 161 | 'META/boot_filesystem_config.txt', |
| 162 | 'META/otakeys.txt', |
| 163 | 'META/releasetools.py', |
| 164 | 'META/vendor_filesystem_config.txt', |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 165 | 'BOOT/*', |
| 166 | 'DATA/*', |
| 167 | 'ODM/*', |
| 168 | 'OTA/android-info.txt', |
| 169 | 'PREBUILT_IMAGES/*', |
| 170 | 'RADIO/*', |
| 171 | 'VENDOR/*', |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 172 | ) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 173 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 174 | # VENDOR_EXTRACT_SPECIAL_ITEM_LIST is a list of items to extract from the |
| 175 | # partial vendor target files package that need some special processing, such as |
| 176 | # some sort of combination with items from the partial framework target files |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 177 | # package. |
| 178 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 179 | VENDOR_EXTRACT_SPECIAL_ITEM_LIST = ('META/*',) |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 180 | |
| 181 | # The merge config lists should not attempt to extract items from both |
| 182 | # builds for any of the following partitions. The partitions in |
| 183 | # SINGLE_BUILD_PARTITIONS should come entirely from a single build (either |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 184 | # framework or vendor, but not both). |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 185 | |
| 186 | SINGLE_BUILD_PARTITIONS = ( |
| 187 | 'BOOT/', |
| 188 | 'DATA/', |
| 189 | 'ODM/', |
| 190 | 'PRODUCT/', |
Justin Yun | 6151e3f | 2019-06-25 15:58:13 +0900 | [diff] [blame] | 191 | 'SYSTEM_EXT/', |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 192 | 'RADIO/', |
| 193 | 'RECOVERY/', |
| 194 | 'ROOT/', |
| 195 | 'SYSTEM/', |
| 196 | 'SYSTEM_OTHER/', |
| 197 | 'VENDOR/', |
| 198 | ) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 199 | |
| 200 | |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 201 | def write_sorted_data(data, path): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 202 | """Writes the sorted contents of either a list or dict to file. |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 203 | |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 204 | This function sorts the contents of the list or dict and then writes the |
| 205 | resulting sorted contents to a file specified by path. |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 206 | |
| 207 | Args: |
| 208 | data: The list or dict to sort and write. |
| 209 | path: Path to the file to write the sorted values to. The file at path will |
| 210 | be overridden if it exists. |
| 211 | """ |
| 212 | with open(path, 'w') as output: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 213 | for entry in sorted(data): |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 214 | out_str = '{}={}\n'.format(entry, data[entry]) if isinstance( |
| 215 | data, dict) else '{}\n'.format(entry) |
| 216 | output.write(out_str) |
| 217 | |
| 218 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 219 | def extract_items(target_files, target_files_temp_dir, extract_item_list): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 220 | """Extracts items from target files to temporary directory. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 221 | |
| 222 | This function extracts from the specified target files zip archive into the |
| 223 | specified temporary directory, the items specified in the extract item list. |
| 224 | |
| 225 | Args: |
| 226 | target_files: The target files zip archive from which to extract items. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 227 | target_files_temp_dir: The temporary directory where the extracted items |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 228 | will land. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 229 | extract_item_list: A list of items to extract. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 230 | """ |
| 231 | |
| 232 | logger.info('extracting from %s', target_files) |
| 233 | |
| 234 | # Filter the extract_item_list to remove any items that do not exist in the |
| 235 | # zip file. Otherwise, the extraction step will fail. |
| 236 | |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 237 | with zipfile.ZipFile(target_files, allowZip64=True) as target_files_zipfile: |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 238 | target_files_namelist = target_files_zipfile.namelist() |
| 239 | |
| 240 | filtered_extract_item_list = [] |
| 241 | for pattern in extract_item_list: |
| 242 | matching_namelist = fnmatch.filter(target_files_namelist, pattern) |
| 243 | if not matching_namelist: |
| 244 | logger.warning('no match for %s', pattern) |
| 245 | else: |
| 246 | filtered_extract_item_list.append(pattern) |
| 247 | |
Bill Peckham | 8ff3fbd | 2019-02-22 10:57:43 -0800 | [diff] [blame] | 248 | # Extract from target_files into target_files_temp_dir the |
| 249 | # filtered_extract_item_list. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 250 | |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 251 | common.UnzipToDir(target_files, target_files_temp_dir, |
| 252 | filtered_extract_item_list) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 253 | |
| 254 | |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 255 | def copy_items(from_dir, to_dir, patterns): |
| 256 | """Similar to extract_items() except uses an input dir instead of zip.""" |
| 257 | file_paths = [] |
| 258 | for dirpath, _, filenames in os.walk(from_dir): |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 259 | file_paths.extend( |
| 260 | os.path.relpath(path=os.path.join(dirpath, filename), start=from_dir) |
| 261 | for filename in filenames) |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 262 | |
| 263 | filtered_file_paths = set() |
| 264 | for pattern in patterns: |
| 265 | filtered_file_paths.update(fnmatch.filter(file_paths, pattern)) |
| 266 | |
| 267 | for file_path in filtered_file_paths: |
| 268 | original_file_path = os.path.join(from_dir, file_path) |
| 269 | copied_file_path = os.path.join(to_dir, file_path) |
| 270 | copied_file_dir = os.path.dirname(copied_file_path) |
| 271 | if not os.path.exists(copied_file_dir): |
| 272 | os.makedirs(copied_file_dir) |
| 273 | if os.path.islink(original_file_path): |
| 274 | os.symlink(os.readlink(original_file_path), copied_file_path) |
| 275 | else: |
| 276 | shutil.copyfile(original_file_path, copied_file_path) |
| 277 | |
| 278 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 279 | def validate_config_lists(framework_item_list, framework_misc_info_keys, |
| 280 | vendor_item_list): |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 281 | """Performs validations on the merge config lists. |
| 282 | |
| 283 | Args: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 284 | framework_item_list: The list of items to extract from the partial framework |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 285 | target files package as is. |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 286 | framework_misc_info_keys: A list of keys to obtain from the framework |
| 287 | instance of META/misc_info.txt. The remaining keys from the vendor |
| 288 | instance. |
| 289 | vendor_item_list: The list of items to extract from the partial vendor |
| 290 | target files package as is. |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 291 | |
| 292 | Returns: |
| 293 | False if a validation fails, otherwise true. |
| 294 | """ |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 295 | has_error = False |
| 296 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 297 | default_combined_item_set = set(DEFAULT_FRAMEWORK_ITEM_LIST) |
| 298 | default_combined_item_set.update(DEFAULT_VENDOR_ITEM_LIST) |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 299 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 300 | combined_item_set = set(framework_item_list) |
| 301 | combined_item_set.update(vendor_item_list) |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 302 | |
| 303 | # Check that the merge config lists are not missing any item specified |
| 304 | # by the default config lists. |
| 305 | difference = default_combined_item_set.difference(combined_item_set) |
| 306 | if difference: |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 307 | logger.error('Missing merge config items: %s', list(difference)) |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 308 | logger.error('Please ensure missing items are in either the ' |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 309 | 'framework-item-list or vendor-item-list files provided to ' |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 310 | 'this script.') |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 311 | has_error = True |
| 312 | |
| 313 | for partition in SINGLE_BUILD_PARTITIONS: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 314 | in_framework = any( |
| 315 | item.startswith(partition) for item in framework_item_list) |
| 316 | in_vendor = any(item.startswith(partition) for item in vendor_item_list) |
| 317 | if in_framework and in_vendor: |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 318 | logger.error( |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 319 | 'Cannot extract items from %s for both the framework and vendor' |
Kiyoung Kim | ebe7c9c | 2019-06-25 17:09:55 +0900 | [diff] [blame] | 320 | ' builds. Please ensure only one merge config item list' |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 321 | ' includes %s.', partition, partition) |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 322 | has_error = True |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 323 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 324 | if ('dynamic_partition_list' in framework_misc_info_keys) or ( |
| 325 | 'super_partition_groups' in framework_misc_info_keys): |
Daniel Norman | 19b9fe9 | 2019-03-19 14:48:02 -0700 | [diff] [blame] | 326 | logger.error('Dynamic partition misc info keys should come from ' |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 327 | 'the vendor instance of META/misc_info.txt.') |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 328 | has_error = True |
Daniel Norman | 19b9fe9 | 2019-03-19 14:48:02 -0700 | [diff] [blame] | 329 | |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 330 | return not has_error |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 331 | |
| 332 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 333 | def process_ab_partitions_txt(framework_target_files_temp_dir, |
| 334 | vendor_target_files_temp_dir, |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 335 | output_target_files_temp_dir): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 336 | """Performs special processing for META/ab_partitions.txt. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 337 | |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 338 | This function merges the contents of the META/ab_partitions.txt files from the |
| 339 | framework directory and the vendor directory, placing the merged result in the |
| 340 | output directory. The precondition in that the files are already extracted. |
| 341 | The post condition is that the output META/ab_partitions.txt contains the |
| 342 | merged content. The format for each ab_partitions.txt a one partition name per |
| 343 | line. The output file contains the union of the parition names. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 344 | |
| 345 | Args: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 346 | framework_target_files_temp_dir: The name of a directory containing the |
| 347 | special items extracted from the framework target files package. |
| 348 | vendor_target_files_temp_dir: The name of a directory containing the special |
| 349 | items extracted from the vendor target files package. |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 350 | output_target_files_temp_dir: The name of a directory that will be used to |
| 351 | create the output target files package after all the special cases are |
| 352 | processed. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 353 | """ |
| 354 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 355 | framework_ab_partitions_txt = os.path.join(framework_target_files_temp_dir, |
| 356 | 'META', 'ab_partitions.txt') |
| 357 | |
| 358 | vendor_ab_partitions_txt = os.path.join(vendor_target_files_temp_dir, 'META', |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 359 | 'ab_partitions.txt') |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 360 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 361 | with open(framework_ab_partitions_txt) as f: |
| 362 | framework_ab_partitions = f.read().splitlines() |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 363 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 364 | with open(vendor_ab_partitions_txt) as f: |
| 365 | vendor_ab_partitions = f.read().splitlines() |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 366 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 367 | output_ab_partitions = set(framework_ab_partitions + vendor_ab_partitions) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 368 | |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 369 | output_ab_partitions_txt = os.path.join(output_target_files_temp_dir, 'META', |
| 370 | 'ab_partitions.txt') |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 371 | |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 372 | write_sorted_data(data=output_ab_partitions, path=output_ab_partitions_txt) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 373 | |
| 374 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 375 | def process_misc_info_txt(framework_target_files_temp_dir, |
| 376 | vendor_target_files_temp_dir, |
| 377 | output_target_files_temp_dir, |
| 378 | framework_misc_info_keys): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 379 | """Performs special processing for META/misc_info.txt. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 380 | |
| 381 | This function merges the contents of the META/misc_info.txt files from the |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 382 | framework directory and the vendor directory, placing the merged result in the |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 383 | output directory. The precondition in that the files are already extracted. |
| 384 | The post condition is that the output META/misc_info.txt contains the merged |
| 385 | content. |
| 386 | |
| 387 | Args: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 388 | framework_target_files_temp_dir: The name of a directory containing the |
| 389 | special items extracted from the framework target files package. |
| 390 | vendor_target_files_temp_dir: The name of a directory containing the special |
| 391 | items extracted from the vendor target files package. |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 392 | output_target_files_temp_dir: The name of a directory that will be used to |
| 393 | create the output target files package after all the special cases are |
| 394 | processed. |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 395 | framework_misc_info_keys: A list of keys to obtain from the framework |
| 396 | instance of META/misc_info.txt. The remaining keys from the vendor |
| 397 | instance. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 398 | """ |
| 399 | |
Kiyoung Kim | ebe7c9c | 2019-06-25 17:09:55 +0900 | [diff] [blame] | 400 | misc_info_path = ['META', 'misc_info.txt'] |
| 401 | framework_dict = common.LoadDictionaryFromFile( |
| 402 | os.path.join(framework_target_files_temp_dir, *misc_info_path)) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 403 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 404 | # We take most of the misc info from the vendor target files. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 405 | |
Kiyoung Kim | ebe7c9c | 2019-06-25 17:09:55 +0900 | [diff] [blame] | 406 | merged_dict = common.LoadDictionaryFromFile( |
| 407 | os.path.join(vendor_target_files_temp_dir, *misc_info_path)) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 408 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 409 | # Replace certain values in merged_dict with values from |
| 410 | # framework_dict. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 411 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 412 | for key in framework_misc_info_keys: |
| 413 | merged_dict[key] = framework_dict[key] |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 414 | |
Daniel Norman | 19b9fe9 | 2019-03-19 14:48:02 -0700 | [diff] [blame] | 415 | # Merge misc info keys used for Dynamic Partitions. |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 416 | if (merged_dict.get('use_dynamic_partitions') == 'true') and ( |
| 417 | framework_dict.get('use_dynamic_partitions') == 'true'): |
Daniel Norman | bfc51ef | 2019-07-24 14:34:54 -0700 | [diff] [blame] | 418 | merged_dynamic_partitions_dict = common.MergeDynamicPartitionInfoDicts( |
Daniel Norman | 5541714 | 2019-11-25 16:04:36 -0800 | [diff] [blame^] | 419 | framework_dict=framework_dict, vendor_dict=merged_dict) |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 420 | merged_dict.update(merged_dynamic_partitions_dict) |
Tao Bao | 48a2feb | 2019-06-28 11:00:05 -0700 | [diff] [blame] | 421 | # Ensure that add_img_to_target_files rebuilds super split images for |
| 422 | # devices that retrofit dynamic partitions. This flag may have been set to |
| 423 | # false in the partial builds to prevent duplicate building of super.img. |
Daniel Norman | 0bf940c | 2019-06-10 12:50:19 -0700 | [diff] [blame] | 424 | merged_dict['build_super_partition'] = 'true' |
Daniel Norman | 19b9fe9 | 2019-03-19 14:48:02 -0700 | [diff] [blame] | 425 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 426 | # Replace <image>_selinux_fc values with framework or vendor file_contexts.bin |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 427 | # depending on which dictionary the key came from. |
| 428 | # Only the file basename is required because all selinux_fc properties are |
| 429 | # replaced with the full path to the file under META/ when misc_info.txt is |
| 430 | # loaded from target files for repacking. See common.py LoadInfoDict(). |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 431 | for key in merged_dict: |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 432 | if key.endswith('_selinux_fc'): |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 433 | merged_dict[key] = 'vendor_file_contexts.bin' |
| 434 | for key in framework_dict: |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 435 | if key.endswith('_selinux_fc'): |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 436 | merged_dict[key] = 'framework_file_contexts.bin' |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 437 | |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 438 | output_misc_info_txt = os.path.join(output_target_files_temp_dir, 'META', |
| 439 | 'misc_info.txt') |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 440 | write_sorted_data(data=merged_dict, path=output_misc_info_txt) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 441 | |
| 442 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 443 | def process_dynamic_partitions_info_txt(framework_target_files_dir, |
| 444 | vendor_target_files_dir, |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 445 | output_target_files_dir): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 446 | """Performs special processing for META/dynamic_partitions_info.txt. |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 447 | |
| 448 | This function merges the contents of the META/dynamic_partitions_info.txt |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 449 | files from the framework directory and the vendor directory, placing the |
| 450 | merged result in the output directory. |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 451 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 452 | This function does nothing if META/dynamic_partitions_info.txt from the vendor |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 453 | directory does not exist. |
| 454 | |
| 455 | Args: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 456 | framework_target_files_dir: The name of a directory containing the special |
| 457 | items extracted from the framework target files package. |
| 458 | vendor_target_files_dir: The name of a directory containing the special |
| 459 | items extracted from the vendor target files package. |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 460 | output_target_files_dir: The name of a directory that will be used to create |
| 461 | the output target files package after all the special cases are processed. |
| 462 | """ |
| 463 | |
| 464 | if not os.path.exists( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 465 | os.path.join(vendor_target_files_dir, 'META', |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 466 | 'dynamic_partitions_info.txt')): |
| 467 | return |
| 468 | |
Kiyoung Kim | ebe7c9c | 2019-06-25 17:09:55 +0900 | [diff] [blame] | 469 | dynamic_partitions_info_path = ['META', 'dynamic_partitions_info.txt'] |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 470 | |
Kiyoung Kim | ebe7c9c | 2019-06-25 17:09:55 +0900 | [diff] [blame] | 471 | framework_dynamic_partitions_dict = common.LoadDictionaryFromFile( |
| 472 | os.path.join(framework_target_files_dir, *dynamic_partitions_info_path)) |
| 473 | vendor_dynamic_partitions_dict = common.LoadDictionaryFromFile( |
| 474 | os.path.join(vendor_target_files_dir, *dynamic_partitions_info_path)) |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 475 | |
Daniel Norman | bfc51ef | 2019-07-24 14:34:54 -0700 | [diff] [blame] | 476 | merged_dynamic_partitions_dict = common.MergeDynamicPartitionInfoDicts( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 477 | framework_dict=framework_dynamic_partitions_dict, |
Daniel Norman | 5541714 | 2019-11-25 16:04:36 -0800 | [diff] [blame^] | 478 | vendor_dict=vendor_dynamic_partitions_dict) |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 479 | |
| 480 | output_dynamic_partitions_info_txt = os.path.join( |
| 481 | output_target_files_dir, 'META', 'dynamic_partitions_info.txt') |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 482 | write_sorted_data( |
| 483 | data=merged_dynamic_partitions_dict, |
| 484 | path=output_dynamic_partitions_info_txt) |
| 485 | |
| 486 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 487 | def process_apex_keys_apk_certs_common(framework_target_files_dir, |
| 488 | vendor_target_files_dir, |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 489 | output_target_files_dir, file_name): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 490 | """Performs special processing for META/apexkeys.txt or META/apkcerts.txt. |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 491 | |
| 492 | This function merges the contents of the META/apexkeys.txt or |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 493 | META/apkcerts.txt files from the framework directory and the vendor directory, |
| 494 | placing the merged result in the output directory. The precondition in that |
| 495 | the files are already extracted. The post condition is that the output |
| 496 | META/apexkeys.txt or META/apkcerts.txt contains the merged content. |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 497 | |
| 498 | Args: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 499 | framework_target_files_dir: The name of a directory containing the special |
| 500 | items extracted from the framework target files package. |
| 501 | vendor_target_files_dir: The name of a directory containing the special |
| 502 | items extracted from the vendor target files package. |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 503 | output_target_files_dir: The name of a directory that will be used to create |
| 504 | the output target files package after all the special cases are processed. |
| 505 | file_name: The name of the file to merge. One of apkcerts.txt or |
| 506 | apexkeys.txt. |
| 507 | """ |
| 508 | |
| 509 | def read_helper(d): |
| 510 | temp = {} |
| 511 | file_path = os.path.join(d, 'META', file_name) |
| 512 | with open(file_path) as f: |
| 513 | for line in f: |
| 514 | if line.strip(): |
| 515 | temp[line.split()[0]] = line.strip() |
| 516 | return temp |
| 517 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 518 | framework_dict = read_helper(framework_target_files_dir) |
| 519 | vendor_dict = read_helper(vendor_target_files_dir) |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 520 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 521 | for key in framework_dict: |
| 522 | if key in vendor_dict and vendor_dict[key] != framework_dict[key]: |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 523 | raise ValueError('Conflicting entries found in %s:\n %s and\n %s' % |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 524 | (file_name, framework_dict[key], vendor_dict[key])) |
| 525 | vendor_dict[key] = framework_dict[key] |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 526 | |
| 527 | output_file = os.path.join(output_target_files_dir, 'META', file_name) |
| 528 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 529 | write_sorted_data(data=vendor_dict.values(), path=output_file) |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 530 | |
| 531 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 532 | def copy_file_contexts(framework_target_files_dir, vendor_target_files_dir, |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 533 | output_target_files_dir): |
| 534 | """Creates named copies of each build's file_contexts.bin in output META/.""" |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 535 | framework_fc_path = os.path.join(framework_target_files_dir, 'META', |
| 536 | 'framework_file_contexts.bin') |
| 537 | if not os.path.exists(framework_fc_path): |
| 538 | framework_fc_path = os.path.join(framework_target_files_dir, 'META', |
| 539 | 'file_contexts.bin') |
| 540 | if not os.path.exists(framework_fc_path): |
| 541 | raise ValueError('Missing framework file_contexts.bin.') |
| 542 | shutil.copyfile( |
| 543 | framework_fc_path, |
| 544 | os.path.join(output_target_files_dir, 'META', |
| 545 | 'framework_file_contexts.bin')) |
| 546 | |
| 547 | vendor_fc_path = os.path.join(vendor_target_files_dir, 'META', |
| 548 | 'vendor_file_contexts.bin') |
| 549 | if not os.path.exists(vendor_fc_path): |
| 550 | vendor_fc_path = os.path.join(vendor_target_files_dir, 'META', |
Daniel Norman | edf1247 | 2019-05-22 10:47:08 -0700 | [diff] [blame] | 551 | 'file_contexts.bin') |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 552 | if not os.path.exists(vendor_fc_path): |
| 553 | raise ValueError('Missing vendor file_contexts.bin.') |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 554 | shutil.copyfile( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 555 | vendor_fc_path, |
| 556 | os.path.join(output_target_files_dir, 'META', 'vendor_file_contexts.bin')) |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 557 | |
| 558 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 559 | def process_special_cases(framework_target_files_temp_dir, |
| 560 | vendor_target_files_temp_dir, |
| 561 | output_target_files_temp_dir, |
Bill Peckham | e868aec | 2019-09-17 17:06:47 -0700 | [diff] [blame] | 562 | framework_misc_info_keys): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 563 | """Performs special-case processing for certain target files items. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 564 | |
| 565 | Certain files in the output target files package require special-case |
| 566 | processing. This function performs all that special-case processing. |
| 567 | |
| 568 | Args: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 569 | framework_target_files_temp_dir: The name of a directory containing the |
| 570 | special items extracted from the framework target files package. |
| 571 | vendor_target_files_temp_dir: The name of a directory containing the special |
| 572 | items extracted from the vendor target files package. |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 573 | output_target_files_temp_dir: The name of a directory that will be used to |
| 574 | create the output target files package after all the special cases are |
| 575 | processed. |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 576 | framework_misc_info_keys: A list of keys to obtain from the framework |
| 577 | instance of META/misc_info.txt. The remaining keys from the vendor |
| 578 | instance. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 579 | """ |
| 580 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 581 | if 'ab_update' in framework_misc_info_keys: |
Bill Peckham | 364c1cc | 2019-03-29 18:27:23 -0700 | [diff] [blame] | 582 | process_ab_partitions_txt( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 583 | framework_target_files_temp_dir=framework_target_files_temp_dir, |
| 584 | vendor_target_files_temp_dir=vendor_target_files_temp_dir, |
Bill Peckham | 364c1cc | 2019-03-29 18:27:23 -0700 | [diff] [blame] | 585 | output_target_files_temp_dir=output_target_files_temp_dir) |
| 586 | |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 587 | copy_file_contexts( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 588 | framework_target_files_dir=framework_target_files_temp_dir, |
| 589 | vendor_target_files_dir=vendor_target_files_temp_dir, |
Daniel Norman | 72c626f | 2019-05-13 15:58:14 -0700 | [diff] [blame] | 590 | output_target_files_dir=output_target_files_temp_dir) |
| 591 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 592 | process_misc_info_txt( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 593 | framework_target_files_temp_dir=framework_target_files_temp_dir, |
| 594 | vendor_target_files_temp_dir=vendor_target_files_temp_dir, |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 595 | output_target_files_temp_dir=output_target_files_temp_dir, |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 596 | framework_misc_info_keys=framework_misc_info_keys) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 597 | |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 598 | process_dynamic_partitions_info_txt( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 599 | framework_target_files_dir=framework_target_files_temp_dir, |
| 600 | vendor_target_files_dir=vendor_target_files_temp_dir, |
Daniel Norman | 714bd12 | 2019-05-08 16:20:02 -0700 | [diff] [blame] | 601 | output_target_files_dir=output_target_files_temp_dir) |
Daniel Norman | a61cde0 | 2019-05-03 14:19:13 -0700 | [diff] [blame] | 602 | |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 603 | process_apex_keys_apk_certs_common( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 604 | framework_target_files_dir=framework_target_files_temp_dir, |
| 605 | vendor_target_files_dir=vendor_target_files_temp_dir, |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 606 | output_target_files_dir=output_target_files_temp_dir, |
| 607 | file_name='apkcerts.txt') |
| 608 | |
| 609 | process_apex_keys_apk_certs_common( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 610 | framework_target_files_dir=framework_target_files_temp_dir, |
| 611 | vendor_target_files_dir=vendor_target_files_temp_dir, |
Chris Gross | fabf50a | 2019-05-02 12:42:09 -0700 | [diff] [blame] | 612 | output_target_files_dir=output_target_files_temp_dir, |
| 613 | file_name='apexkeys.txt') |
| 614 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 615 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 616 | def files_from_path(target_path, extra_args=None): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 617 | """Gets files under given path. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 618 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 619 | Get (sub)files from given target path and return sorted list. |
| 620 | |
| 621 | Args: |
| 622 | target_path: Target path to get subfiles. |
| 623 | extra_args: List of extra argument for find command. Optional. |
| 624 | |
| 625 | Returns: |
| 626 | Sorted files and directories list. |
| 627 | """ |
| 628 | |
| 629 | find_command = ['find', target_path] + (extra_args or []) |
| 630 | find_process = common.Run(find_command, stdout=subprocess.PIPE, verbose=False) |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 631 | return common.RunAndCheckOutput(['sort'], |
| 632 | stdin=find_process.stdout, |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 633 | verbose=False) |
| 634 | |
| 635 | |
| 636 | def create_merged_package(temp_dir, framework_target_files, framework_item_list, |
| 637 | vendor_target_files, vendor_item_list, |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 638 | framework_misc_info_keys, rebuild_recovery): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 639 | """Merges two target files packages into one target files structure. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 640 | |
| 641 | Args: |
| 642 | temp_dir: The name of a directory we use when we extract items from the |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 643 | input target files packages, and also a scratch directory that we use for |
| 644 | temporary files. |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 645 | framework_target_files: The name of the zip archive containing the framework |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 646 | partial target files package. |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 647 | framework_item_list: The list of items to extract from the partial framework |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 648 | target files package as is, meaning these items will land in the output |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 649 | target files package exactly as they appear in the input partial framework |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 650 | target files package. |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 651 | vendor_target_files: The name of the zip archive containing the vendor |
| 652 | partial target files package. |
| 653 | vendor_item_list: The list of items to extract from the partial vendor |
| 654 | target files package as is, meaning these items will land in the output |
| 655 | target files package exactly as they appear in the input partial vendor |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 656 | target files package. |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 657 | framework_misc_info_keys: The list of keys to obtain from the framework |
| 658 | instance of META/misc_info.txt. The remaining keys from the vendor |
| 659 | instance. |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 660 | rebuild_recovery: If true, rebuild the recovery patch used by non-A/B |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 661 | devices and write it to the system image. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 662 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 663 | Returns: |
| 664 | Path to merged package under temp directory. |
| 665 | """ |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 666 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 667 | # Create directory names that we'll use when we extract files from framework, |
| 668 | # and vendor, and for zipping the final output. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 669 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 670 | framework_target_files_temp_dir = os.path.join(temp_dir, 'framework') |
| 671 | vendor_target_files_temp_dir = os.path.join(temp_dir, 'vendor') |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 672 | output_target_files_temp_dir = os.path.join(temp_dir, 'output') |
| 673 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 674 | # Extract "as is" items from the input framework partial target files package. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 675 | # We extract them directly into the output temporary directory since the |
| 676 | # items do not need special case processing. |
| 677 | |
Bill Peckham | 889b0c6 | 2019-02-21 18:53:37 -0800 | [diff] [blame] | 678 | extract_items( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 679 | target_files=framework_target_files, |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 680 | target_files_temp_dir=output_target_files_temp_dir, |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 681 | extract_item_list=framework_item_list) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 682 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 683 | # Extract "as is" items from the input vendor partial target files package. We |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 684 | # extract them directly into the output temporary directory since the items |
| 685 | # do not need special case processing. |
| 686 | |
Bill Peckham | 889b0c6 | 2019-02-21 18:53:37 -0800 | [diff] [blame] | 687 | extract_items( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 688 | target_files=vendor_target_files, |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 689 | target_files_temp_dir=output_target_files_temp_dir, |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 690 | extract_item_list=vendor_item_list) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 691 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 692 | # Extract "special" items from the input framework partial target files |
| 693 | # package. We extract these items to different directory since they require |
| 694 | # special processing before they will end up in the output directory. |
| 695 | |
| 696 | extract_items( |
| 697 | target_files=framework_target_files, |
| 698 | target_files_temp_dir=framework_target_files_temp_dir, |
| 699 | extract_item_list=FRAMEWORK_EXTRACT_SPECIAL_ITEM_LIST) |
| 700 | |
| 701 | # Extract "special" items from the input vendor partial target files package. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 702 | # We extract these items to different directory since they require special |
| 703 | # processing before they will end up in the output directory. |
| 704 | |
Bill Peckham | 889b0c6 | 2019-02-21 18:53:37 -0800 | [diff] [blame] | 705 | extract_items( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 706 | target_files=vendor_target_files, |
| 707 | target_files_temp_dir=vendor_target_files_temp_dir, |
| 708 | extract_item_list=VENDOR_EXTRACT_SPECIAL_ITEM_LIST) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 709 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 710 | # Now that the temporary directories contain all the extracted files, perform |
| 711 | # special case processing on any items that need it. After this function |
| 712 | # completes successfully, all the files we need to create the output target |
| 713 | # files package are in place. |
| 714 | |
Bill Peckham | 889b0c6 | 2019-02-21 18:53:37 -0800 | [diff] [blame] | 715 | process_special_cases( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 716 | framework_target_files_temp_dir=framework_target_files_temp_dir, |
| 717 | vendor_target_files_temp_dir=vendor_target_files_temp_dir, |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 718 | output_target_files_temp_dir=output_target_files_temp_dir, |
Bill Peckham | e868aec | 2019-09-17 17:06:47 -0700 | [diff] [blame] | 719 | framework_misc_info_keys=framework_misc_info_keys) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 720 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 721 | return output_target_files_temp_dir |
| 722 | |
| 723 | |
| 724 | def generate_images(target_files_dir, rebuild_recovery): |
| 725 | """Generate images from target files. |
| 726 | |
| 727 | This function takes merged output temporary directory and create images |
| 728 | from it. |
| 729 | |
| 730 | Args: |
| 731 | target_files_dir: Path to merged temp directory. |
| 732 | rebuild_recovery: If true, rebuild the recovery patch used by non-A/B |
| 733 | devices and write it to the system image. |
| 734 | """ |
| 735 | |
| 736 | # Regenerate IMAGES in the target directory. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 737 | |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 738 | add_img_args = ['--verbose'] |
Paul Trautrim | bc3600c | 2019-08-13 18:07:03 +0900 | [diff] [blame] | 739 | add_img_args.append('--add_missing') |
Bill Peckham | e868aec | 2019-09-17 17:06:47 -0700 | [diff] [blame] | 740 | # TODO(b/132730255): Remove this if statement. |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 741 | if rebuild_recovery: |
| 742 | add_img_args.append('--rebuild_recovery') |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 743 | add_img_args.append(target_files_dir) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 744 | |
| 745 | add_img_to_target_files.main(add_img_args) |
| 746 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 747 | |
| 748 | def generate_super_empty_image(target_dir, output_super_empty): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 749 | """Generates super_empty image from target package. |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 750 | |
| 751 | Args: |
| 752 | target_dir: Path to the target file package which contains misc_info.txt for |
| 753 | detailed information for super image. |
| 754 | output_super_empty: If provided, copies a super_empty.img file from the |
| 755 | target files package to this path. |
| 756 | """ |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 757 | # Create super_empty.img using the merged misc_info.txt. |
| 758 | |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 759 | misc_info_txt = os.path.join(target_dir, 'META', 'misc_info.txt') |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 760 | |
Kiyoung Kim | ebe7c9c | 2019-06-25 17:09:55 +0900 | [diff] [blame] | 761 | use_dynamic_partitions = common.LoadDictionaryFromFile(misc_info_txt).get( |
| 762 | 'use_dynamic_partitions') |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 763 | |
| 764 | if use_dynamic_partitions != 'true' and output_super_empty: |
| 765 | raise ValueError( |
| 766 | 'Building super_empty.img requires use_dynamic_partitions=true.') |
| 767 | elif use_dynamic_partitions == 'true': |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 768 | super_empty_img = os.path.join(target_dir, 'IMAGES', 'super_empty.img') |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 769 | build_super_image_args = [ |
| 770 | misc_info_txt, |
| 771 | super_empty_img, |
| 772 | ] |
| 773 | build_super_image.main(build_super_image_args) |
| 774 | |
| 775 | # Copy super_empty.img to the user-provided output_super_empty location. |
| 776 | if output_super_empty: |
| 777 | shutil.copyfile(super_empty_img, output_super_empty) |
| 778 | |
Daniel Norman | b8a2f9d | 2019-04-24 12:55:51 -0700 | [diff] [blame] | 779 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 780 | def create_target_files_archive(output_file, source_dir, temp_dir): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 781 | """Creates archive from target package. |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 782 | |
| 783 | Args: |
| 784 | output_file: The name of the zip archive target files package. |
| 785 | source_dir: The target directory contains package to be archived. |
| 786 | temp_dir: Path to temporary directory for any intermediate files. |
| 787 | """ |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 788 | output_target_files_list = os.path.join(temp_dir, 'output.list') |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 789 | output_zip = os.path.abspath(output_file) |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 790 | output_target_files_meta_dir = os.path.join(source_dir, 'META') |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 791 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 792 | meta_content = files_from_path(output_target_files_meta_dir) |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 793 | other_content = files_from_path( |
| 794 | source_dir, |
| 795 | ['-path', output_target_files_meta_dir, '-prune', '-o', '-print']) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 796 | |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 797 | with open(output_target_files_list, 'w') as f: |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 798 | f.write(meta_content) |
| 799 | f.write(other_content) |
| 800 | |
| 801 | command = [ |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 802 | 'soong_zip', |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 803 | '-d', |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 804 | '-o', |
| 805 | output_zip, |
| 806 | '-C', |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 807 | source_dir, |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 808 | '-l', |
| 809 | output_target_files_list, |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 810 | ] |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 811 | |
| 812 | logger.info('creating %s', output_file) |
Bill Peckham | 889b0c6 | 2019-02-21 18:53:37 -0800 | [diff] [blame] | 813 | common.RunAndWait(command, verbose=True) |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 814 | logger.info('finished creating %s', output_file) |
| 815 | |
| 816 | return output_zip |
| 817 | |
| 818 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 819 | def merge_target_files(temp_dir, framework_target_files, framework_item_list, |
| 820 | framework_misc_info_keys, vendor_target_files, |
| 821 | vendor_item_list, output_target_files, output_dir, |
| 822 | output_item_list, output_ota, output_img, |
| 823 | output_super_empty, rebuild_recovery): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 824 | """Merges two target files packages together. |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 825 | |
| 826 | This function takes framework and vendor target files packages as input, |
| 827 | performs various file extractions, special case processing, and finally |
| 828 | creates a merged zip archive as output. |
| 829 | |
| 830 | Args: |
| 831 | temp_dir: The name of a directory we use when we extract items from the |
| 832 | input target files packages, and also a scratch directory that we use for |
| 833 | temporary files. |
| 834 | framework_target_files: The name of the zip archive containing the framework |
| 835 | partial target files package. |
| 836 | framework_item_list: The list of items to extract from the partial framework |
| 837 | target files package as is, meaning these items will land in the output |
| 838 | target files package exactly as they appear in the input partial framework |
| 839 | target files package. |
| 840 | framework_misc_info_keys: The list of keys to obtain from the framework |
| 841 | instance of META/misc_info.txt. The remaining keys from the vendor |
| 842 | instance. |
| 843 | vendor_target_files: The name of the zip archive containing the vendor |
| 844 | partial target files package. |
| 845 | vendor_item_list: The list of items to extract from the partial vendor |
| 846 | target files package as is, meaning these items will land in the output |
| 847 | target files package exactly as they appear in the input partial vendor |
| 848 | target files package. |
| 849 | output_target_files: The name of the output zip archive target files package |
| 850 | created by merging framework and vendor. |
| 851 | output_dir: The destination directory for saving merged files. |
| 852 | output_item_list: The list of items to copy into the output_dir. |
| 853 | output_ota: The name of the output zip archive ota package. |
| 854 | output_img: The name of the output zip archive img package. |
| 855 | output_super_empty: If provided, creates a super_empty.img file from the |
| 856 | merged target files package and saves it at this path. |
| 857 | rebuild_recovery: If true, rebuild the recovery patch used by non-A/B |
| 858 | devices and write it to the system image. |
| 859 | """ |
| 860 | |
| 861 | logger.info('starting: merge framework %s and vendor %s into output %s', |
| 862 | framework_target_files, vendor_target_files, output_target_files) |
| 863 | |
| 864 | output_target_files_temp_dir = create_merged_package( |
| 865 | temp_dir, framework_target_files, framework_item_list, |
| 866 | vendor_target_files, vendor_item_list, framework_misc_info_keys, |
| 867 | rebuild_recovery) |
| 868 | |
Yifan Hong | ade0d3f | 2019-08-21 16:37:11 -0700 | [diff] [blame] | 869 | if not check_target_files_vintf.CheckVintf(output_target_files_temp_dir): |
| 870 | raise RuntimeError("Incompatible VINTF metadata") |
| 871 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 872 | generate_images(output_target_files_temp_dir, rebuild_recovery) |
| 873 | |
| 874 | generate_super_empty_image(output_target_files_temp_dir, output_super_empty) |
| 875 | |
Kiyoung Kim | 7cbeda7 | 2019-06-28 13:26:04 +0900 | [diff] [blame] | 876 | # Finally, create the output target files zip archive and/or copy the |
| 877 | # output items to the output target files directory. |
| 878 | |
| 879 | if output_dir: |
| 880 | copy_items(output_target_files_temp_dir, output_dir, output_item_list) |
| 881 | |
| 882 | if not output_target_files: |
| 883 | return |
| 884 | |
| 885 | output_zip = create_target_files_archive(output_target_files, |
| 886 | output_target_files_temp_dir, |
| 887 | temp_dir) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 888 | |
Daniel Norman | 74eb74b | 2019-09-18 14:01:48 -0700 | [diff] [blame] | 889 | # Create the IMG package from the merged target files package. |
| 890 | |
| 891 | if output_img: |
| 892 | img_from_target_files.main([output_zip, output_img]) |
| 893 | |
Daniel Norman | 3b64ce1 | 2019-04-16 16:11:35 -0700 | [diff] [blame] | 894 | # Create the OTA package from the merged target files package. |
| 895 | |
| 896 | if output_ota: |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 897 | ota_from_target_files.main([output_zip, output_ota]) |
Daniel Norman | 3b64ce1 | 2019-04-16 16:11:35 -0700 | [diff] [blame] | 898 | |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 899 | |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 900 | def call_func_with_temp_dir(func, keep_tmp): |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 901 | """Manages the creation and cleanup of the temporary directory. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 902 | |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 903 | This function calls the given function after first creating a temporary |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 904 | directory. It also cleans up the temporary directory. |
| 905 | |
| 906 | Args: |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 907 | func: The function to call. Should accept one parameter, the path to the |
| 908 | temporary directory. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 909 | keep_tmp: Keep the temporary directory after processing is complete. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 910 | """ |
| 911 | |
| 912 | # Create a temporary directory. This will serve as the parent of directories |
| 913 | # we use when we extract items from the input target files packages, and also |
| 914 | # a scratch directory that we use for temporary files. |
| 915 | |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 916 | temp_dir = common.MakeTempDir(prefix='merge_target_files_') |
| 917 | |
| 918 | try: |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 919 | func(temp_dir) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 920 | finally: |
| 921 | if keep_tmp: |
| 922 | logger.info('keeping %s', temp_dir) |
| 923 | else: |
| 924 | common.Cleanup() |
| 925 | |
| 926 | |
| 927 | def main(): |
| 928 | """The main function. |
| 929 | |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 930 | Process command line arguments, then call merge_target_files to |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 931 | perform the heavy lifting. |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 932 | """ |
| 933 | |
| 934 | common.InitLogging() |
| 935 | |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 936 | def option_handler(o, a): |
| 937 | if o == '--system-target-files': |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 938 | logger.warning( |
| 939 | '--system-target-files has been renamed to --framework-target-files') |
| 940 | OPTIONS.framework_target_files = a |
| 941 | elif o == '--framework-target-files': |
| 942 | OPTIONS.framework_target_files = a |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 943 | elif o == '--system-item-list': |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 944 | logger.warning( |
| 945 | '--system-item-list has been renamed to --framework-item-list') |
| 946 | OPTIONS.framework_item_list = a |
| 947 | elif o == '--framework-item-list': |
| 948 | OPTIONS.framework_item_list = a |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 949 | elif o == '--system-misc-info-keys': |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 950 | logger.warning('--system-misc-info-keys has been renamed to ' |
| 951 | '--framework-misc-info-keys') |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 952 | OPTIONS.framework_misc_info_keys = a |
| 953 | elif o == '--framework-misc-info-keys': |
| 954 | OPTIONS.framework_misc_info_keys = a |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 955 | elif o == '--other-target-files': |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 956 | logger.warning( |
| 957 | '--other-target-files has been renamed to --vendor-target-files') |
| 958 | OPTIONS.vendor_target_files = a |
| 959 | elif o == '--vendor-target-files': |
| 960 | OPTIONS.vendor_target_files = a |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 961 | elif o == '--other-item-list': |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 962 | logger.warning('--other-item-list has been renamed to --vendor-item-list') |
| 963 | OPTIONS.vendor_item_list = a |
| 964 | elif o == '--vendor-item-list': |
| 965 | OPTIONS.vendor_item_list = a |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 966 | elif o == '--output-target-files': |
| 967 | OPTIONS.output_target_files = a |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 968 | elif o == '--output-dir': |
| 969 | OPTIONS.output_dir = a |
| 970 | elif o == '--output-item-list': |
| 971 | OPTIONS.output_item_list = a |
Daniel Norman | 3b64ce1 | 2019-04-16 16:11:35 -0700 | [diff] [blame] | 972 | elif o == '--output-ota': |
| 973 | OPTIONS.output_ota = a |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 974 | elif o == '--output-img': |
| 975 | OPTIONS.output_img = a |
Daniel Norman | f031825 | 2019-04-15 11:34:56 -0700 | [diff] [blame] | 976 | elif o == '--output-super-empty': |
| 977 | OPTIONS.output_super_empty = a |
Bill Peckham | e868aec | 2019-09-17 17:06:47 -0700 | [diff] [blame] | 978 | elif o == '--rebuild_recovery': # TODO(b/132730255): Warn |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 979 | OPTIONS.rebuild_recovery = True |
Bill Peckham | 364c1cc | 2019-03-29 18:27:23 -0700 | [diff] [blame] | 980 | elif o == '--keep-tmp': |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 981 | OPTIONS.keep_tmp = True |
| 982 | else: |
| 983 | return False |
| 984 | return True |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 985 | |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 986 | args = common.ParseOptions( |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 987 | sys.argv[1:], |
| 988 | __doc__, |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 989 | extra_long_opts=[ |
| 990 | 'system-target-files=', |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 991 | 'framework-target-files=', |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 992 | 'system-item-list=', |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 993 | 'framework-item-list=', |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 994 | 'system-misc-info-keys=', |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 995 | 'framework-misc-info-keys=', |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 996 | 'other-target-files=', |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 997 | 'vendor-target-files=', |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 998 | 'other-item-list=', |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 999 | 'vendor-item-list=', |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 1000 | 'output-target-files=', |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 1001 | 'output-dir=', |
| 1002 | 'output-item-list=', |
Daniel Norman | 3b64ce1 | 2019-04-16 16:11:35 -0700 | [diff] [blame] | 1003 | 'output-ota=', |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 1004 | 'output-img=', |
Daniel Norman | f031825 | 2019-04-15 11:34:56 -0700 | [diff] [blame] | 1005 | 'output-super-empty=', |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 1006 | 'rebuild_recovery', |
Bill Peckham | 364c1cc | 2019-03-29 18:27:23 -0700 | [diff] [blame] | 1007 | 'keep-tmp', |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 1008 | ], |
| 1009 | extra_option_handler=option_handler) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 1010 | |
Tao Bao | 2ad4b82 | 2019-06-27 16:52:12 -0700 | [diff] [blame] | 1011 | # pylint: disable=too-many-boolean-expressions |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1012 | if (args or OPTIONS.framework_target_files is None or |
| 1013 | OPTIONS.vendor_target_files is None or |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 1014 | (OPTIONS.output_target_files is None and OPTIONS.output_dir is None) or |
| 1015 | (OPTIONS.output_dir is not None and OPTIONS.output_item_list is None)): |
Bill Peckham | f753e15 | 2019-02-19 18:02:46 -0800 | [diff] [blame] | 1016 | common.Usage(__doc__) |
Bill Peckham | 889b0c6 | 2019-02-21 18:53:37 -0800 | [diff] [blame] | 1017 | sys.exit(1) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 1018 | |
Tao Bao | abb806b | 2019-08-06 10:32:32 -0700 | [diff] [blame] | 1019 | # Always turn on verbose logging. |
| 1020 | OPTIONS.verbose = True |
| 1021 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1022 | if OPTIONS.framework_item_list: |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 1023 | framework_item_list = common.LoadListFromFile(OPTIONS.framework_item_list) |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 1024 | else: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1025 | framework_item_list = DEFAULT_FRAMEWORK_ITEM_LIST |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 1026 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1027 | if OPTIONS.framework_misc_info_keys: |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 1028 | framework_misc_info_keys = common.LoadListFromFile( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1029 | OPTIONS.framework_misc_info_keys) |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 1030 | else: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1031 | framework_misc_info_keys = DEFAULT_FRAMEWORK_MISC_INFO_KEYS |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 1032 | |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1033 | if OPTIONS.vendor_item_list: |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 1034 | vendor_item_list = common.LoadListFromFile(OPTIONS.vendor_item_list) |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 1035 | else: |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1036 | vendor_item_list = DEFAULT_VENDOR_ITEM_LIST |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 1037 | |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 1038 | if OPTIONS.output_item_list: |
Daniel Norman | 4cc9df6 | 2019-07-18 10:11:07 -0700 | [diff] [blame] | 1039 | output_item_list = common.LoadListFromFile(OPTIONS.output_item_list) |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 1040 | else: |
| 1041 | output_item_list = None |
| 1042 | |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 1043 | if not validate_config_lists( |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1044 | framework_item_list=framework_item_list, |
| 1045 | framework_misc_info_keys=framework_misc_info_keys, |
| 1046 | vendor_item_list=vendor_item_list): |
Daniel Norman | e596452 | 2019-03-19 10:32:03 -0700 | [diff] [blame] | 1047 | sys.exit(1) |
| 1048 | |
Daniel Norman | 2c99c5b | 2019-03-07 13:01:48 -0800 | [diff] [blame] | 1049 | call_func_with_temp_dir( |
| 1050 | lambda temp_dir: merge_target_files( |
| 1051 | temp_dir=temp_dir, |
Daniel Norman | d5d70ea | 2019-06-05 15:13:43 -0700 | [diff] [blame] | 1052 | framework_target_files=OPTIONS.framework_target_files, |
| 1053 | framework_item_list=framework_item_list, |
| 1054 | framework_misc_info_keys=framework_misc_info_keys, |
| 1055 | vendor_target_files=OPTIONS.vendor_target_files, |
| 1056 | vendor_item_list=vendor_item_list, |
Daniel Norman | a4911da | 2019-03-15 14:36:21 -0700 | [diff] [blame] | 1057 | output_target_files=OPTIONS.output_target_files, |
Daniel Norman | fdb3881 | 2019-04-15 09:47:24 -0700 | [diff] [blame] | 1058 | output_dir=OPTIONS.output_dir, |
| 1059 | output_item_list=output_item_list, |
Daniel Norman | 3b64ce1 | 2019-04-16 16:11:35 -0700 | [diff] [blame] | 1060 | output_ota=OPTIONS.output_ota, |
Daniel Norman | 1bd2a1d | 2019-04-18 12:32:18 -0700 | [diff] [blame] | 1061 | output_img=OPTIONS.output_img, |
Daniel Norman | f031825 | 2019-04-15 11:34:56 -0700 | [diff] [blame] | 1062 | output_super_empty=OPTIONS.output_super_empty, |
Daniel Norman | e5b134a | 2019-04-17 14:54:06 -0700 | [diff] [blame] | 1063 | rebuild_recovery=OPTIONS.rebuild_recovery), OPTIONS.keep_tmp) |
Bill Peckham | e9eb5f9 | 2019-02-01 15:52:10 -0800 | [diff] [blame] | 1064 | |
| 1065 | |
| 1066 | if __name__ == '__main__': |
Bill Peckham | 889b0c6 | 2019-02-21 18:53:37 -0800 | [diff] [blame] | 1067 | main() |