Loading tools/releasetools/common.py +13 −8 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import copy import datetime import errno import fnmatch from genericpath import isdir import getopt import getpass import gzip Loading @@ -34,12 +33,13 @@ import re import shlex import shutil import subprocess import sys import stat import sys import tempfile import threading import time import zipfile from genericpath import isdir from hashlib import sha1, sha256 import images Loading Loading @@ -112,13 +112,18 @@ SPECIAL_CERT_STRINGS = ("PRESIGNED", "EXTERNAL") # descriptor into vbmeta.img. When adding a new entry here, the # AVB_FOOTER_ARGS_BY_PARTITION in sign_target_files_apks need to be updated # accordingly. AVB_PARTITIONS = ('boot', 'init_boot', 'dtbo', 'odm', 'product', 'pvmfw', 'recovery', 'system', 'system_ext', 'vendor', 'vendor_boot', 'vendor_kernel_boot', 'vendor_dlkm', 'odm_dlkm', 'system_dlkm') AVB_PARTITIONS = ('boot', 'init_boot', 'dtbo', 'odm', 'product', 'pvmfw', 'recovery', 'system', 'system_ext', 'vendor', 'vendor_boot', 'vendor_kernel_boot', 'vendor_dlkm', 'odm_dlkm', 'system_dlkm') # Chained VBMeta partitions. AVB_VBMETA_PARTITIONS = ('vbmeta_system', 'vbmeta_vendor') # avbtool arguments name AVB_ARG_NAME_INCLUDE_DESC_FROM_IMG = '--include_descriptors_from_image' AVB_ARG_NAME_CHAIN_PARTITION = '--chain_partition' # Partitions that should have their care_map added to META/care_map.pb PARTITIONS_WITH_CARE_MAP = [ 'system', Loading Loading @@ -1467,7 +1472,7 @@ def GetAvbPartitionArg(partition, image, info_dict=None): # Check if chain partition is used. key_path = info_dict.get("avb_" + partition + "_key_path") if not key_path: return ["--include_descriptors_from_image", image] return [AVB_ARG_NAME_INCLUDE_DESC_FROM_IMG, image] # For a non-A/B device, we don't chain /recovery nor include its descriptor # into vbmeta.img. The recovery image will be configured on an independent Loading @@ -1479,7 +1484,7 @@ def GetAvbPartitionArg(partition, image, info_dict=None): # Otherwise chain the partition into vbmeta. chained_partition_arg = GetAvbChainedPartitionArg(partition, info_dict) return ["--chain_partition", chained_partition_arg] return [AVB_ARG_NAME_CHAIN_PARTITION, chained_partition_arg] def GetAvbChainedPartitionArg(partition, info_dict, key=None): Loading Loading @@ -1598,7 +1603,7 @@ def BuildVBMeta(image_path, partitions, name, needed_partitions): # same location when running this script (we have the input target_files # zip only). For such cases, we additionally scan other locations (e.g. # IMAGES/, RADIO/, etc) before bailing out. if arg == '--include_descriptors_from_image': if arg == AVB_ARG_NAME_INCLUDE_DESC_FROM_IMG: chained_image = split_args[index + 1] if os.path.exists(chained_image): continue Loading tools/releasetools/test_common.py +4 −3 Original line number Diff line number Diff line Loading @@ -1585,7 +1585,8 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase): info_dict = {} cmd = common.GetAvbPartitionArg('system', '/path/to/system.img', info_dict) self.assertEqual( ['--include_descriptors_from_image', '/path/to/system.img'], cmd) [common.AVB_ARG_NAME_INCLUDE_DESC_FROM_IMG, '/path/to/system.img'], cmd) @test_utils.SkipIfExternalToolsUnavailable() def test_AppendVBMetaArgsForPartition_vendorAsChainedPartition(self): Loading @@ -1598,7 +1599,7 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase): } cmd = common.GetAvbPartitionArg('vendor', '/path/to/vendor.img', info_dict) self.assertEqual(2, len(cmd)) self.assertEqual('--chain_partition', cmd[0]) self.assertEqual(common.AVB_ARG_NAME_CHAIN_PARTITION, cmd[0]) chained_partition_args = cmd[1].split(':') self.assertEqual(3, len(chained_partition_args)) self.assertEqual('vendor', chained_partition_args[0]) Loading Loading @@ -1631,7 +1632,7 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase): cmd = common.GetAvbPartitionArg( 'recovery', '/path/to/recovery.img', info_dict) self.assertEqual(2, len(cmd)) self.assertEqual('--chain_partition', cmd[0]) self.assertEqual(common.AVB_ARG_NAME_CHAIN_PARTITION, cmd[0]) chained_partition_args = cmd[1].split(':') self.assertEqual(3, len(chained_partition_args)) self.assertEqual('recovery', chained_partition_args[0]) Loading Loading
tools/releasetools/common.py +13 −8 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import copy import datetime import errno import fnmatch from genericpath import isdir import getopt import getpass import gzip Loading @@ -34,12 +33,13 @@ import re import shlex import shutil import subprocess import sys import stat import sys import tempfile import threading import time import zipfile from genericpath import isdir from hashlib import sha1, sha256 import images Loading Loading @@ -112,13 +112,18 @@ SPECIAL_CERT_STRINGS = ("PRESIGNED", "EXTERNAL") # descriptor into vbmeta.img. When adding a new entry here, the # AVB_FOOTER_ARGS_BY_PARTITION in sign_target_files_apks need to be updated # accordingly. AVB_PARTITIONS = ('boot', 'init_boot', 'dtbo', 'odm', 'product', 'pvmfw', 'recovery', 'system', 'system_ext', 'vendor', 'vendor_boot', 'vendor_kernel_boot', 'vendor_dlkm', 'odm_dlkm', 'system_dlkm') AVB_PARTITIONS = ('boot', 'init_boot', 'dtbo', 'odm', 'product', 'pvmfw', 'recovery', 'system', 'system_ext', 'vendor', 'vendor_boot', 'vendor_kernel_boot', 'vendor_dlkm', 'odm_dlkm', 'system_dlkm') # Chained VBMeta partitions. AVB_VBMETA_PARTITIONS = ('vbmeta_system', 'vbmeta_vendor') # avbtool arguments name AVB_ARG_NAME_INCLUDE_DESC_FROM_IMG = '--include_descriptors_from_image' AVB_ARG_NAME_CHAIN_PARTITION = '--chain_partition' # Partitions that should have their care_map added to META/care_map.pb PARTITIONS_WITH_CARE_MAP = [ 'system', Loading Loading @@ -1467,7 +1472,7 @@ def GetAvbPartitionArg(partition, image, info_dict=None): # Check if chain partition is used. key_path = info_dict.get("avb_" + partition + "_key_path") if not key_path: return ["--include_descriptors_from_image", image] return [AVB_ARG_NAME_INCLUDE_DESC_FROM_IMG, image] # For a non-A/B device, we don't chain /recovery nor include its descriptor # into vbmeta.img. The recovery image will be configured on an independent Loading @@ -1479,7 +1484,7 @@ def GetAvbPartitionArg(partition, image, info_dict=None): # Otherwise chain the partition into vbmeta. chained_partition_arg = GetAvbChainedPartitionArg(partition, info_dict) return ["--chain_partition", chained_partition_arg] return [AVB_ARG_NAME_CHAIN_PARTITION, chained_partition_arg] def GetAvbChainedPartitionArg(partition, info_dict, key=None): Loading Loading @@ -1598,7 +1603,7 @@ def BuildVBMeta(image_path, partitions, name, needed_partitions): # same location when running this script (we have the input target_files # zip only). For such cases, we additionally scan other locations (e.g. # IMAGES/, RADIO/, etc) before bailing out. if arg == '--include_descriptors_from_image': if arg == AVB_ARG_NAME_INCLUDE_DESC_FROM_IMG: chained_image = split_args[index + 1] if os.path.exists(chained_image): continue Loading
tools/releasetools/test_common.py +4 −3 Original line number Diff line number Diff line Loading @@ -1585,7 +1585,8 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase): info_dict = {} cmd = common.GetAvbPartitionArg('system', '/path/to/system.img', info_dict) self.assertEqual( ['--include_descriptors_from_image', '/path/to/system.img'], cmd) [common.AVB_ARG_NAME_INCLUDE_DESC_FROM_IMG, '/path/to/system.img'], cmd) @test_utils.SkipIfExternalToolsUnavailable() def test_AppendVBMetaArgsForPartition_vendorAsChainedPartition(self): Loading @@ -1598,7 +1599,7 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase): } cmd = common.GetAvbPartitionArg('vendor', '/path/to/vendor.img', info_dict) self.assertEqual(2, len(cmd)) self.assertEqual('--chain_partition', cmd[0]) self.assertEqual(common.AVB_ARG_NAME_CHAIN_PARTITION, cmd[0]) chained_partition_args = cmd[1].split(':') self.assertEqual(3, len(chained_partition_args)) self.assertEqual('vendor', chained_partition_args[0]) Loading Loading @@ -1631,7 +1632,7 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase): cmd = common.GetAvbPartitionArg( 'recovery', '/path/to/recovery.img', info_dict) self.assertEqual(2, len(cmd)) self.assertEqual('--chain_partition', cmd[0]) self.assertEqual(common.AVB_ARG_NAME_CHAIN_PARTITION, cmd[0]) chained_partition_args = cmd[1].split(':') self.assertEqual(3, len(chained_partition_args)) self.assertEqual('recovery', chained_partition_args[0]) Loading