Merge "save file block allocations in target_files" into lmp-dev

This commit is contained in:
Doug Zongker 2014-08-13 00:18:12 +00:00 committed by Android (Google) Code Review
commit ad876835c4
3 changed files with 29 additions and 9 deletions

View File

@ -49,23 +49,38 @@ OPTIONS = common.OPTIONS
def AddSystem(output_zip, sparse=True, prefix="IMAGES/"):
"""Turn the contents of SYSTEM into a system image and store it in
output_zip."""
data = BuildSystem(OPTIONS.input_tmp, OPTIONS.info_dict, sparse=sparse)
block_list = tempfile.NamedTemporaryFile()
data = BuildSystem(OPTIONS.input_tmp, OPTIONS.info_dict, sparse=sparse,
block_list=block_list.name)
common.ZipWriteStr(output_zip, prefix + "system.img", data)
with open(block_list.name, "rb") as f:
block_list_data = f.read()
common.ZipWriteStr(output_zip, prefix + "system.map", block_list_data)
block_list.close()
def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
def BuildSystem(input_dir, info_dict, sparse=True, map_file=None,
block_list=None):
return CreateImage(input_dir, info_dict, "system",
sparse=sparse, map_file=map_file)
sparse=sparse, map_file=map_file, block_list=block_list)
def AddVendor(output_zip, sparse=True, prefix="IMAGES/"):
data = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict, sparse=sparse)
block_list = tempfile.NamedTemporaryFile()
data = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict, sparse=sparse,
block_list=block_list.name)
common.ZipWriteStr(output_zip, prefix + "vendor.img", data)
with open(block_list.name, "rb") as f:
block_list_data = f.read()
common.ZipWriteStr(output_zip, prefix + "vendor.map", block_list_data)
block_list.close()
def BuildVendor(input_dir, info_dict, sparse=True, map_file=None):
def BuildVendor(input_dir, info_dict, sparse=True, map_file=None,
block_list=None):
return CreateImage(input_dir, info_dict, "vendor",
sparse=sparse, map_file=map_file)
sparse=sparse, map_file=map_file, block_list=block_list)
def CreateImage(input_dir, info_dict, what, sparse=True, map_file=None):
def CreateImage(input_dir, info_dict, what, sparse=True, map_file=None,
block_list=None):
print "creating " + what + ".img..."
img = tempfile.NamedTemporaryFile()
@ -104,7 +119,8 @@ def CreateImage(input_dir, info_dict, what, sparse=True, map_file=None):
succ = build_image.BuildImage(os.path.join(input_dir, what),
image_props, img.name,
fs_config=fs_config,
fc_config=fc_config)
fc_config=fc_config,
block_list=block_list)
assert succ, "build " + what + ".img image failed"
mapdata = None

View File

@ -209,7 +209,8 @@ def MakeVerityEnabledImage(out_file, prop_dict):
def BuildImage(in_dir, prop_dict, out_file,
fs_config=None,
fc_config=None):
fc_config=None,
block_list=None):
"""Build an image to out_file from in_dir with property prop_dict.
Args:
@ -252,6 +253,8 @@ def BuildImage(in_dir, prop_dict, out_file,
build_command.extend(["-T", str(prop_dict["timestamp"])])
if fs_config is not None:
build_command.extend(["-C", fs_config])
if block_list is not None:
build_command.extend(["-B", block_list])
if fc_config is not None:
build_command.append(fc_config)
elif "selinux_fc" in prop_dict:

View File

@ -90,6 +90,7 @@ def main(argv):
if images:
for i in images:
if bootable_only and i not in ("boot.img", "recovery.img"): continue
if not i.endswith(".img"): continue
with open(os.path.join(images_path, i), "r") as f:
common.ZipWriteStr(output_zip, i, f.read())
done = True