summaryrefslogtreecommitdiffstats
path: root/tools/releasetools/img_from_target_files.py
diff options
context:
space:
mode:
authorDoug Zongker <dougz@google.com>2014-06-16 15:16:31 -0700
committerDoug Zongker <dougz@google.com>2014-06-16 15:39:54 -0700
commitc8b4e849f10f3a382694b00453b3f49608c83b48 (patch)
treec54d82b98530a5e82cbbca361ec5073f70545083 /tools/releasetools/img_from_target_files.py
parent4b445e89989845b5e8109caf96a8f32d8d7fe788 (diff)
downloadbuild-c8b4e849f10f3a382694b00453b3f49608c83b48.zip
build-c8b4e849f10f3a382694b00453b3f49608c83b48.tar.gz
build-c8b4e849f10f3a382694b00453b3f49608c83b48.tar.bz2
full support for OTA of vendor partitions
Make vendor partition a first-class member of the OTA system (for target_files that contain a VENDOR/ subdirectory). Build vendor images in a way that is compatible with block-based OTA. Support updating the vendor partition in both full and incremental, block and file OTAs. In most cases this is handled by refactoring the existing code to handle the system partition to handle either, and then calling it twice. Currently we don't support incremental OTAs from a target-files without a VENDOR subdirectory to one with one, or vice versa. To add or remove a vendor partition a full OTA will need to be done. Bug: 15544685 Change-Id: I9cb9a1267060bd9683a9bea19b43a26b5a43800d
Diffstat (limited to 'tools/releasetools/img_from_target_files.py')
-rwxr-xr-xtools/releasetools/img_from_target_files.py90
1 files changed, 40 insertions, 50 deletions
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 2ca9316..6043355 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -59,9 +59,21 @@ def AddSystem(output_zip, sparse=True):
data = BuildSystem(OPTIONS.input_tmp, OPTIONS.info_dict, sparse=sparse)
common.ZipWriteStr(output_zip, "system.img", data)
-
def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
- print "creating system.img..."
+ return CreateImage(input_dir, info_dict, "system",
+ sparse=sparse, map_file=map_file)
+
+def AddVendor(output_zip, sparse=True):
+ data = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict, sparse=sparse)
+ common.ZipWriteStr(output_zip, "vendor.img", data)
+
+def BuildVendor(input_dir, info_dict, sparse=True, map_file=None):
+ return CreateImage(input_dir, info_dict, "vendor",
+ sparse=sparse, map_file=map_file)
+
+
+def CreateImage(input_dir, info_dict, what, sparse=True, map_file=None):
+ print "creating " + what + ".img..."
img = tempfile.NamedTemporaryFile()
@@ -69,8 +81,8 @@ def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
# mkyaffs2image. It wants "system" but we have a directory named
# "SYSTEM", so create a symlink.
try:
- os.symlink(os.path.join(input_dir, "SYSTEM"),
- os.path.join(input_dir, "system"))
+ os.symlink(os.path.join(input_dir, what.upper()),
+ os.path.join(input_dir, what))
except OSError, e:
# bogus error on my mac version?
# File "./build/tools/releasetools/img_from_target_files", line 86, in AddSystem
@@ -79,22 +91,28 @@ def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
if (e.errno == errno.EEXIST):
pass
- image_props = build_image.ImagePropFromGlobalDict(info_dict, "system")
+ image_props = build_image.ImagePropFromGlobalDict(info_dict, what)
fstab = info_dict["fstab"]
if fstab:
- image_props["fs_type" ] = fstab["/system"].fs_type
+ image_props["fs_type" ] = fstab["/" + what].fs_type
+
+ if what == "system":
+ fs_config_prefix = ""
+ else:
+ fs_config_prefix = what + "_"
- fs_config = os.path.join(input_dir, "META/filesystem_config.txt")
+ fs_config = os.path.join(
+ input_dir, "META/" + fs_config_prefix + "filesystem_config.txt")
if not os.path.exists(fs_config): fs_config = None
fc_config = os.path.join(input_dir, "BOOT/RAMDISK/file_contexts")
if not os.path.exists(fc_config): fc_config = None
- succ = build_image.BuildImage(os.path.join(input_dir, "system"),
+ succ = build_image.BuildImage(os.path.join(input_dir, what),
image_props, img.name,
fs_config=fs_config,
fc_config=fc_config)
- assert succ, "build system.img image failed"
+ assert succ, "build " + what + ".img image failed"
mapdata = None
@@ -104,7 +122,7 @@ def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
else:
success, name = build_image.UnsparseImage(img.name, replace=False)
if not success:
- assert False, "unsparsing system.img failed"
+ assert False, "unsparsing " + what + ".img failed"
if map_file:
mmap = tempfile.NamedTemporaryFile()
@@ -131,45 +149,6 @@ def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
return mapdata, data
-def AddVendor(output_zip):
- """Turn the contents of VENDOR into vendor.img and store it in
- output_zip."""
-
- image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict,
- "vendor")
- # The build system has to explicitly request for vendor.img.
- if "fs_type" not in image_props:
- return
-
- print "creating vendor.img..."
-
- img = tempfile.NamedTemporaryFile()
-
- # The name of the directory it is making an image out of matters to
- # mkyaffs2image. It wants "vendor" but we have a directory named
- # "VENDOR", so create a symlink or an empty directory if VENDOR does not
- # exist.
- if not os.path.exists(os.path.join(OPTIONS.input_tmp, "vendor")):
- if os.path.exists(os.path.join(OPTIONS.input_tmp, "VENDOR")):
- os.symlink(os.path.join(OPTIONS.input_tmp, "VENDOR"),
- os.path.join(OPTIONS.input_tmp, "vendor"))
- else:
- os.mkdir(os.path.join(OPTIONS.input_tmp, "vendor"))
-
- img = tempfile.NamedTemporaryFile()
-
- fstab = OPTIONS.info_dict["fstab"]
- if fstab:
- image_props["fs_type" ] = fstab["/vendor"].fs_type
- succ = build_image.BuildImage(os.path.join(OPTIONS.input_tmp, "vendor"),
- image_props, img.name)
- assert succ, "build vendor.img image failed"
-
- common.CheckSize(img.name, "vendor.img", OPTIONS.info_dict)
- output_zip.write(img.name, "vendor.img")
- img.close()
-
-
def AddUserdata(output_zip):
"""Create an empty userdata image and store it in output_zip."""
@@ -287,10 +266,21 @@ def main(argv):
if recovery_image:
recovery_image.AddToZip(output_zip)
+ def banner(s):
+ print "\n\n++++ " + s + " ++++\n\n"
+
if not bootable_only:
+ banner("AddSystem")
AddSystem(output_zip)
- AddVendor(output_zip)
+ try:
+ input_zip.getinfo("VENDOR/")
+ banner("AddVendor")
+ AddVendor(output_zip)
+ except KeyError:
+ pass # no vendor partition for this device
+ banner("AddUserdata")
AddUserdata(output_zip)
+ banner("AddCache")
AddCache(output_zip)
CopyInfo(output_zip)