diff options
author | Tao Bao <tbao@google.com> | 2019-09-17 22:43:11 -0700 |
---|---|---|
committer | Tao Bao <tbao@google.com> | 2019-09-18 10:44:09 -0700 |
commit | 180275bcd5d78efde2a37b4347984372866878c9 (patch) | |
tree | 3d3600fbe0603fb9cc8e6e14c15610e0289d24ab | |
parent | 028a161162c665643e0464b4374bb13129a40366 (diff) | |
download | build-180275bcd5d78efde2a37b4347984372866878c9.tar.gz |
releasetools: Remove more images out of secondary payload.
This CL additionally removes boot/dtbo/modem/vbmeta_* images out of
secondary payload. We essentially only keep system_other.img and
bootloader images there.
For Pixel devices, this additionally saves ~80MiB (mostly because of
the removal of boot and radio images).
Bug: 140771390
Test: ota_from_target_files \
--include_secondary --skip_postinstall \
-i input-target_files-1.zip \
input-target_files-2.zip \
output-ota.zip
Test: python -m unittest test_ota_from_target_files
Change-Id: If47b27c52b3547a4cc86223a988c53960bc6af40
Merged-In: If47b27c52b3547a4cc86223a988c53960bc6af40
(cherry picked from commit 3e759462d9c81353ae43efa7c33e040c414b19f1)
-rwxr-xr-x | tools/releasetools/ota_from_target_files.py | 24 | ||||
-rw-r--r-- | tools/releasetools/test_ota_from_target_files.py | 32 |
2 files changed, 41 insertions, 15 deletions
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index d0b66a753b..27854fd66b 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -242,7 +242,12 @@ DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt' AB_PARTITIONS = 'META/ab_partitions.txt' UNZIP_PATTERN = ['IMAGES/*', 'META/*', 'RADIO/*'] RETROFIT_DAP_UNZIP_PATTERN = ['OTA/super_*.img', AB_PARTITIONS] -SECONDARY_IMAGES_SKIP_PARTITIONS = ['odm', 'product', 'system_ext', 'vendor'] + +# Images to be excluded from secondary payload. We essentially only keep +# 'system_other' and bootloader partitions. +SECONDARY_PAYLOAD_SKIPPED_IMAGES = [ + 'boot', 'dtbo', 'modem', 'odm', 'product', 'radio', 'recovery', + 'system_ext', 'vbmeta', 'vbmeta_system', 'vbmeta_vendor', 'vendor'] class BuildInfo(object): @@ -1891,7 +1896,7 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): if key == 'dynamic_partition_list' or key.endswith(LIST_SUFFIX): partitions = value.split() partitions = [partition for partition in partitions if partition - not in SECONDARY_IMAGES_SKIP_PARTITIONS] + not in SECONDARY_PAYLOAD_SKIPPED_IMAGES] output_list.append('{}={}'.format(key, ' '.join(partitions))) else: output_list.append(line) @@ -1914,10 +1919,13 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): elif info.filename in ('IMAGES/system.img', 'IMAGES/system.map'): pass - # Images like vendor and product are not needed in the secondary payload. - elif info.filename in ['IMAGES/{}.img'.format(partition) for partition in - SECONDARY_IMAGES_SKIP_PARTITIONS]: - pass + + # Copy images that are not in SECONDARY_PAYLOAD_SKIPPED_IMAGES. + elif info.filename.startswith(('IMAGES/', 'RADIO/')): + image_name = os.path.basename(info.filename) + if image_name not in ['{}.img'.format(partition) for partition in + SECONDARY_PAYLOAD_SKIPPED_IMAGES]: + common.ZipWrite(target_zip, unzipped_file, arcname=info.filename) # Skip copying the postinstall config if requested. elif skip_postinstall and info.filename == POSTINSTALL_CONFIG: @@ -1930,7 +1938,7 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): with open(unzipped_file) as f: partition_list = f.read().splitlines() partition_list = [partition for partition in partition_list if partition - and partition not in SECONDARY_IMAGES_SKIP_PARTITIONS] + and partition not in SECONDARY_PAYLOAD_SKIPPED_IMAGES] common.ZipWriteStr(target_zip, info.filename, '\n'.join(partition_list)) # Remove the unnecessary partitions from the dynamic partitions list. elif (info.filename == 'META/misc_info.txt' or @@ -1939,8 +1947,6 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): common.ZipWriteStr(target_zip, info.filename, modified_info) else: common.ZipWrite(target_zip, unzipped_file, arcname=info.filename) - elif info.filename.startswith(('IMAGES/', 'RADIO/')): - common.ZipWrite(target_zip, unzipped_file, arcname=info.filename) common.ZipClose(target_zip) diff --git a/tools/releasetools/test_ota_from_target_files.py b/tools/releasetools/test_ota_from_target_files.py index 2942d611df..07dcffb6aa 100644 --- a/tools/releasetools/test_ota_from_target_files.py +++ b/tools/releasetools/test_ota_from_target_files.py @@ -591,16 +591,16 @@ class OtaFromTargetFilesTest(test_utils.ReleaseToolsTestCase): ab_partitions = verify_zip.read('META/ab_partitions.txt') self.assertIn('META/ab_partitions.txt', namelist) - self.assertIn('IMAGES/boot.img', namelist) self.assertIn('IMAGES/system.img', namelist) self.assertIn('RADIO/bootloader.img', namelist) - self.assertIn('RADIO/modem.img', namelist) self.assertIn(POSTINSTALL_CONFIG, namelist) + self.assertNotIn('IMAGES/boot.img', namelist) self.assertNotIn('IMAGES/system_other.img', namelist) self.assertNotIn('IMAGES/system.map', namelist) + self.assertNotIn('RADIO/modem.img', namelist) - expected_ab_partitions = ['boot', 'system', 'bootloader', 'modem'] + expected_ab_partitions = ['system', 'bootloader'] self.assertEqual('\n'.join(expected_ab_partitions), ab_partitions) @test_utils.SkipIfExternalToolsUnavailable() @@ -613,16 +613,36 @@ class OtaFromTargetFilesTest(test_utils.ReleaseToolsTestCase): namelist = verify_zip.namelist() self.assertIn('META/ab_partitions.txt', namelist) - self.assertIn('IMAGES/boot.img', namelist) self.assertIn('IMAGES/system.img', namelist) self.assertIn('RADIO/bootloader.img', namelist) - self.assertIn('RADIO/modem.img', namelist) + self.assertNotIn('IMAGES/boot.img', namelist) self.assertNotIn('IMAGES/system_other.img', namelist) self.assertNotIn('IMAGES/system.map', namelist) + self.assertNotIn('RADIO/modem.img', namelist) self.assertNotIn(POSTINSTALL_CONFIG, namelist) @test_utils.SkipIfExternalToolsUnavailable() + def test_GetTargetFilesZipForSecondaryImages_withoutRadioImages(self): + input_file = construct_target_files(secondary=True) + common.ZipDelete(input_file, 'RADIO/bootloader.img') + common.ZipDelete(input_file, 'RADIO/modem.img') + target_file = GetTargetFilesZipForSecondaryImages(input_file) + + with zipfile.ZipFile(target_file) as verify_zip: + namelist = verify_zip.namelist() + + self.assertIn('META/ab_partitions.txt', namelist) + self.assertIn('IMAGES/system.img', namelist) + self.assertIn(POSTINSTALL_CONFIG, namelist) + + self.assertNotIn('IMAGES/boot.img', namelist) + self.assertNotIn('IMAGES/system_other.img', namelist) + self.assertNotIn('IMAGES/system.map', namelist) + self.assertNotIn('RADIO/bootloader.img', namelist) + self.assertNotIn('RADIO/modem.img', namelist) + + @test_utils.SkipIfExternalToolsUnavailable() def test_GetTargetFilesZipForSecondaryImages_dynamicPartitions(self): input_file = construct_target_files(secondary=True) misc_info = '\n'.join([ @@ -653,12 +673,12 @@ class OtaFromTargetFilesTest(test_utils.ReleaseToolsTestCase): 'META/dynamic_partitions_info.txt') self.assertIn('META/ab_partitions.txt', namelist) - self.assertIn('IMAGES/boot.img', namelist) self.assertIn('IMAGES/system.img', namelist) self.assertIn(POSTINSTALL_CONFIG, namelist) self.assertIn('META/misc_info.txt', namelist) self.assertIn('META/dynamic_partitions_info.txt', namelist) + self.assertNotIn('IMAGES/boot.img', namelist) self.assertNotIn('IMAGES/system_other.img', namelist) self.assertNotIn('IMAGES/system.map', namelist) |