Skip userdata.img if no size is provided when building images from target files
Change-Id: Iab5c510fcc7608c4b109781e6595ab8964f4c543
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files
index 002e6e6..ec6e7c6 100755
--- a/tools/releasetools/img_from_target_files
+++ b/tools/releasetools/img_from_target_files
@@ -55,6 +55,12 @@
def AddUserdata(output_zip):
"""Create an empty userdata image and store it in output_zip."""
+ image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict,
+ "data")
+ # If no userdata_size is provided, skip userdata.img.
+ if not image_props.get("userdata_size"):
+ return
+
print "creating userdata.img..."
# The name of the directory it is making an image out of matters to
@@ -65,8 +71,6 @@
os.mkdir(user_dir)
img = tempfile.NamedTemporaryFile()
- image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict,
- "data")
fstab = OPTIONS.info_dict["fstab"]
if fstab:
image_props["fs_type" ] = fstab["/data"].fs_type