releasetools: Keep the original RangeSet for 'uses_shared_blocks' case.
Setting 'uses_shared_blocks' indicates that the block list for a given
file is incomplete, as some of the blocks are "owned" by others. As a
result, such a file will be skipped from imgdiff'ing.
This CL makes a copy of the original block list before removing the
shared blocks. It uses the original RangeSet as the value of
extra['uses_shared_blocks']. validate_target_files.py will try to read
the file as in the original RangeSet, unless the original list is also
incomplete or has non-monotonic ranges.
Test: Run validate_target_files on a target that uses
`BOARD_EXT4_SHARE_DUP_BLOCKS := true`.
Change-Id: I259e871ecc249ba0c14b5796bef413185a1b8242
diff --git a/tools/releasetools/validate_target_files.py b/tools/releasetools/validate_target_files.py
index ae8253d..eeb802b 100755
--- a/tools/releasetools/validate_target_files.py
+++ b/tools/releasetools/validate_target_files.py
@@ -89,13 +89,20 @@
logging.warning('Skipping %s that has incomplete block list', entry)
continue
+ # Use the original RangeSet if applicable, which includes the shared
+ # blocks. And this needs to happen before checking the monotonicity flag.
+ if ranges.extra.get('uses_shared_blocks'):
+ file_ranges = ranges.extra['uses_shared_blocks']
+ else:
+ file_ranges = ranges
+
# TODO(b/79951650): Handle files with non-monotonic ranges.
- if not ranges.monotonic:
+ if not file_ranges.monotonic:
logging.warning(
- 'Skipping %s that has non-monotonic ranges: %s', entry, ranges)
+ 'Skipping %s that has non-monotonic ranges: %s', entry, file_ranges)
continue
- blocks_sha1 = image.RangeSha1(ranges)
+ blocks_sha1 = image.RangeSha1(file_ranges)
# The filename under unpacked directory, such as SYSTEM/bin/sh.
unpacked_name = os.path.join(
@@ -104,7 +111,7 @@
file_sha1 = unpacked_file.sha1
assert blocks_sha1 == file_sha1, \
'file: %s, range: %s, blocks_sha1: %s, file_sha1: %s' % (
- entry, ranges, blocks_sha1, file_sha1)
+ entry, file_ranges, blocks_sha1, file_sha1)
logging.info('Validating file consistency.')
@@ -311,9 +318,9 @@
if info_dict.get("avb_enable") == "true":
logging.info('Verifying Verified Boot 2.0 (AVB) images...')
- # Temporarily disable the verification for AVB-signed images, due to the
- # dependency on PyCrypto in `avbtool verify_image` (Bug: 119624011).
- logging.info('Temporarily disabled due to b/119624011')
+ # TODO(b/120517892): Temporarily disable the verification for AVB-signed
+ # images. Needing supporting changes in caller to pass in the desired keys.
+ logging.info('Temporarily disabled due to b/120517892')
def main():