Loading tools/releasetools/ota_from_target_files.py +37 −5 Original line number Diff line number Diff line Loading @@ -235,8 +235,9 @@ OPTIONS.output_metadata_path = None METADATA_NAME = 'META-INF/com/android/metadata' POSTINSTALL_CONFIG = 'META/postinstall_config.txt' DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt' AB_PARTITIONS = 'META/ab_partitions.txt' UNZIP_PATTERN = ['IMAGES/*', 'META/*'] SUPER_SPLIT_PATTERN = ['OTA/super_*.img'] RETROFIT_DAP_UNZIP_PATTERN = ['OTA/super_*.img', AB_PARTITIONS] class BuildInfo(object): Loading Loading @@ -1852,7 +1853,8 @@ def GetTargetFilesZipWithoutPostinstallConfig(input_file): def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, super_block_devices): super_block_devices, dynamic_partition_list): """Returns a target-files.zip for retrofitting dynamic partitions. This allows brillo_update_payload to generate an OTA based on the exact Loading @@ -1861,6 +1863,7 @@ def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, Args: input_file: The input target-files.zip filename. super_block_devices: The list of super block devices dynamic_partition_list: The list of dynamic partitions Returns: The filename of target-files.zip with *.img replaced with super_*.img for Loading @@ -1877,8 +1880,34 @@ def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, with zipfile.ZipFile(input_file, 'r') as input_zip: namelist = input_zip.namelist() input_tmp = common.UnzipTemp(input_file, RETROFIT_DAP_UNZIP_PATTERN) # Remove partitions from META/ab_partitions.txt that is in # dynamic_partition_list but not in super_block_devices so that # brillo_update_payload won't generate update for those logical partitions. ab_partitions_file = os.path.join(input_tmp, *AB_PARTITIONS.split('/')) with open(ab_partitions_file) as f: ab_partitions_lines = f.readlines() ab_partitions = [line.strip() for line in ab_partitions_lines] # Assert that all super_block_devices are in ab_partitions super_device_not_updated = [partition for partition in super_block_devices if partition not in ab_partitions] assert not super_device_not_updated, \ "{} is in super_block_devices but not in {}".format( super_device_not_updated, AB_PARTITIONS) # ab_partitions -= (dynamic_partition_list - super_block_devices) new_ab_partitions = common.MakeTempFile(prefix="ab_partitions", suffix=".txt") with open(new_ab_partitions, 'w') as f: for partition in ab_partitions: if (partition in dynamic_partition_list and partition not in super_block_devices): logger.info("Dropping %s from ab_partitions.txt", partition) continue f.write(partition + "\n") to_delete = [AB_PARTITIONS] # Always skip postinstall for a retrofit update. to_delete = [POSTINSTALL_CONFIG] to_delete += [POSTINSTALL_CONFIG] # Delete dynamic_partitions_info.txt so that brillo_update_payload thinks this # is a regular update on devices without dynamic partitions support. Loading @@ -1890,7 +1919,6 @@ def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, common.ZipDelete(target_file, to_delete) input_tmp = common.UnzipTemp(input_file, SUPER_SPLIT_PATTERN) target_zip = zipfile.ZipFile(target_file, 'a', allowZip64=True) # Write super_{foo}.img as {foo}.img. Loading @@ -1900,6 +1928,9 @@ def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, unzipped_file = os.path.join(input_tmp, *src.split('/')) common.ZipWrite(target_zip, unzipped_file, arcname=dst) # Write new ab_partitions.txt file common.ZipWrite(target_zip, new_ab_partitions, arcname=AB_PARTITIONS) common.ZipClose(target_zip) return target_file Loading Loading @@ -1928,7 +1959,8 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file, if OPTIONS.retrofit_dynamic_partitions: target_file = GetTargetFilesZipForRetrofitDynamicPartitions( target_file, target_info.get("super_block_devices").strip().split()) target_file, target_info.get("super_block_devices").strip().split(), target_info.get("dynamic_partition_list").strip().split()) elif OPTIONS.skip_postinstall: target_file = GetTargetFilesZipWithoutPostinstallConfig(target_file) Loading Loading
tools/releasetools/ota_from_target_files.py +37 −5 Original line number Diff line number Diff line Loading @@ -235,8 +235,9 @@ OPTIONS.output_metadata_path = None METADATA_NAME = 'META-INF/com/android/metadata' POSTINSTALL_CONFIG = 'META/postinstall_config.txt' DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt' AB_PARTITIONS = 'META/ab_partitions.txt' UNZIP_PATTERN = ['IMAGES/*', 'META/*'] SUPER_SPLIT_PATTERN = ['OTA/super_*.img'] RETROFIT_DAP_UNZIP_PATTERN = ['OTA/super_*.img', AB_PARTITIONS] class BuildInfo(object): Loading Loading @@ -1852,7 +1853,8 @@ def GetTargetFilesZipWithoutPostinstallConfig(input_file): def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, super_block_devices): super_block_devices, dynamic_partition_list): """Returns a target-files.zip for retrofitting dynamic partitions. This allows brillo_update_payload to generate an OTA based on the exact Loading @@ -1861,6 +1863,7 @@ def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, Args: input_file: The input target-files.zip filename. super_block_devices: The list of super block devices dynamic_partition_list: The list of dynamic partitions Returns: The filename of target-files.zip with *.img replaced with super_*.img for Loading @@ -1877,8 +1880,34 @@ def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, with zipfile.ZipFile(input_file, 'r') as input_zip: namelist = input_zip.namelist() input_tmp = common.UnzipTemp(input_file, RETROFIT_DAP_UNZIP_PATTERN) # Remove partitions from META/ab_partitions.txt that is in # dynamic_partition_list but not in super_block_devices so that # brillo_update_payload won't generate update for those logical partitions. ab_partitions_file = os.path.join(input_tmp, *AB_PARTITIONS.split('/')) with open(ab_partitions_file) as f: ab_partitions_lines = f.readlines() ab_partitions = [line.strip() for line in ab_partitions_lines] # Assert that all super_block_devices are in ab_partitions super_device_not_updated = [partition for partition in super_block_devices if partition not in ab_partitions] assert not super_device_not_updated, \ "{} is in super_block_devices but not in {}".format( super_device_not_updated, AB_PARTITIONS) # ab_partitions -= (dynamic_partition_list - super_block_devices) new_ab_partitions = common.MakeTempFile(prefix="ab_partitions", suffix=".txt") with open(new_ab_partitions, 'w') as f: for partition in ab_partitions: if (partition in dynamic_partition_list and partition not in super_block_devices): logger.info("Dropping %s from ab_partitions.txt", partition) continue f.write(partition + "\n") to_delete = [AB_PARTITIONS] # Always skip postinstall for a retrofit update. to_delete = [POSTINSTALL_CONFIG] to_delete += [POSTINSTALL_CONFIG] # Delete dynamic_partitions_info.txt so that brillo_update_payload thinks this # is a regular update on devices without dynamic partitions support. Loading @@ -1890,7 +1919,6 @@ def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, common.ZipDelete(target_file, to_delete) input_tmp = common.UnzipTemp(input_file, SUPER_SPLIT_PATTERN) target_zip = zipfile.ZipFile(target_file, 'a', allowZip64=True) # Write super_{foo}.img as {foo}.img. Loading @@ -1900,6 +1928,9 @@ def GetTargetFilesZipForRetrofitDynamicPartitions(input_file, unzipped_file = os.path.join(input_tmp, *src.split('/')) common.ZipWrite(target_zip, unzipped_file, arcname=dst) # Write new ab_partitions.txt file common.ZipWrite(target_zip, new_ab_partitions, arcname=AB_PARTITIONS) common.ZipClose(target_zip) return target_file Loading Loading @@ -1928,7 +1959,8 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file, if OPTIONS.retrofit_dynamic_partitions: target_file = GetTargetFilesZipForRetrofitDynamicPartitions( target_file, target_info.get("super_block_devices").strip().split()) target_file, target_info.get("super_block_devices").strip().split(), target_info.get("dynamic_partition_list").strip().split()) elif OPTIONS.skip_postinstall: target_file = GetTargetFilesZipWithoutPostinstallConfig(target_file) Loading