handle don't care regions in the system image

The system partitions has regions that we shouldn't write and can't
depend on the contents of.  Adds a new script to generate a map of
these regions (using the sparse image as input), and include the map
in the package zip so it can be used when writing or patching the
system partition.

Also fixes a bug where the wrong SELinux file contexts are used when
generating incrementals.

Change-Id: Iaca5b967a3b7d1df843c7c21becc19b3f1633dad
This commit is contained in:
Doug Zongker
2014-02-24 08:13:45 -08:00
parent 7676dbe03e
commit 5fad2039bb
7 changed files with 228 additions and 19 deletions

View File

@@ -60,7 +60,7 @@ def AddSystem(output_zip, sparse=True):
common.ZipWriteStr(output_zip, "system.img", data)
def BuildSystem(input_dir, info_dict, sparse=True):
def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
print "creating system.img..."
img = tempfile.NamedTemporaryFile()
@@ -87,6 +87,8 @@ def BuildSystem(input_dir, info_dict, sparse=True):
image_props, img.name)
assert succ, "build system.img image failed"
mapdata = None
if sparse:
img.seek(os.SEEK_SET, 0)
data = img.read()
@@ -95,13 +97,30 @@ def BuildSystem(input_dir, info_dict, sparse=True):
success, name = build_image.UnsparseImage(img.name, replace=False)
if not success:
assert False, "unsparsing system.img failed"
if map_file:
mmap = tempfile.NamedTemporaryFile()
mimg = tempfile.NamedTemporaryFile(delete=False)
success = build_image.MappedUnsparseImage(
img.name, name, mmap.name, mimg.name)
if not success:
assert False, "creating sparse map failed"
os.unlink(name)
name = mimg.name
with open(mmap.name) as f:
mapdata = f.read()
try:
with open(name) as f:
data = f.read()
finally:
os.unlink(name)
return data
if mapdata is None:
return data
else:
return mapdata, data
def AddVendor(output_zip):