summaryrefslogtreecommitdiffstats
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 10:10:31 -0700
commit7f9470cda390ee61c0fc71491d0c649fbf6e02dd (patch)
tree5a0501e3b793531059fc1945ce065b4491d742b9
parentef5dc90bba179f774bee0c7e479965cef12091de (diff)
downloadbuild-7f9470cda390ee61c0fc71491d0c649fbf6e02dd.zip
build-7f9470cda390ee61c0fc71491d0c649fbf6e02dd.tar.gz
build-7f9470cda390ee61c0fc71491d0c649fbf6e02dd.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: I82aa05fbbd79130b08868585edd5298e531c4f5a
-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..59d2b71 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"] = rangelib.RangeSet(data=zero_blocks)
+ if nonzero_blocks:
+ out["__NONZERO"] = rangelib.RangeSet(data=nonzero_blocks)
def ResetFileMap(self):
"""Throw away the file map and treat the entire image as