releasetools: Support verifying files with non-monotonic ranges.
Fixes: 79951650
Test: Run validate_target_files on target_files.zip with files in
non-monotonic ranges.
Test: python -m unittest test_validate_target_files
Test: python3 -m unittest test_validate_target_files
Change-Id: I82571d3358598775de4cdeb5e64035689fea6487
diff --git a/tools/releasetools/sparse_img.py b/tools/releasetools/sparse_img.py
index 3367896..a249081 100644
--- a/tools/releasetools/sparse_img.py
+++ b/tools/releasetools/sparse_img.py
@@ -249,8 +249,9 @@
with open(fn) as f:
for line in f:
- fn, ranges = line.split(None, 1)
- ranges = rangelib.RangeSet.parse(ranges)
+ fn, ranges_text = line.rstrip().split(None, 1)
+ ranges = rangelib.RangeSet.parse(ranges_text)
+ ranges.extra['text_str'] = ranges_text
if allow_shared_blocks:
# Find the shared blocks that have been claimed by others. If so, tag
@@ -261,9 +262,6 @@
if not non_shared:
continue
- # There shouldn't anything in the extra dict yet.
- assert not ranges.extra, "Non-empty RangeSet.extra"
-
# Put the non-shared RangeSet as the value in the block map, which
# has a copy of the original RangeSet.
non_shared.extra['uses_shared_blocks'] = ranges