reprint
summary:
This article mainly introduces the compilation and production process of Android ota package (Android L), focusing on the process of compiling ota in Makefile, from specifying target to compiling cmd and other processes.
Main process:
Source code analysis:
build/core/Makefile:
.PHONY: otapackage
otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
otapackage pseudo-command, that is, when make otapackage
is executed, the $(INTERNAL_OTA_PACKAGE_TARGET)
target will be compiled
$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
@echo "Package OTA: $@"
ifneq ($(TARGET_USERIMAGES_USE_UBIFS),true)
ifeq (yes, $(filter $(TRUSTONIC_TEE_SUPPORT) $(MTK_ATF_SUPPORT),yes))
$(hide) MTK_SECURITY_SW_SUPPORT=$(MTK_SECURITY_SW_SUPPORT) MKBOOTIMG=$(MKBOOTIMG) \
./build/tools/releasetools/ota_from_target_files -v \
--block \
-p $(HOST_OUT) \
-k $(KEY_CERT_PAIR) \
-z $(PRODUCT_OUT)/trustzone.bin \
$(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
$(BUILT_TARGET_FILES_PACKAGE) $@
else
$(hide) MTK_SECURITY_SW_SUPPORT=$(MTK_SECURITY_SW_SUPPORT) MKBOOTIMG=$(MKBOOTIMG) \
./build/tools/releasetools/ota_from_target_files -v \
--block \
-p $(HOST_OUT) \
-k $(KEY_CERT_PAIR) \
$(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
$(BUILT_TARGET_FILES_PACKAGE) $@
endif
else
$(hide) MTK_SECURITY_SW_SUPPORT=$(MTK_SECURITY_SW_SUPPORT) ./build/tools/releasetools/ota_from_target_files -v \
-n \
-g \
-p $(HOST_OUT) \
-k $(KEY_CERT_PAIR) \
$(BUILT_TARGET_FILES_PACKAGE) $@
endif
ifeq ($(strip $(MTK_FW_UPGRADE)), yes)
# @echo "Package FWUpgradePackage"
# bash $(FWUPGRADEPACKAGE_SH) $(PRODUCT_OUT) $(KEY_CERT_PAIR)
endif
Depends on two parts:
$(BUILT_TARGET_FILES_PACKAGE)$(DISTTOOLS)
Then look $(BUILT_TARGET_FILES_PACKAGE)
first. BUILT_TARGET_FILES_PACKAGE:= (intermediates)/(intermediates)/(intermediates)/(name).zip
Actually: full_p92s_hd-target_files-eng.wan.zip
# -----------------------------------------------------------------
# A zip of the directories that map to the target filesystem.
# This zip can be used to create an OTA package or filesystem image
# as a post-build step.
#
name := $(TARGET_PRODUCT)
ifeq ($(TARGET_BUILD_TYPE),debug)
name := $(name)_debug
endif
name := $(name)-target_files-$(FILE_NAME_TAG)
The above steps mainly determine the name variable name name:=(project−name)−targetfiles−(project-name)-target_files-(project−name)−targetfiles−(FILE_NAME_TAG)
, assuming project-name=p92 FILE_NAME_TAG=eng
, then:
name := p92-target_files-eng
intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
A function is called here: intermediates-dir-for
, let's interpret its definition to know what this sentence means. It is defined in build/core/definitions.mk
as follows:
$(1): target class, like "APPS"
$(2): target name, like "NotePad"
$(3): if non-empty, this is a HOST target.
$(4): if non-empty, force the intermediates to be COMMON
$(5): if non-empty, force the intermedistes to be for the 2ndarch
define intermediates-dir-for
$(strip \
$(eval _idfClass :=$(strip $(1))) \
$(if $(_idfClass),, \
$(error$(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \
$(eval _idfName :=$(strip $(2))) \
$(if $(_idfName),, \
$(error$(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \
$(eval _idfPrefix :=$(if $(strip $(3)),HOST,TARGET)) \
$(eval_idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
$(if $(filter$(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
$(eval _idfIntBase:= $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
,$(if $(filter$(_idfClass),SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP),\
$(eval_idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
,$(eval _idfIntBase:= $($(_idfPrefix)_OUT_INTERMEDIATES)) \
) \
) \
$(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
)
endif
Incoming parameters: $1= PACKAGING
, $2=target-files
, $3
and later parameters are empty.
So execute it:
- _idfClass := PACKAGING
- _idfName := target_files
- _idfPrefix := TARGET (以为$3为空,所以if函数走到else part 为TARGET)
- _idfIntBase := TARGET_OUT_INTERMEDIATES
Since this macro is defined in build/core/envsetup.mk
:
TARGET_OUT_INTERMEDIATES := (PRODUCTOUT)/obj(out/target/product/(PRODUCT_OUT)/obj (out/target/product/(PRODUCTOUT)/obj(out/target/product/(project)/obj)
Results of the:
out/target/product/$(project)/obj/PACKAGING/target_files_intermediates
So after this function call: intermediates := out/target/product/$(project)/obj/PACKAGING/target-files_intermeidates
BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
$(BUILT_TARGET_FILES_PACKAGE): \
zip_root := $(intermediates)/$(name)
The above sentences are also assignments to variables such as targets:
BUILT_TARGET_FILES_PACKAGE := out/target/product/$(project)/obj/PACKAGING/target-files_intermeidates/p92-target_files-eng.zip
(this is the target file to be generated)
Then set two target-specific variables: intermediates
and zip_root
, that is, these two variables are only valid in the target context of BUILT_TARGET_FILES_PACKAGE
(similar to the local C language variable)
Intermediates:= out/target/product/$(project)/obj/PACKAGING/target-files_intermeidates
zip_root := out/target/product/$(project)/obj/PACKAGING/target-files_intermeidates/p92-target_files-eng
# $(1): Directory to copy
# $(2): Location to copy it to
# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
define package_files-copy-root
if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
mkdir -p $(2) && \
$(ACP) -rd $(strip $(1))/* $(2); \
fi
endef
The above defines a function for copying a file, with two parameters $1, $2, which copies the contents of $1 into $2.
built_ota_tools := \
$(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
$(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
$(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
$(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3
ifeq ($(TARGET_ARCH),arm64)
built_ota_tools += $(call intermediates-dir-for,EXECUTABLES,updater,,,t)/updater
else
built_ota_tools += $(call intermediates-dir-for,EXECUTABLES,updater)/updater
endif
The above mainly do two things:
-
applypatch … sqlite3
and other executable files (in the obj/EXECUTABLES/... directory) tobuilt_ota_tools
Append the
updater
executable tobuilt_ota_tools
. It is worth noting here that the call parameters ofupdater
cba0f507f14bb29f933ebda8f13925a5---:(EXECUTABLES,updater,,,t)
, there is $5, combined with the above pair ofintermediates-dir-for
function analysis can be obtained:$(eval_idfIntBase := ((((_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) 可得到:idfIntBase :=$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES:= $(PRODUCT_OUT)/obj_$(TARGET_2ND_ARCH) :=out/target/product/$(project)/obj_arm
So finally return: out/target/product/$(project)/obj_arm/updater_intermediates/(updater)
可intermediates-dir-for
此函数,如果存在参数$5, _idfClass
680106641eb6dd498bd976fc0a8dde85---在SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP
中, idfIntBase := out/target/product/$(project)/obj_arm
(而非obj)。 Final built_ota_tools := applypatchapplypatch_static check_prereq sqlite3 updater
these files (directory ignored)
$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
# default to common dir for device vendor
$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
else
$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
endif
-
built_ota_tools
to the target formulation variablePRIVATE_OTA_TOOLS
PRIVATE_RECOVERY_API_VERSION
,PRIVATE_RECOVERY_FSTAB_VERSION
赋值,其中RECOVERY_API_VERSION
,RECOVERY_FSTAB_VERSION
bootable/recovery/Android.mk
中有定义:RECOVERY_API_VERSION:= 3 RECOVERY_FSTAB_VERSION:= 2
- Assignment to
tool_extensions
# Depending on the various images guarantees that the underlying
# directories are up-to-date.
$(BUILT_TARGET_FILES_PACKAGE): \
$(INSTALLED_BOOTIMAGE_TARGET) \
$(INSTALLED_RADIOIMAGE_TARGET) \
$(INSTALLED_RECOVERYIMAGE_TARGET) \
$(INSTALLED_SYSTEMIMAGE) \
$(INSTALLED_USERDATAIMAGE_TARGET) \
$(INSTALLED_CACHEIMAGE_TARGET) \
$(INSTALLED_VENDORIMAGE_TARGET) \
$(INSTALLED_ANDROID_INFO_TXT_TARGET) \
$(SELINUX_FC) \
$(built_ota_tools) \
$(APKCERTS_FILE) \
$(HOST_OUT_EXECUTABLES)/fs_config \
| $(ACP)
Add dependencies to the target ( out/…/obj/PACKAGING/ target-files_intermeidates/p92-target_files-eng.zip
), which are divided into two types of dependencies. Before "|" are common dependencies, that is, when these dependencies INSTALLED_BOOTIMAGE_TARGET
have changed, maketarget
The target should also be rebuilt; "|" is followed by order-only
dependency, which means that if the ACP variable changes, and the target already exists, it does not need to be rebuilt, and if it is generated for the first time, it needs to be rebuilt.
ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_CACHEIMAGE_TARGET)
Endif
Continue to add dependencies $(INSTALLED_CACHEIMAGE_TARGET)
@echo "Package target files: $@"
$(hide) rm -rf $@ $(zip_root)
$(hide) mkdir -p $(dir $@) $(zip_root)
@# Components of the recovery image
$(hide) mkdir -p $(zip_root)/RECOVERY
$(hide) $(call package_files-copy-root, \
$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
ifdef INSTALLED_KERNEL_TARGET
$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
$(hide) $(ACP) $(recovery_ramdisk) $(zip_root)/RECOVERY/ramdisk
ifeq ($(MTK_HEADER_SUPPORT),yes)
$(hide) $(ACP) $(recovery_ramdisk_bthdr) $(zip_root)/RECOVERY/ramdisk-bthdr
endif
endif
ifdef INSTALLED_2NDBOOTLOADER_TARGET
$(hide) $(ACP) \
$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
endif
ifdef BOARD_KERNEL_CMDLINE
$(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
endif
ifdef BOARD_KERNEL_BASE
$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
endif
ifdef BOARD_KERNEL_PAGESIZE
$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
endif
ifdef BOARD_RAMDISK_OFFSET
$(hide) echo "$(BOARD_RAMDISK_OFFSET)" > $(zip_root)/RECOVERY/ramdisk_offset
endif
ifdef BOARD_KERNEL_OFFSET
$(hide) echo "$(BOARD_KERNEL_OFFSET)" > $(zip_root)/RECOVERY/kernel_offset
endif
ifdef BOARD_TAGS_OFFSET
$(hide) echo "$(BOARD_TAGS_OFFSET)" > $(zip_root)/RECOVERY/tags_offset
endif
$(hide) if [ -f $(PRODUCT_OUT)/custom_build_verno ]; then \
cat $(PRODUCT_OUT)/custom_build_verno > $(zip_root)/RECOVERY/board; \
fi
@# Components of the boot image
$(hide) mkdir -p $(zip_root)/BOOT
$(hide) $(call package_files-copy-root, \
$(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
ifdef INSTALLED_KERNEL_TARGET
$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
$(hide) $(ACP) $(INSTALLED_RAMDISK_TARGET) $(zip_root)/BOOT/ramdisk
endif
ifdef INSTALLED_2NDBOOTLOADER_TARGET
$(hide) $(ACP) \
$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
endif
ifdef BOARD_KERNEL_CMDLINE
$(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
endif
ifdef BOARD_KERNEL_BASE
$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
endif
ifdef BOARD_RAMDISK_OFFSET
$(hide) echo "$(BOARD_RAMDISK_OFFSET)" > $(zip_root)/BOOT/ramdisk_offset
endif
ifdef BOARD_KERNEL_OFFSET
$(hide) echo "$(BOARD_KERNEL_OFFSET)" > $(zip_root)/BOOT/kernel_offset
endif
ifdef BOARD_TAGS_OFFSET
$(hide) echo "$(BOARD_TAGS_OFFSET)" > $(zip_root)/BOOT/tags_offset
endif
ifdef BOARD_KERNEL_PAGESIZE
$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
endif
$(hide) if [ -f $(PRODUCT_OUT)/custom_build_verno ]; then \
cat $(PRODUCT_OUT)/custom_build_verno > $(zip_root)/BOOT/board; \
fi
$(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
mkdir -p $(zip_root)/RADIO; \
$(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
@# Contents of the system image
$(hide) $(call package_files-copy-root, \
$(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
@# Contents of the data image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_DATA),$(zip_root)/DATA)
@# Contents of the apd image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_APD),$(zip_root)/APD)
ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
@# Contents of the vendor image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
endif
#wschen 2012-11-07
$(if $(BOARD_CUSTOMIMAGE_PARTITION_SIZE), \
$(hide) $(call package_files-copy-root, \
$(TARGET_CUSTOM_OUT),$(zip_root)/CUSTOM))
@# Extra contents of the OTA package
$(hide) mkdir -p $(zip_root)/OTA/bin
$(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
$(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
The above content is mainly to create the directory required for the corresponding upgrade partition in the zip_root
out
directory, and put the corresponding file copy
in the corresponding directory. If you need to add a new partition to the ota, you need to make some modifications above, please refer to the apd partition.
@# Security information of the OTA package
@echo "[SEC OTA] Adding Security information to OTA package"
@echo "[SEC OTA] path : vendor/mediatek/proprietary/custom/$(MTK_BASE_PROJECT)/security/recovery/SEC_VER.txt"
$(hide) $(ACP) vendor/mediatek/proprietary/custom/$(MTK_BASE_PROJECT)/security/recovery/SEC_VER.txt $(zip_root)/OTA/
-$(hide) $(ACP) $(PRODUCT_OUT)/trustzone.bin $(zip_root)/OTA/
@# Files that do not end up in any images, but are necessary to
@# build them.
$(hide) mkdir -p $(zip_root)/META
$(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) 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
fdef BOARD_FLASH_BLOCK_SIZE
$(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
endif
ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
$(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(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
ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
@# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
$(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
else
$(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
endif
$(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
$(hide) echo "default_system_dev_certificate=$(DEFAULT_KEY_CERT_PAIR)" >> $(zip_root)/META/misc_info.txt
ifdef PRODUCT_EXTRA_RECOVERY_KEYS
$(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
endif
$(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
$(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
$(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
$(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
$(hide) echo "blockimgdiff_versions=1,2" >> $(zip_root)/META/misc_info.txt
ifeq ($(MTK_HEADER_SUPPORT),yes)
$(hide) echo "mtk_header_support=1" >> $(zip_root)/META/misc_info.txt
endif
ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
# 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 ($(TARGET_USERIMAGES_USE_UBIFS),true)
$(call generate-ubifs-prop-dictionary, $(zip_root)/META/misc_info.txt)
endif
$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
ifeq ($(TRUSTONIC_TEE_SUPPORT),yes)
$(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root) $(PRODUCT_OUT)
else
$(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root) $(TRUSTONIC_TEE_SUPPORT)
endif
ifeq ($(strip $(MTK_SECURITY_SW_SUPPORT)), yes)
#security boot signature
$(hide) $(SHELL) $(SECURITY_SIG_TOOL)
$(hide) cp $(PRODUCT_OUT)/sig/boot.sig $(zip_root)/META/
$(hide) cp $(PRODUCT_OUT)/sig/recovery.sig $(zip_root)/META/
$(hide) cp $(PRODUCT_OUT)/sig/recovery.sig $(zip_root)/SYSTEM/etc/
Endif
Continue to do some copy file actions.
@# 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
Compress the content in zip_root into the target compressed package zip –qry …/p92-target_files-eng.zip
.
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -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 -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="APD/" } /^APD\// {print "apd/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/apd_filesystem_config.txt
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
#wschen 2012-11-07
$(if $(BOARD_CUSTOMIMAGE_PARTITION_SIZE), \
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="CUSTOM/" } /^CUSTOM\// {print "custom/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/custom_filesystem_config.txt)
Add selinux permissions to the partition directory that needs ota upgrade and the files in the directory, and output these permissions to the X_filesystem_config.txt
file, such as meta/apd_filesystem_config.txt
:
apd 0 0 755selabel=u:object_r:apd_file:s0 capabilities=0x0
apd/test.ini 0 2000 777selabel=u:object_r:apd_file:s0 capabilities=0x0
apd/apd.txt 0 2000 777selabel=u:object_r:apd_file:s0 capabilities=0x0
apd/apd.ini 0 2000 777selabel=u:object_r:apd_file:s0 capabilities=0x0
$(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Put these *filesystem_config.txt
files together in the target archive
$(hide) ./build/tools/releasetools/add_img_to_target_files -p $(HOST_OUT) $@
This file add_img_to_target_files.py
is very important. The main function is to generate an images folder, which stores various img generated (including the partition that needs to be added to the ota upgrade), as shown in the figure below. If you need to add a new partition to the ota upgrade package, this file needs to be modified, please refer to the method of adding custom/vendor partition.
$(hide) ./build/tools/releasetools/replace_img_from_target_files.py $@ $(PRODUCT_OUT)
To understand the main purpose of this sentence, take a look at the annotations of the replace_img_from_target_files.py
file:
'''
Given a target-files zipfilethat does contain images (ie, does
have an IMAGES/ top-level subdirectory), replace the images to
the output dir.
Usage: replace_img_from_target_files target_files output
'''
把目标压缩包out/target/product/(project)/obj/PACKAGING/target−filesintermeidates/p92−targetfiles−eng.zip
中的images/
路径下的各个img out/target/product/(project)/obj/PACKAGING/target-files_intermeidates/p92-target_files-eng.zip
中的images/
路径下的各个img 输出到Each img in the out/target/product/(project)/obj/PACKAGING/target−filesintermeidates/p92−targetfiles−eng.zip
images/
path in ---2422959a9ab7c5d14a0f803eeb88084c--- is output to the out/target/product/(project-name)/
directory. For example, replace the original boot.img, system.img, apd.img, etc. in the out... directory.
Then look at another dependency:
DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
$(HOST_OUT_EXECUTABLES)/mkbootfs \
$(HOST_OUT_EXECUTABLES)/mkbootimg \
$(HOST_OUT_EXECUTABLES)/fs_config \
$(HOST_OUT_EXECUTABLES)/mkyaffs2image \
$(HOST_OUT_EXECUTABLES)/zipalign \
$(HOST_OUT_EXECUTABLES)/bsdiff \
$(HOST_OUT_EXECUTABLES)/imgdiff \
$(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
$(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
$(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
$(HOST_OUT_EXECUTABLES)/make_ext4fs \
$(HOST_OUT_EXECUTABLES)/simg2img \
$(HOST_OUT_EXECUTABLES)/e2fsck \
$(HOST_OUT_EXECUTABLES)/build_verity_tree \
$(HOST_OUT_EXECUTABLES)/verity_signer \
$(HOST_OUT_EXECUTABLES)/append2simg
In fact, it defines disttools
as some executable files in the out/host/
directory.
Finally, jump to the cmd of the ultimate goal to start execution:
$(hide) MTK_SECURITY_SW_SUPPORT=$(MTK_SECURITY_SW_SUPPORT) MKBOOTIMG=$(MKBOOTIMG) \
./build/tools/releasetools/ota_from_target_files -v \
--block \
-p $(HOST_OUT) \
-k $(KEY_CERT_PAIR) \
$(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
$(BUILT_TARGET_FILES_PACKAGE) $@
So jump to the ota_from_target_files python
file, and then look at the function of this file ota_from_target_files
.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。