am 1579e231: Merge "Support to build vendor.img" into jb-mr2-dev

* commit '1579e23178a6ae72bb3051a0385a1852dd970f1a':
  Support to build vendor.img
This commit is contained in:
Ying Wang 2013-03-25 20:53:39 +00:00 committed by Android Git Automerger
commit a5b29e212a
4 changed files with 131 additions and 40 deletions

View file

@ -588,6 +588,8 @@ $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTE
$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
$(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
@ -1021,6 +1023,39 @@ cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
# -----------------------------------------------------------------
# vendor partition image
ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
INTERNAL_VENDORIMAGE_FILES := \
$(filter $(TARGET_OUT_VENDOR)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
vendorimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,vendor)
BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
define build-vendorimage-target
$(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_VENDOR)
@mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
$(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
./build/tools/releasetools/build_image.py \
$(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET)
$(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE),yaffs)
endef
# We just build this directly to the install location.
INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES)
$(build-vendorimage-target)
.PHONY: vendorimage-nodeps
vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
$(build-vendorimage-target)
endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
# -----------------------------------------------------------------
# bring in the installer image generation defines if necessary
ifeq ($(TARGET_USE_DISKINSTALLER),true)
@ -1105,6 +1140,7 @@ $(BUILT_TARGET_FILES_PACKAGE): \
$(INSTALLED_SYSTEMIMAGE) \
$(INSTALLED_USERDATAIMAGE_TARGET) \
$(INSTALLED_CACHEIMAGE_TARGET) \
$(INSTALLED_VENDORIMAGE_TARGET) \
$(INSTALLED_ANDROID_INFO_TXT_TARGET) \
$(built_ota_tools) \
$(APKCERTS_FILE) \
@ -1162,6 +1198,11 @@ endif
@# Contents of the data image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_DATA),$(zip_root)/DATA)
ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
@# Contents of the vendor image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
endif
@# Extra contents of the OTA package
$(hide) mkdir -p $(zip_root)/OTA/bin
$(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
@ -1197,7 +1238,7 @@ endif
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/recovery_filesystem_config.txt
$(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
.PHONY: target-files-package
target-files-package: $(BUILT_TARGET_FILES_PACKAGE)

View file

@ -749,6 +749,9 @@ userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
.PHONY: cacheimage
cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
.PHONY: vendorimage
vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
.PHONY: bootimage
bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
@ -774,6 +777,7 @@ droidcore: files \
$(INSTALLED_RECOVERYIMAGE_TARGET) \
$(INSTALLED_USERDATAIMAGE_TARGET) \
$(INSTALLED_CACHEIMAGE_TARGET) \
$(INSTALLED_VENDORIMAGE_TARGET) \
$(INSTALLED_FILES_FILE)
# dist_files only for putting your library into the dist directory with a full build.

View file

@ -128,6 +128,9 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
elif mount_point == "cache":
copy_prop("cache_fs_type", "fs_type")
copy_prop("cache_size", "partition_size")
elif mount_point == "vendor":
copy_prop("vendor_fs_type", "fs_type")
copy_prop("vendor_size", "partition_size")
return d
@ -164,6 +167,8 @@ def main(argv):
mount_point = "data"
elif image_filename == "cache.img":
mount_point = "cache"
elif image_filename == "vendor.img":
mount_point = "vendor"
else:
print >> sys.stderr, "error: unknown image file name ", image_filename
exit(1)

View file

@ -52,6 +52,85 @@ import common
OPTIONS = common.OPTIONS
def AddSystem(output_zip):
"""Turn the contents of SYSTEM into a system image and store it in
output_zip."""
print "creating system.img..."
img = tempfile.NamedTemporaryFile()
# The name of the directory it is making an image out of matters to
# mkyaffs2image. It wants "system" but we have a directory named
# "SYSTEM", so create a symlink.
try:
os.symlink(os.path.join(OPTIONS.input_tmp, "SYSTEM"),
os.path.join(OPTIONS.input_tmp, "system"))
except OSError, e:
# bogus error on my mac version?
# File "./build/tools/releasetools/img_from_target_files", line 86, in AddSystem
# os.path.join(OPTIONS.input_tmp, "system"))
# OSError: [Errno 17] File exists
if (e.errno == errno.EEXIST):
pass
image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict,
"system")
fstab = OPTIONS.info_dict["fstab"]
if fstab:
image_props["fs_type" ] = fstab["/system"].fs_type
succ = build_image.BuildImage(os.path.join(OPTIONS.input_tmp, "system"),
image_props, img.name)
assert succ, "build system.img image failed"
img.seek(os.SEEK_SET, 0)
data = img.read()
img.close()
common.CheckSize(data, "system.img", OPTIONS.info_dict)
common.ZipWriteStr(output_zip, "system.img", 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."""
@ -117,45 +196,6 @@ def AddCache(output_zip):
os.rmdir(temp_dir)
def AddSystem(output_zip):
"""Turn the contents of SYSTEM into a system image and store it in
output_zip."""
print "creating system.img..."
img = tempfile.NamedTemporaryFile()
# The name of the directory it is making an image out of matters to
# mkyaffs2image. It wants "system" but we have a directory named
# "SYSTEM", so create a symlink.
try:
os.symlink(os.path.join(OPTIONS.input_tmp, "SYSTEM"),
os.path.join(OPTIONS.input_tmp, "system"))
except OSError, e:
# bogus error on my mac version?
# File "./build/tools/releasetools/img_from_target_files", line 86, in AddSystem
# os.path.join(OPTIONS.input_tmp, "system"))
# OSError: [Errno 17] File exists
if (e.errno == errno.EEXIST):
pass
image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict,
"system")
fstab = OPTIONS.info_dict["fstab"]
if fstab:
image_props["fs_type" ] = fstab["/system"].fs_type
succ = build_image.BuildImage(os.path.join(OPTIONS.input_tmp, "system"),
image_props, img.name)
assert succ, "build system.img image failed"
img.seek(os.SEEK_SET, 0)
data = img.read()
img.close()
common.CheckSize(data, "system.img", OPTIONS.info_dict)
common.ZipWriteStr(output_zip, "system.img", data)
def CopyInfo(output_zip):
"""Copy the android-info.txt file from the input to the output."""
output_zip.write(os.path.join(OPTIONS.input_tmp, "OTA", "android-info.txt"),
@ -199,6 +239,7 @@ def main(argv):
if not bootable_only:
AddSystem(output_zip)
AddVendor(output_zip)
AddUserdata(output_zip)
AddCache(output_zip)
CopyInfo(output_zip)