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