Make the partition= tag optional.

Since we might use ToT release tools to sign a package
generated by an older build, we make the new
`partition=` tag optional. This also means we need to be
careful to use non-greedy regex matching.

Bug: 153133823
Test: python3 -m unittest
Test: input with and without the new `partition=` tag
Test: new test_ReadApkCerts_WithWithoutOptionalFields
Change-Id: Ic57efd34e745ad302ae17150c6f2318f0b4524cb
This commit is contained in:
Bill Peckham
2020-04-03 15:36:23 -07:00
parent 40ddffe600
commit 5c7b034a5c
5 changed files with 44 additions and 12 deletions

View File

@@ -117,14 +117,15 @@ OPTIONS.keep_tmp = False
PARTITION_ITEM_PATTERN = re.compile(r'^([A-Z_]+)/\*$')
# In apexkeys.txt or apkcerts.txt, we may find partition tags on the various
# entries in the file. We use these partition tags to filter the entries in
# those files from the two different target files packages to produce a merged
# apexkeys.txt or apkcerts.txt file. A partition tag (e.g., for the product
# partition) looks like this: 'partition="_PRODUCT"' or 'partition="product".
# We use the group syntax grab the value of the tag.
# In apexkeys.txt or apkcerts.txt, we will find partition tags on each entry in
# the file. We use these partition tags to filter the entries in those files
# from the two different target files packages to produce a merged apexkeys.txt
# or apkcerts.txt file. A partition tag (e.g., for the product partition) looks
# like this: 'partition="product"'. We use the group syntax grab the value of
# the tag. We use non-greedy matching in case there are other fields on the
# same line.
PARTITION_TAG_PATTERN = re.compile(r'partition="(.*)"')
PARTITION_TAG_PATTERN = re.compile(r'partition="(.*?)"')
# The sorting algorithm for apexkeys.txt and apkcerts.txt does not include the
# ".apex" or ".apk" suffix, so we use the following pattern to extract a key.