summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDiogo Ferreira <diogo@underdev.org>2015-09-04 11:59:13 +0100
committerEdward Wang <ewang@cyngn.com>2016-04-15 11:32:30 -0700
commitc9c78dbd214d3ca9e79788c3406a40cb80638dcb (patch)
tree8434c3ac21d395d87606826f9e7eb51258c69842 /tools
parent4bbce4fdc6186d3dd6986daff4fc5ce6dc918421 (diff)
downloadbuild-c9c78dbd214d3ca9e79788c3406a40cb80638dcb.zip
build-c9c78dbd214d3ca9e79788c3406a40cb80638dcb.tar.gz
build-c9c78dbd214d3ca9e79788c3406a40cb80638dcb.tar.bz2
build: Create a oem image when BOARD_OEMIMAGE_FILE_SYSTEM_TYPE is defined
This adds the capability of generating a OEM image with the build and adding it to target files when BOARD_OEMIMAGE_FILE_SYSTEM_TYPE is set. Change-Id: I6c596d58d9d5ece1a261d953eeb8c60eac30e642 Ticket: CYNGNOS-936 (cherry picked from commit 1966a9e7c22b95eb4c16be6aee7adf43cb6ce118)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/releasetools/add_img_to_target_files.py33
-rwxr-xr-xtools/releasetools/img_from_target_files.py6
2 files changed, 39 insertions, 0 deletions
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index b132963..b699135 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -100,6 +100,29 @@ def BuildVendor(input_dir, info_dict, block_list=None):
file containing it."""
return CreateImage(input_dir, info_dict, "vendor", block_list=block_list)
+def AddOem(output_zip, prefix="IMAGES/"):
+ """Turn the contents of OEM into a oem image and store in it
+ output_zip."""
+
+ prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "oem.img")
+ if os.path.exists(prebuilt_path):
+ print("oem.img already exists in %s, no need to rebuild..." % prefix)
+ return
+
+ block_list = common.MakeTempFile(prefix="oem-blocklist-", suffix=".map")
+ imgname = BuildOem(OPTIONS.input_tmp, OPTIONS.info_dict,
+ block_list=block_list)
+ with open(imgname, "rb") as f:
+ common.ZipWriteStr(output_zip, prefix + "oem.img", f.read())
+ with open(block_list, "rb") as f:
+ common.ZipWriteStr(output_zip, prefix + "oem.map", f.read())
+
+
+def BuildOem(input_dir, info_dict, block_list=None):
+ """Build the (sparse) oem image and return the name of a temp
+ file containing it."""
+ return CreateImage(input_dir, info_dict, "oem", block_list=block_list)
+
def CreateImage(input_dir, info_dict, what, block_list=None):
print("creating " + what + ".img...")
@@ -314,6 +337,12 @@ def AddImagesToTargetFiles(filename):
except KeyError:
has_vendor = False
+ try:
+ input_zip.getinfo("OEM/")
+ has_oem = True
+ except KeyError:
+ has_oem = False
+
OPTIONS.info_dict = common.LoadInfoDict(input_zip)
if "selinux_fc" in OPTIONS.info_dict:
OPTIONS.info_dict["selinux_fc"] = os.path.join(
@@ -365,6 +394,10 @@ def AddImagesToTargetFiles(filename):
AddUserdataExtra(output_zip)
banner("cache")
AddCache(output_zip)
+ if has_oem:
+ banner("oem")
+ AddOem(output_zip)
+
common.ZipClose(output_zip)
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index d486a7a..e9f9af6 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -165,6 +165,12 @@ def main(argv):
add_img_to_target_files.AddUserdataExtra(output_zip, prefix="")
banner("AddCache")
add_img_to_target_files.AddCache(output_zip, prefix="")
+ try:
+ input_zip.getinfo("OEM/")
+ banner("AddOem")
+ add_img_to_target_files.AddOem(output_zip, prefix="")
+ except KeyError:
+ pass # no oem partition for this device
finally:
print("cleaning up...")