summaryrefslogtreecommitdiffstats
path: root/tools/releasetools
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-06-26 17:49:39 -0700
committerSimon Wilson <simonwilson@google.com>2015-07-01 11:24:30 -0700
commit1aa1af0e997699bc025e4f0a754692068328d7e6 (patch)
tree3cb5701ccd7b24904b138ae8453674bfe184a8ef /tools/releasetools
parent16401ad4256178fbe7a2cd8588e6dbf9a6c63180 (diff)
downloadbuild-1aa1af0e997699bc025e4f0a754692068328d7e6.zip
build-1aa1af0e997699bc025e4f0a754692068328d7e6.tar.gz
build-1aa1af0e997699bc025e4f0a754692068328d7e6.tar.bz2
sparse_img.py: Don't write empty map groups.
In certain cases, we may have no mapping of ZERO or NONZERO blocks in the image (such as squashfs at the moment). Don't write those groups if they are empty. Change-Id: I4a1f0105ada2e1573c3d6162457b83725e0d8971
Diffstat (limited to 'tools/releasetools')
-rw-r--r--tools/releasetools/sparse_img.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/releasetools/sparse_img.py b/tools/releasetools/sparse_img.py
index 7574747..820d85b 100644
--- a/tools/releasetools/sparse_img.py
+++ b/tools/releasetools/sparse_img.py
@@ -204,8 +204,12 @@ class SparseImage(object):
nonzero_blocks.append(b)
nonzero_blocks.append(b+1)
- out["__ZERO"] = RangeSet(data=zero_blocks)
- out["__NONZERO"] = RangeSet(data=nonzero_blocks)
+ assert zero_blocks or nonzero_blocks
+
+ if zero_blocks:
+ out["__ZERO"] = RangeSet(data=zero_blocks)
+ if nonzero_blocks:
+ out["__NONZERO"] = RangeSet(data=nonzero_blocks)
def ResetFileMap(self):
"""Throw away the file map and treat the entire image as