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