diff options
author | Ying Wang <wangying@google.com> | 2011-11-04 11:37:01 -0700 |
---|---|---|
committer | Ying Wang <wangying@google.com> | 2011-11-10 14:30:34 -0800 |
commit | 9f8e8db188371cb3787a91a03d193f87ad244ea3 (patch) | |
tree | ee9f126715d9889a03269450960693a1044f2adf /tools/releasetools/img_from_target_files | |
parent | ba2c734f71202522464db540260b0df696d26c06 (diff) | |
download | build-9f8e8db188371cb3787a91a03d193f87ad244ea3.zip build-9f8e8db188371cb3787a91a03d193f87ad244ea3.tar.gz build-9f8e8db188371cb3787a91a03d193f87ad244ea3.tar.bz2 |
Build cache.img on demand
Bug: 5153694
To build cache.img, set BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE (required,
ext4 only for now), BOARD_CACHEIMAGE_PARTITION_SIZE (optional) in
BoardConfig.mk.
Change-Id: I1d8b91646aa1dba88285e008ad3335768bcbddd2
Diffstat (limited to 'tools/releasetools/img_from_target_files')
-rwxr-xr-x | tools/releasetools/img_from_target_files | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files index 4388f69..002e6e6 100755 --- a/tools/releasetools/img_from_target_files +++ b/tools/releasetools/img_from_target_files @@ -80,6 +80,38 @@ def AddUserdata(output_zip): os.rmdir(temp_dir) +def AddCache(output_zip): + """Create an empty cache image and store it in output_zip.""" + + image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, + "cache") + # The build system has to explicitly request for cache.img. + if "fs_type" not in image_props: + return + + print "creating cache.img..." + + # The name of the directory it is making an image out of matters to + # mkyaffs2image. So we create a temp dir, and within it we create an + # empty dir named "cache", and build the image from that. + temp_dir = tempfile.mkdtemp() + user_dir = os.path.join(temp_dir, "cache") + os.mkdir(user_dir) + img = tempfile.NamedTemporaryFile() + + fstab = OPTIONS.info_dict["fstab"] + if fstab: + image_props["fs_type" ] = fstab["/cache"].fs_type + succ = build_image.BuildImage(user_dir, image_props, img.name) + assert succ, "build cache.img image failed" + + common.CheckSize(img.name, "cache.img", OPTIONS.info_dict) + output_zip.write(img.name, "cache.img") + img.close() + os.rmdir(user_dir) + os.rmdir(temp_dir) + + def AddSystem(output_zip): """Turn the contents of SYSTEM into a system image and store it in output_zip.""" @@ -163,6 +195,7 @@ def main(argv): if not bootable_only: AddSystem(output_zip) AddUserdata(output_zip) + AddCache(output_zip) CopyInfo(output_zip) print "cleaning up..." |