Updating security patch string to 2016-03-01 am: c24c6ccd4d am: 293887c43e am: 53e7d9bf7f am: c9da4cce57 am: 6c61548bb7 am: 6facd249d5
am: 1b29f2f9c9
* commit '1b29f2f9c97bc1b099712cd7c93c31e7f7a18ad1':
Updating security patch string to 2016-03-01
diff --git a/core/Makefile b/core/Makefile
index 07d1c94..8de935c 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -203,6 +203,8 @@
BUILD_ID="$(BUILD_ID)" \
BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
BUILD_NUMBER="$(BUILD_NUMBER)" \
+ BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
+ AB_OTA_UPDATER="$(AB_OTA_UPDATER)" \
PLATFORM_VERSION="$(PLATFORM_VERSION)" \
PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \
PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \
@@ -816,8 +818,15 @@
else
recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
endif
+
+ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
# Named '.dat' so we don't attempt to use imgdiff for patching it.
RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
+else
+# We carry a full copy of the recovery image. recovery-resource.dat is no
+# longer needed.
+RECOVERY_RESOURCE_ZIP :=
+endif
ifeq ($(recovery_resources_private),)
$(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
@@ -869,7 +878,7 @@
$(hide) mkdir -p $(TARGET_RECOVERY_OUT)
$(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp
@echo Copying baseline ramdisk...
- $(hide) rsync -a $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) # "cp -Rf" fails to overwrite broken symlinks on Mac.
+ $(hide) rsync -a --exclude=etc $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) # "cp -Rf" fails to overwrite broken symlinks on Mac.
@echo Modifying ramdisk contents...
$(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
$(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
@@ -887,6 +896,10 @@
$(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
$(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
> $(TARGET_RECOVERY_ROOT_OUT)/default.prop
+ $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)), \
+ $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system_root; \
+ rm -rf $(TARGET_RECOVERY_ROOT_OUT)/system; \
+ ln -sf /system_root/system $(TARGET_RECOVERY_ROOT_OUT)/system) # Mount the system_root_image to /system_root and symlink /system.
$(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
$(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
$(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
@@ -910,16 +923,19 @@
$(RECOVERY_INSTALL_OTA_KEYS)
$(call build-recoveryimage-target, $@)
+ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
$(hide) mkdir -p $(dir $@)
$(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
+endif
.PHONY: recoveryimage-nodeps
recoveryimage-nodeps:
@echo "make $@: ignoring dependencies"
$(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
-else
+else # ! ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
+INSTALLED_RECOVERYIMAGE_TARGET :=
RECOVERY_RESOURCE_ZIP :=
endif
@@ -1026,6 +1042,7 @@
# we can see how big it's going to be, and include that in the system
# image size check calculation.
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
+ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
@@ -1035,6 +1052,9 @@
@echo "Construct recovery from boot"
mkdir -p $(dir $@)
PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
+else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
+RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
+endif
endif
@@ -1417,6 +1437,7 @@
@echo "Package target files: $@"
$(hide) rm -rf $@ $(zip_root)
$(hide) mkdir -p $(dir $@) $(zip_root)
+ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
@# Components of the recovery image
$(hide) mkdir -p $(zip_root)/RECOVERY
$(hide) $(call package_files-copy-root, \
@@ -1437,10 +1458,17 @@
ifdef BOARD_KERNEL_PAGESIZE
$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
endif
+endif
@# Components of the boot image
$(hide) mkdir -p $(zip_root)/BOOT
+ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
+ $(hide) mkdir -p $(zip_root)/ROOT
+ $(hide) $(call package_files-copy-root, \
+ $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
+else
$(hide) $(call package_files-copy-root, \
$(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
+endif
ifdef INSTALLED_KERNEL_TARGET
$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
endif
@@ -1481,6 +1509,7 @@
$(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
$(hide) if test -e $(tool_extensions)/releasetools.py; then $(ACP) $(tool_extensions)/releasetools.py $(zip_root)/META/; fi
$(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
+ $(hide) $(ACP) $(SELINUX_FC) $(zip_root)/META/file_contexts
$(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
$(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
ifdef BOARD_FLASH_BLOCK_SIZE
@@ -1489,6 +1518,9 @@
ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
$(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
endif
+ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
+ $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt
+endif
ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
$(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
endif
@@ -1515,17 +1547,35 @@
# OTA scripts are only interested in fingerprint related properties
$(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
endif
+ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
+ $(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt
+endif
$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
+ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
+endif
+ifeq ($(AB_OTA_UPDATER),true)
+ @# When using the A/B updater, include the updater config files in the zip.
+ $(hide) $(ACP) $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
+ $(hide) for part in $(AB_OTA_PARTITIONS); do \
+ echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
+ done
+endif
@# Zip everything up, preserving symlinks
$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
@# Run fs_config on all the system, vendor, boot ramdisk,
@# and recovery ramdisk files in the zip, and save the output
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt
+ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
+ $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="ROOT/" } /^ROOT\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT)-S $(SELINUX_FC) > $(zip_root)/META/root_filesystem_config.txt
+else
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
+endif
+ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
+endif
$(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
./build/tools/releasetools/add_img_to_target_files -p $(HOST_OUT) $@
diff --git a/core/binary.mk b/core/binary.mk
index b8003d7..e6ad788 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -587,6 +587,38 @@
endif # $(proto_sources) non-empty
###########################################################
+## AIDL: Compile .aidl files to .cpp and .h files
+###########################################################
+aidl_src := $(strip $(filter %.aidl,$(my_src_files)))
+aidl_gen_cpp :=
+ifneq ($(aidl_src),)
+
+aidl_gen_cpp_root := $(intermediates)/aidl-generated/src
+aidl_gen_include_root := $(intermediates)/aidl-generated/include
+
+aidl_gen_cpp := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(aidl_src))
+aidl_gen_cpp := $(addprefix $(aidl_gen_cpp_root)/,$(aidl_gen_cpp))
+
+# TODO(wiley): we could pass down a flag here to only generate the server or
+# client side of the binder interface.
+$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
+$(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root)
+$(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
+
+# Multi-architecture builds have distinct intermediates directories.
+# Define rules for both architectures.
+$(aidl_gen_cpp) : $(aidl_gen_cpp_root)/%$(LOCAL_CPP_EXTENSION) : $(LOCAL_PATH)/%.aidl $(AIDL_CPP)
+ $(transform-aidl-to-cpp)
+-include $(addsuffix .P,$(basename $(aidl_gen_cpp)))
+
+# Add generated headers to include path.
+my_c_includes += $(aidl_gen_include_root)
+# Pick up the generated C++ files later for transformation to .o files.
+my_generated_sources += $(aidl_gen_cpp)
+
+endif # $(aidl_src) non-empty
+
+###########################################################
## YACC: Compile .y and .yy files to .cpp and the to .o.
###########################################################
diff --git a/core/config.mk b/core/config.mk
index 51810aa..136b204 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -398,6 +398,7 @@
DOXYGEN:= doxygen
AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX)
AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX)
+AIDL_CPP := $(HOST_OUT_EXECUTABLES)/aidl-cpp$(HOST_EXECUTABLE_SUFFIX)
PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
index 3450b2c..1493a5b 100644
--- a/core/cxx_stl_setup.mk
+++ b/core/cxx_stl_setup.mk
@@ -49,15 +49,17 @@
ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
my_cflags += -D_USING_LIBCXX
my_c_includes += external/libcxx/include
- ifeq ($(my_cxx_stl),libc++)
- my_shared_libraries += libc++
+
+ # Note that the structure of this means that LOCAL_CXX_STL := libc++ will
+ # use the static libc++ for static executables.
+ ifeq ($(my_link_type),dynamic)
+ ifeq ($(my_cxx_stl),libc++)
+ my_shared_libraries += libc++
+ else
+ my_static_libraries += libc++_static
+ endif
else
my_static_libraries += libc++_static
- ifndef LOCAL_IS_HOST_MODULE
- ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
- my_static_libraries += libm libc libdl
- endif
- endif
endif
ifdef LOCAL_IS_HOST_MODULE
@@ -72,7 +74,7 @@
endif
ifeq ($(my_link_type),static)
- my_static_libraries += libdl
+ my_static_libraries += libm libc libdl
else
my_shared_libraries += libdl
endif
diff --git a/core/definitions.mk b/core/definitions.mk
index 9dea18c..9df23fd 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1002,6 +1002,14 @@
endef
#$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@
+define transform-aidl-to-cpp
+@mkdir -p $(dir $@)
+@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
+@echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<"
+$(hide) $(AIDL_CPP) -d$(basename $@).P $(PRIVATE_AIDL_FLAGS) \
+ $< $(PRIVATE_HEADER_OUTPUT_DIR) $@
+endef
+
###########################################################
## Commands for running java-event-log-tags.py
diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
index 5c199b8..89af758 100755
--- a/tools/buildinfo.sh
+++ b/tools/buildinfo.sh
@@ -20,6 +20,12 @@
echo "ro.build.host=`hostname`"
echo "ro.build.tags=$BUILD_VERSION_TAGS"
echo "ro.build.flavor=$TARGET_BUILD_FLAVOR"
+if [ -n "$BOARD_BUILD_SYSTEM_ROOT_IMAGE" ] ; then
+ echo "ro.build.system_root_image=$BOARD_BUILD_SYSTEM_ROOT_IMAGE"
+fi
+if [ -n "$AB_OTA_UPDATER" ] ; then
+ echo "ro.build.ab_update=$AB_OTA_UPDATER"
+fi
echo "ro.product.model=$PRODUCT_MODEL"
echo "ro.product.brand=$PRODUCT_BRAND"
echo "ro.product.name=$PRODUCT_NAME"
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index f2bf1e1..83a9fde 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -139,21 +139,11 @@
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
-
# Override values loaded from info_dict.
if fs_config:
image_props["fs_config"] = fs_config
- if fc_config:
- image_props["selinux_fc"] = fc_config
if block_list:
image_props["block_list"] = block_list
- if image_props.get("system_root_image") == "true":
- image_props["ramdisk_dir"] = os.path.join(input_dir, "BOOT/RAMDISK")
- image_props["ramdisk_fs_config"] = os.path.join(
- input_dir, "META/boot_filesystem_config.txt")
succ = build_image.BuildImage(os.path.join(input_dir, what),
image_props, img)
@@ -170,8 +160,7 @@
print "userdata.img already exists in %s, no need to rebuild..." % (prefix,)
return
- image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict,
- "data")
+ image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "data")
# We only allow yaffs to have a 0/missing partition_size.
# Extfs, f2fs must have a size. Skip userdata.img if no size.
if (not image_props.get("fs_type", "").startswith("yaffs") and
@@ -215,8 +204,7 @@
print "cache.img already exists in %s, no need to rebuild..." % (prefix,)
return
- image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict,
- "cache")
+ 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
@@ -265,15 +253,14 @@
except KeyError:
has_vendor = False
- OPTIONS.info_dict = common.LoadInfoDict(input_zip)
- if "selinux_fc" in OPTIONS.info_dict:
- OPTIONS.info_dict["selinux_fc"] = os.path.join(
- OPTIONS.input_tmp, "BOOT", "RAMDISK", "file_contexts")
+ OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.input_tmp)
common.ZipClose(input_zip)
output_zip = zipfile.ZipFile(filename, "a",
compression=zipfile.ZIP_DEFLATED)
+ has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true")
+
def banner(s):
print "\n\n++++ " + s + " ++++\n\n"
@@ -291,19 +278,21 @@
if boot_image:
boot_image.AddToZip(output_zip)
- banner("recovery")
recovery_image = None
- prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img")
- if os.path.exists(prebuilt_path):
- print "recovery.img already exists in IMAGES/, no need to rebuild..."
- if OPTIONS.rebuild_recovery:
+ if has_recovery:
+ banner("recovery")
+ prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img")
+ if os.path.exists(prebuilt_path):
+ print "recovery.img already exists in IMAGES/, no need to rebuild..."
+ if OPTIONS.rebuild_recovery:
+ recovery_image = common.GetBootableImage(
+ "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp,
+ "RECOVERY")
+ else:
recovery_image = common.GetBootableImage(
"IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
- else:
- recovery_image = common.GetBootableImage(
- "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
- if recovery_image:
- recovery_image.AddToZip(output_zip)
+ if recovery_image:
+ recovery_image.AddToZip(output_zip)
banner("system")
AddSystem(output_zip, recovery_img=recovery_image, boot_img=boot_image)
@@ -315,6 +304,23 @@
banner("cache")
AddCache(output_zip)
+ # For devices using A/B update, copy over images from RADIO/ to IMAGES/ and
+ # make sure we have all the needed images ready under IMAGES/.
+ ab_partitions = os.path.join(OPTIONS.input_tmp, "META", "ab_partitions.txt")
+ if os.path.exists(ab_partitions):
+ with open(ab_partitions, 'r') as f:
+ lines = f.readlines()
+ for line in lines:
+ img_name = line.strip() + ".img"
+ img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name)
+ if os.path.exists(img_radio_path):
+ common.ZipWrite(output_zip, img_radio_path,
+ os.path.join("IMAGES", img_name))
+
+ # Zip spec says: All slashes MUST be forward slashes.
+ img_path = 'IMAGES/' + img_name
+ assert img_path in output_zip.namelist(), "cannot find " + img_name
+
common.ZipClose(output_zip)
def main(argv):
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index cb6fc85..a6c6bd8 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -483,7 +483,7 @@
if free_string:
out.append("".join(free_string))
- if self.version >= 2:
+ if self.version >= 2 and common.OPTIONS.cache_size is not None:
# Sanity check: abort if we're going to need more stash space than
# the allowed size (cache_size * threshold). There are two purposes
# of having a threshold here. a) Part of the cache may have been
@@ -524,10 +524,16 @@
if self.version >= 2:
max_stashed_size = max_stashed_blocks * self.tgt.blocksize
- max_allowed = common.OPTIONS.cache_size * common.OPTIONS.stash_threshold
- print("max stashed blocks: %d (%d bytes), limit: %d bytes (%.2f%%)\n" % (
- max_stashed_blocks, max_stashed_size, max_allowed,
- max_stashed_size * 100.0 / max_allowed))
+ OPTIONS = common.OPTIONS
+ if OPTIONS.cache_size is not None:
+ max_allowed = OPTIONS.cache_size * OPTIONS.stash_threshold
+ print("max stashed blocks: %d (%d bytes), "
+ "limit: %d bytes (%.2f%%)\n" % (
+ max_stashed_blocks, max_stashed_size, max_allowed,
+ max_stashed_size * 100.0 / max_allowed))
+ else:
+ print("max stashed blocks: %d (%d bytes), limit: <unknown>\n" % (
+ max_stashed_blocks, max_stashed_size))
def ReviseStashSize(self):
print("Revising stash size...")
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 357a666..470a108 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -432,6 +432,7 @@
copy_prop("system_verity_block_device", "verity_block_device")
copy_prop("system_root_image", "system_root_image")
copy_prop("ramdisk_dir", "ramdisk_dir")
+ copy_prop("ramdisk_fs_config", "ramdisk_fs_config")
copy_prop("has_ext4_reserved_blocks", "has_ext4_reserved_blocks")
copy_prop("system_squashfs_compressor", "squashfs_compressor")
copy_prop("system_squashfs_compressor_opt", "squashfs_compressor_opt")
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 2965fa8..ca9952d 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -62,6 +62,9 @@
self.source_info_dict = None
self.target_info_dict = None
self.worker_threads = None
+ # Stash size cannot exceed cache_size * threshold.
+ self.cache_size = None
+ self.stash_threshold = 0.8
OPTIONS = Options()
@@ -99,7 +102,7 @@
pass
-def LoadInfoDict(input_file):
+def LoadInfoDict(input_file, input_dir=None):
"""Read and parse the META/misc_info.txt key/value pairs from the
input target files and return a dict."""
@@ -150,6 +153,34 @@
if "fstab_version" not in d:
d["fstab_version"] = "1"
+ # A few properties are stored as links to the files in the out/ directory.
+ # It works fine with the build system. However, they are no longer available
+ # when (re)generating from target_files zip. If input_dir is not None, we
+ # are doing repacking. Redirect those properties to the actual files in the
+ # unzipped directory.
+ if input_dir is not None:
+ # We carry a copy of file_contexts under META/. If not available, search
+ # BOOT/RAMDISK/. Note that sometimes we may need a different file_contexts
+ # to build images than the one running on device, such as when enabling
+ # system_root_image. In that case, we must have the one for image
+ # generation copied to META/.
+ fc_config = os.path.join(input_dir, "META", "file_contexts")
+ if d.get("system_root_image") == "true":
+ assert os.path.exists(fc_config)
+ if not os.path.exists(fc_config):
+ fc_config = os.path.join(input_dir, "BOOT", "RAMDISK", "file_contexts")
+ if not os.path.exists(fc_config):
+ fc_config = None
+
+ if fc_config:
+ d["selinux_fc"] = fc_config
+
+ # Similarly we need to redirect "ramdisk_dir" and "ramdisk_fs_config".
+ if d.get("system_root_image") == "true":
+ d["ramdisk_dir"] = os.path.join(input_dir, "ROOT")
+ d["ramdisk_fs_config"] = os.path.join(
+ input_dir, "META", "root_filesystem_config.txt")
+
try:
data = read_helper("META/imagesizes.txt")
for line in data.split("\n"):
@@ -179,7 +210,11 @@
makeint("boot_size")
makeint("fstab_version")
- d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"])
+ if d.get("no_recovery", False) == "true":
+ d["fstab"] = None
+ else:
+ d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"],
+ d.get("system_root_image", False))
d["build.prop"] = LoadBuildProp(read_helper)
return d
@@ -202,7 +237,7 @@
d[name] = value
return d
-def LoadRecoveryFSTab(read_helper, fstab_version):
+def LoadRecoveryFSTab(read_helper, fstab_version, system_root_image=False):
class Partition(object):
def __init__(self, mount_point, fs_type, device, length, device2, context):
self.mount_point = mount_point
@@ -294,6 +329,12 @@
else:
raise ValueError("Unknown fstab_version: \"%d\"" % (fstab_version,))
+ # / is used for the system mount point when the root directory is included in
+ # system. Other areas assume system is always at "/system" so point /system
+ # at /.
+ if system_root_image:
+ assert not d.has_key("/system") and d.has_key("/")
+ d["/system"] = d["/"]
return d
@@ -302,34 +343,46 @@
print "%-25s = (%s) %s" % (k, type(v).__name__, v)
-def BuildBootableImage(sourcedir, fs_config_file, info_dict=None):
- """Take a kernel, cmdline, and ramdisk directory from the input (in
- 'sourcedir'), and turn them into a boot image. Return the image
- data, or None if sourcedir does not appear to contains files for
- building the requested image."""
+def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None,
+ has_ramdisk=False):
+ """Build a bootable image from the specified sourcedir.
- if (not os.access(os.path.join(sourcedir, "RAMDISK"), os.F_OK) or
- not os.access(os.path.join(sourcedir, "kernel"), os.F_OK)):
+ Take a kernel, cmdline, and optionally a ramdisk directory from the input (in
+ 'sourcedir'), and turn them into a boot image. Return the image data, or
+ None if sourcedir does not appear to contains files for building the
+ requested image."""
+
+ def make_ramdisk():
+ ramdisk_img = tempfile.NamedTemporaryFile()
+
+ if os.access(fs_config_file, os.F_OK):
+ cmd = ["mkbootfs", "-f", fs_config_file,
+ os.path.join(sourcedir, "RAMDISK")]
+ else:
+ cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")]
+ p1 = Run(cmd, stdout=subprocess.PIPE)
+ p2 = Run(["minigzip"], stdin=p1.stdout, stdout=ramdisk_img.file.fileno())
+
+ p2.wait()
+ p1.wait()
+ assert p1.returncode == 0, "mkbootfs of %s ramdisk failed" % (sourcedir,)
+ assert p2.returncode == 0, "minigzip of %s ramdisk failed" % (sourcedir,)
+
+ return ramdisk_img
+
+ if not os.access(os.path.join(sourcedir, "kernel"), os.F_OK):
+ return None
+
+ if has_ramdisk and not os.access(os.path.join(sourcedir, "RAMDISK"), os.F_OK):
return None
if info_dict is None:
info_dict = OPTIONS.info_dict
- ramdisk_img = tempfile.NamedTemporaryFile()
img = tempfile.NamedTemporaryFile()
- if os.access(fs_config_file, os.F_OK):
- cmd = ["mkbootfs", "-f", fs_config_file, os.path.join(sourcedir, "RAMDISK")]
- else:
- cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")]
- p1 = Run(cmd, stdout=subprocess.PIPE)
- p2 = Run(["minigzip"],
- stdin=p1.stdout, stdout=ramdisk_img.file.fileno())
-
- p2.wait()
- p1.wait()
- assert p1.returncode == 0, "mkbootfs of %s ramdisk failed" % (sourcedir,)
- assert p2.returncode == 0, "minigzip of %s ramdisk failed" % (sourcedir,)
+ if has_ramdisk:
+ ramdisk_img = make_ramdisk()
# use MKBOOTIMG from environ, or "mkbootimg" if empty or not set
mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg"
@@ -360,14 +413,15 @@
if args and args.strip():
cmd.extend(shlex.split(args))
+ if has_ramdisk:
+ cmd.extend(["--ramdisk", ramdisk_img.name])
+
img_unsigned = None
if info_dict.get("vboot", None):
img_unsigned = tempfile.NamedTemporaryFile()
- cmd.extend(["--ramdisk", ramdisk_img.name,
- "--output", img_unsigned.name])
+ cmd.extend(["--output", img_unsigned.name])
else:
- cmd.extend(["--ramdisk", ramdisk_img.name,
- "--output", img.name])
+ cmd.extend(["--output", img.name])
p = Run(cmd, stdout=subprocess.PIPE)
p.communicate()
@@ -407,7 +461,8 @@
img.seek(os.SEEK_SET, 0)
data = img.read()
- ramdisk_img.close()
+ if has_ramdisk:
+ ramdisk_img.close()
img.close()
return data
@@ -415,11 +470,11 @@
def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir,
info_dict=None):
- """Return a File object (with name 'name') with the desired bootable
- image. Look for it in 'unpack_dir'/BOOTABLE_IMAGES under the name
- 'prebuilt_name', otherwise look for it under 'unpack_dir'/IMAGES,
- otherwise construct it from the source files in
- 'unpack_dir'/'tree_subdir'."""
+ """Return a File object with the desired bootable image.
+
+ Look for it in 'unpack_dir'/BOOTABLE_IMAGES under the name 'prebuilt_name',
+ otherwise look for it under 'unpack_dir'/IMAGES, otherwise construct it from
+ the source files in 'unpack_dir'/'tree_subdir'."""
prebuilt_path = os.path.join(unpack_dir, "BOOTABLE_IMAGES", prebuilt_name)
if os.path.exists(prebuilt_path):
@@ -432,10 +487,18 @@
return File.FromLocalFile(name, prebuilt_path)
print "building image from target_files %s..." % (tree_subdir,)
+
+ if info_dict is None:
+ info_dict = OPTIONS.info_dict
+
+ # With system_root_image == "true", we don't pack ramdisk into the boot image.
+ has_ramdisk = (info_dict.get("system_root_image", None) != "true" or
+ prebuilt_name != "boot.img")
+
fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt"
- data = BuildBootableImage(os.path.join(unpack_dir, tree_subdir),
- os.path.join(unpack_dir, fs_config),
- info_dict)
+ data = _BuildBootableImage(os.path.join(unpack_dir, tree_subdir),
+ os.path.join(unpack_dir, fs_config),
+ info_dict, has_ramdisk)
if data:
return File(name, data)
return None
@@ -1385,18 +1448,25 @@
if info_dict is None:
info_dict = OPTIONS.info_dict
- diff_program = ["imgdiff"]
- path = os.path.join(input_dir, "SYSTEM", "etc", "recovery-resource.dat")
- if os.path.exists(path):
- diff_program.append("-b")
- diff_program.append(path)
- bonus_args = "-b /system/etc/recovery-resource.dat"
- else:
- bonus_args = ""
+ full_recovery_image = info_dict.get("full_recovery_image", None) == "true"
+ system_root_image = info_dict.get("system_root_image", None) == "true"
- d = Difference(recovery_img, boot_img, diff_program=diff_program)
- _, _, patch = d.ComputePatch()
- output_sink("recovery-from-boot.p", patch)
+ if full_recovery_image:
+ output_sink("etc/recovery.img", recovery_img.data)
+
+ else:
+ diff_program = ["imgdiff"]
+ path = os.path.join(input_dir, "SYSTEM", "etc", "recovery-resource.dat")
+ if os.path.exists(path):
+ diff_program.append("-b")
+ diff_program.append(path)
+ bonus_args = "-b /system/etc/recovery-resource.dat"
+ else:
+ bonus_args = ""
+
+ d = Difference(recovery_img, boot_img, diff_program=diff_program)
+ _, _, patch = d.ComputePatch()
+ output_sink("recovery-from-boot.p", patch)
try:
# The following GetTypeAndDevice()s need to use the path in the target
@@ -1406,7 +1476,19 @@
except KeyError:
return
- sh = """#!/system/bin/sh
+ if full_recovery_image:
+ sh = """#!/system/bin/sh
+if ! applypatch -c %(type)s:%(device)s:%(size)d:%(sha1)s; then
+ applypatch /system/etc/recovery.img %(type)s:%(device)s %(sha1)s %(size)d && log -t recovery "Installing new recovery image: succeeded" || log -t recovery "Installing new recovery image: failed"
+else
+ log -t recovery "Recovery image already installed"
+fi
+""" % {'type': recovery_type,
+ 'device': recovery_device,
+ 'sha1': recovery_img.sha1,
+ 'size': recovery_img.size}
+ else:
+ sh = """#!/system/bin/sh
if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then
applypatch %(bonus_args)s %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s %(recovery_type)s:%(recovery_device)s %(recovery_sha1)s %(recovery_size)d %(boot_sha1)s:/system/recovery-from-boot.p && log -t recovery "Installing new recovery image: succeeded" || log -t recovery "Installing new recovery image: failed"
else
@@ -1427,13 +1509,15 @@
# target-files expects it to be, and put it there.
sh_location = "etc/install-recovery.sh"
found = False
- init_rc_dir = os.path.join(input_dir, "BOOT", "RAMDISK")
+ if system_root_image:
+ init_rc_dir = os.path.join(input_dir, "ROOT")
+ else:
+ init_rc_dir = os.path.join(input_dir, "BOOT", "RAMDISK")
init_rc_files = os.listdir(init_rc_dir)
for init_rc_file in init_rc_files:
if (not init_rc_file.startswith('init.') or
not init_rc_file.endswith('.rc')):
continue
-
with open(os.path.join(init_rc_dir, init_rc_file)) as f:
for line in f:
m = re.match(r"^service flash_recovery /system/(\S+)\s*$", line)
@@ -1441,10 +1525,8 @@
sh_location = m.group(1)
found = True
break
-
if found:
break
-
print "putting script in", sh_location
output_sink(sh_location, sh)
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index c486992..aa21d7e 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -95,25 +95,18 @@
# images, so build them.
import add_img_to_target_files
- OPTIONS.info_dict = common.LoadInfoDict(input_zip)
-
- # If this image was originally labelled with SELinux contexts,
- # make sure we also apply the labels in our new image. During
- # building, the "file_contexts" is in the out/ directory tree,
- # but for repacking from target-files.zip it's in the root
- # directory of the ramdisk.
- if "selinux_fc" in OPTIONS.info_dict:
- OPTIONS.info_dict["selinux_fc"] = os.path.join(
- OPTIONS.input_tmp, "BOOT", "RAMDISK", "file_contexts")
+ OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.input_tmp)
boot_image = common.GetBootableImage(
"boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
if boot_image:
boot_image.AddToZip(output_zip)
- recovery_image = common.GetBootableImage(
- "recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
- if recovery_image:
- recovery_image.AddToZip(output_zip)
+
+ if OPTIONS.info_dict.get("no_recovery") != "true":
+ recovery_image = common.GetBootableImage(
+ "recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
+ if recovery_image:
+ recovery_image.AddToZip(output_zip)
def banner(s):
print "\n\n++++ " + s + " ++++\n\n"
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index c5c16b4..e5e4d74 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -223,7 +223,8 @@
if i.is_dir:
i.children.sort(key=lambda i: i.name)
- # set metadata for the files generated by this script.
+ # Set metadata for the files generated by this script. For full recovery
+ # image at system/etc/recovery.img, it will be taken care by fs_config.
i = self.ITEMS.get("system/recovery-from-boot.p", None)
if i:
i.uid, i.gid, i.mode, i.selabel, i.capabilities = 0, 0, 0o644, None, None
@@ -427,11 +428,9 @@
def HasRecoveryPatch(target_files_zip):
- try:
- target_files_zip.getinfo("SYSTEM/recovery-from-boot.p")
- return True
- except KeyError:
- return False
+ namelist = [name for name in target_files_zip.namelist()]
+ return ("SYSTEM/recovery-from-boot.p" in namelist or
+ "SYSTEM/etc/recovery.img" in namelist)
def HasVendorPartition(target_files_zip):
try:
@@ -594,6 +593,8 @@
if HasVendorPartition(input_zip):
system_progress -= 0.1
+ # Place a copy of file_contexts into the OTA package which will be used by
+ # the recovery program.
if "selinux_fc" in OPTIONS.info_dict:
WritePolicyConfig(OPTIONS.info_dict["selinux_fc"], output_zip)
@@ -621,8 +622,8 @@
symlinks = CopyPartitionFiles(system_items, input_zip, output_zip)
script.MakeSymlinks(symlinks)
- boot_img = common.GetBootableImage("boot.img", "boot.img",
- OPTIONS.input_tmp, "BOOT")
+ boot_img = common.GetBootableImage(
+ "boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
if not block_based:
def output_sink(fn, data):
@@ -1366,6 +1367,7 @@
common.MakeRecoveryPatch(OPTIONS.target_tmp, output_sink,
target_recovery, target_boot)
script.DeleteFiles(["/system/recovery-from-boot.p",
+ "/system/etc/recovery.img",
"/system/etc/install-recovery.sh"])
print "recovery image changed; including as patch from boot."
else:
@@ -1588,15 +1590,7 @@
OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0])
OPTIONS.target_tmp = OPTIONS.input_tmp
- OPTIONS.info_dict = common.LoadInfoDict(input_zip)
-
- # If this image was originally labelled with SELinux contexts, make sure we
- # also apply the labels in our new image. During building, the "file_contexts"
- # is in the out/ directory tree, but for repacking from target-files.zip it's
- # in the root directory of the ramdisk.
- if "selinux_fc" in OPTIONS.info_dict:
- OPTIONS.info_dict["selinux_fc"] = os.path.join(
- OPTIONS.input_tmp, "BOOT", "RAMDISK", "file_contexts")
+ OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp)
if OPTIONS.verbose:
print "--- target info ---"
@@ -1620,6 +1614,10 @@
if OPTIONS.device_specific is not None:
OPTIONS.device_specific = os.path.abspath(OPTIONS.device_specific)
+ if OPTIONS.info_dict.get("no_recovery") == "true":
+ raise common.ExternalError(
+ "--- target build has specified no recovery ---")
+
while True:
if OPTIONS.no_signing:
@@ -1634,7 +1632,7 @@
cache_size = OPTIONS.info_dict.get("cache_size", None)
if cache_size is None:
- raise RuntimeError("can't determine the cache partition size")
+ print "--- can't determine the cache partition size ---"
OPTIONS.cache_size = cache_size
if OPTIONS.incremental_source is None:
@@ -1651,10 +1649,8 @@
OPTIONS.source_tmp, source_zip = common.UnzipTemp(
OPTIONS.incremental_source)
OPTIONS.target_info_dict = OPTIONS.info_dict
- OPTIONS.source_info_dict = common.LoadInfoDict(source_zip)
- if "selinux_fc" in OPTIONS.source_info_dict:
- OPTIONS.source_info_dict["selinux_fc"] = os.path.join(
- OPTIONS.source_tmp, "BOOT", "RAMDISK", "file_contexts")
+ OPTIONS.source_info_dict = common.LoadInfoDict(source_zip,
+ OPTIONS.source_tmp)
if OPTIONS.package_key is None:
OPTIONS.package_key = OPTIONS.source_info_dict.get(
"default_system_dev_certificate",
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
index 60d62c2..cbf78a1 100755
--- a/tools/releasetools/sign_target_files_apks.py
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -175,21 +175,26 @@
data = input_tf_zip.read(info.filename)
out_info = copy.copy(info)
+ # Replace keys if requested.
if (info.filename == "META/misc_info.txt" and
OPTIONS.replace_verity_private_key):
ReplaceVerityPrivateKey(input_tf_zip, output_tf_zip, misc_info,
OPTIONS.replace_verity_private_key[1])
- elif (info.filename == "BOOT/RAMDISK/verity_key" and
+ elif (info.filename in ("BOOT/RAMDISK/verity_key",
+ "BOOT/verity_key") and
OPTIONS.replace_verity_public_key):
- new_data = ReplaceVerityPublicKey(output_tf_zip,
+ new_data = ReplaceVerityPublicKey(output_tf_zip, info.filename,
OPTIONS.replace_verity_public_key[1])
write_to_temp(info.filename, info.external_attr, new_data)
+ # Copy BOOT/, RECOVERY/, META/, ROOT/ to rebuild recovery patch.
elif (info.filename.startswith("BOOT/") or
info.filename.startswith("RECOVERY/") or
info.filename.startswith("META/") or
+ info.filename.startswith("ROOT/") or
info.filename == "SYSTEM/etc/recovery-resource.dat"):
write_to_temp(info.filename, info.external_attr, data)
+ # Sign APKs.
if info.filename.endswith(".apk"):
name = os.path.basename(info.filename)
key = apk_key_map[name]
@@ -216,6 +221,7 @@
new_data = ReplaceCerts(data)
common.ZipWriteStr(output_tf_zip, out_info, new_data)
elif info.filename in ("SYSTEM/recovery-from-boot.p",
+ "SYSTEM/etc/recovery.img",
"SYSTEM/bin/install-recovery.sh"):
rebuild_recovery = True
elif (OPTIONS.replace_ota_keys and
@@ -227,7 +233,8 @@
info.filename == "META/misc_info.txt"):
pass
elif (OPTIONS.replace_verity_public_key and
- info.filename == "BOOT/RAMDISK/verity_key"):
+ info.filename in ("BOOT/RAMDISK/verity_key",
+ "BOOT/verity_key")):
pass
else:
# a non-APK file; copy it verbatim
@@ -399,11 +406,11 @@
return new_recovery_keys
-def ReplaceVerityPublicKey(targetfile_zip, key_path):
+def ReplaceVerityPublicKey(targetfile_zip, filename, key_path):
print "Replacing verity public key with %s" % key_path
with open(key_path) as f:
data = f.read()
- common.ZipWriteStr(targetfile_zip, "BOOT/RAMDISK/verity_key", data)
+ common.ZipWriteStr(targetfile_zip, filename, data)
return data
def ReplaceVerityPrivateKey(targetfile_input_zip, targetfile_output_zip,