原文链接:https://blog.csdn.net/sjz_iron/article/details/8273205
我们知道,在Android源码整编后执行make otapackage命令即可生成OTA整包,但除此之外它还完成了哪些功能?具体又是如何完成的呢?事实上,在OTA升级过程中命令make otapackage完成了三件事情:
-
重新对system.img文件进行了打包;
-
生成差分资源包,路径为out/target/product/
/obj/PACKAGING/target_files_from_intermedias/-target_files-.zip,差分资源包用于生成整包和差分包;
-
生成OTA整包,路径为out/target/product/
/-ota-.zip
本文将对此命令的执行过程进行分析。
- # —————————————————————–
- # OTA update package
-
- name := (TARGET_PRODUCT)
- ifeq ( (TARGET_PRODUCT)
- ifeq ( (TARGET_BUILD_TYPE),debug)
- name := (name)_debug
- endif
- name := (name)_debug
- endif
- name := (name)-ota-(FILE_NAME_TAG)
-
- INTERNAL_OTA_PACKAGE_TARGET := (FILE_NAME_TAG)
-
- INTERNAL_OTA_PACKAGE_TARGET := (PRODUCT_OUT)/(name).zip
-
- (name).zip
-
- (INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := (DEFAULT_KEY_CERT_PAIR)
-
- (DEFAULT_KEY_CERT_PAIR)
-
- (INTERNAL_OTA_PACKAGE_TARGET): (BUILT_TARGET_FILES_PACKAGE) (BUILT_TARGET_FILES_PACKAGE) (OTATOOLS)
- @echo “Package OTA: @"
- @"
- (hide) ./build/tools/releasetools/ota_from_target_files -v \
- -n \
- -p (HOST_OUT) \ 
- -k (HOST_OUT) \ 
- -k (KEY_CERT_PAIR) \
- (BUILT_TARGET_FILES_PACKAGE) (BUILT_TARGET_FILES_PACKAGE) @
-
- .PHONY: otapackage
- otapackage: (INTERNAL_OTA_PACKAGE_TARGET)
-
- # -----------------------------------------------------------------
- # The update package
-
- name := (INTERNAL_OTA_PACKAGE_TARGET)
-
- # -----------------------------------------------------------------
- # The update package
-
- name := (TARGET_PRODUCT)
- ifeq ((TARGET_BUILD_TYPE),debug)
- name := (TARGET_BUILD_TYPE),debug)
- name := (name)_debug
- endif
- name := (name)−img− ( n a m e ) − i m g − (FILE_NAME_TAG)
# -----------------------------------------------------------------
OTA update package
name := (TARGETPRODUCT)ifeq( ( T A R G E T P R O D U C T ) i f e q ( (TARGET_BUILD_TYPE),debug)
name := (name)debugendifname:= ( n a m e ) d e b u g e n d i f n a m e := (name)-ota-$(FILE_NAME_TAG)
INTERNAL_OTA_PACKAGE_TARGET := (PRODUCTOUT)/ ( P R O D U C T O U T ) / (name).zip
(INTERNALOTAPACKAGETARGET):KEYCERTPAIR:= ( I N T E R N A L O T A P A C K A G E T A R G E T ) : K E Y C E R T P A I R := (DEFAULT_KEY_CERT_PAIR)
(INTERNALOTAPACKAGETARGET): ( I N T E R N A L O T A P A C K A G E T A R G E T ) : (BUILT_TARGET_FILES_PACKAGE) (OTATOOLS)@echo"PackageOTA: ( O T A T O O L S ) @ e c h o " P a c k a g e O T A : @"
(hide)./build/tools/releasetools/otafromtargetfiles−v −n −p ( h i d e ) . / b u i l d / t o o l s / r e l e a s e t o o l s / o t a f r o m t a r g e t f i l e s − v − n − p (HOST_OUT) \
-k (KEYCERTPAIR) ( K E Y C E R T P A I R ) (BUILT_TARGET_FILES_PACKAGE) $@
.PHONY: otapackage
otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
-----------------------------------------------------------------
The update package
name := (TARGETPRODUCT)ifeq( ( T A R G E T P R O D U C T ) i f e q ( (TARGET_BUILD_TYPE),debug)
name := (name)debugendifname:= ( n a m e ) d e b u g e n d i f n a m e := (name)-img-$(FILE_NAME_TAG)
- 代码段1 Makefile文件中目标otapackage的执行代码
代码段1 Makefile文件中目标otapackage的执行代码
首先,make otapackage命令会执行Makefile(./build/core/Makefile)中otapackage的目标代码(如代码1所示)。由代码可知,otapackage目标的执行只依赖于 (INTERNALOTAPACKAGETARGET),而不存在任何规则(根据Makefile语法,规则必须以TAB键开始,而目标otapackage的定义之后却是变量name的声明,因此不存在规则),因此只需要关注目标 ( I N T E R N A L O T A P A C K A G E T A R G E T ) , 而 不 存 在 任 何 规 则 ( 根 据 M a k e f i l e 语 法 , 规 则 必 须 以 T A B 键 开 始 , 而 目 标 o t a p a c k a g e 的 定 义 之 后 却 是 变 量 n a m e 的 声 明 , 因 此 不 存 在 规 则 ) , 因 此 只 需 要 关 注 目 标 (INTERNAL_OTA_PACKAGE_TARGET)的生成。显然,此目标的生成依赖于目标文件:(BUILT_TARGET_FILES_PACKAGE)和 (BUILT_TARGET_FILES_PACKAGE)和 (OTATOOLS),且其执行的命令为./build/tools/releasetools/ota_from_target_files。也就是说,make otapackage所完成的功能全是通过这两个目标文件和执行的命令完成的,我们将分别对这三个关键点进行分析。
1 $(OTATOOLS)
目标文件OTATOOLS的编译规则如下所示
- OTATOOLS := (HOST_OUT_EXECUTABLES)/minigzip \ 
- (HOST_OUT_EXECUTABLES)/minigzip \ 
- (HOST_OUT_EXECUTABLES)/mkbootfs \
- (HOST_OUT_EXECUTABLES)/mkbootimg \ 
- (HOST_OUT_EXECUTABLES)/mkbootimg \ 
- (HOST_OUT_EXECUTABLES)/fs_config \
- (HOST_OUT_EXECUTABLES)/mkyaffs2image \ 
- (HOST_OUT_EXECUTABLES)/mkyaffs2image \ 
- (HOST_OUT_EXECUTABLES)/zipalign \
- (HOST_OUT_EXECUTABLES)/aapt \ 
- (HOST_OUT_EXECUTABLES)/aapt \ 
- (HOST_OUT_EXECUTABLES)/bsdiff \
- (HOST_OUT_EXECUTABLES)/imgdiff \ 
- (HOST_OUT_EXECUTABLES)/imgdiff \ 
- (HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
- (HOST_OUT_JAVA_LIBRARIES)/signapk.jar \ 
- (HOST_OUT_JAVA_LIBRARIES)/signapk.jar \ 
- (HOST_OUT_EXECUTABLES)/mkuserimg.sh \
- (HOST_OUT_EXECUTABLES)/genext2fs \ 
- (HOST_OUT_EXECUTABLES)/genext2fs \ 
- (HOST_OUT_EXECUTABLES)/tune2fs \
- (HOST_OUT_EXECUTABLES)/e2fsck \ 
- (HOST_OUT_EXECUTABLES)/e2fsck \ 
- (HOST_OUT_EXECUTABLES)/make_ext4fs
-
- .PHONY: otatools
- otatools: (OTATOOLS)
OTATOOLS := (OTATOOLS)
OTATOOLS := (HOST_OUT_EXECUTABLES)/minigzip \
(HOSTOUTEXECUTABLES)/mkbootfs ( H O S T O U T E X E C U T A B L E S ) / m k b o o t f s (HOST_OUT_EXECUTABLES)/mkbootimg \
(HOSTOUTEXECUTABLES)/fsconfig ( H O S T O U T E X E C U T A B L E S ) / f s c o n f i g (HOST_OUT_EXECUTABLES)/mkyaffs2image \
(HOSTOUTEXECUTABLES)/zipalign ( H O S T O U T E X E C U T A B L E S ) / z i p a l i g n (HOST_OUT_EXECUTABLES)/aapt \
(HOSTOUTEXECUTABLES)/bsdiff ( H O S T O U T E X E C U T A B L E S ) / b s d i f f (HOST_OUT_EXECUTABLES)/imgdiff \
(HOSTOUTJAVALIBRARIES)/dumpkey.jar ( H O S T O U T J A V A L I B R A R I E S ) / d u m p k e y . j a r (HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
(HOSTOUTEXECUTABLES)/mkuserimg.sh ( H O S T O U T E X E C U T A B L E S ) / m k u s e r i m g . s h (HOST_OUT_EXECUTABLES)/genext2fs \
(HOSTOUTEXECUTABLES)/tune2fs ( H O S T O U T E X E C U T A B L E S ) / t u n e 2 f s (HOST_OUT_EXECUTABLES)/e2fsck \
$(HOST_OUT_EXECUTABLES)/make_ext4fs
.PHONY: otatools
otatools: $(OTATOOLS)
代码段2 $(OTATOOLS)的编译规则
可以看出变量OTATOOLS为系统中一系列文件的集合。那么这些文件又有什么用处呢? 事实上,这些文件用于压缩(minigzip:用于gzip文件;make_ext4fs:将文件转换为ext4类型;mkyaffs2image:用于yaffs文件系统;……)、解压缩、差分(bsdiff,imgdiff)、签名(singapk.jar)等功能,结合代码段1可得到如下结论:目标 (INTERNALOTAPACKAGETARGET)的执行依赖于这一系列系统工具--仅此而已。也就是说,目标文件 ( I N T E R N A L O T A P A C K A G E T A R G E T ) 的 执 行 依 赖 于 这 一 系 列 系 统 工 具 - - 仅 此 而 已 。 也 就 是 说 , 目 标 文 件 (OTATOOLS)仅仅指定了命令执行所需要的工具,并未执行任何操作。
注:变量 (HOSTOUTEXECUTABLES)指代的是out/host/linux−x86/bin目录,而变量 ( H O S T O U T E X E C U T A B L E S ) 指 代 的 是 o u t / h o s t / l i n u x − x 86 / b i n 目 录 , 而 变 量 (HOST_OUT_JAVA_LIBRARIES)/表示的是out/host/linux-x86/framework目录,这意味着我们可以从此目录下找到上述工具,并为我们所用。
1.2$(BUILT_TARGET_FILES_PACKAGE)
目标OTATOOLS指明了执行make otapackage命令所需要的系统工具,而目标 (BUILTTARGEFILESPACKAGE)的生成则完成了两件事:重新打包system.img文件和</span>生成差分资源包。 ( B U I L T T A R G E F I L E S P A C K A G E ) 的 生 成 则 完 成 了 两 件 事 : 重 新 打 包 s y s t e m . i m g 文 件 和 < / s p a n > 生 成 差 分 资 源 包 。 (BUILT_TARGE_FILES_PACKAGE)的编译规则如下所示:
- # —————————————————————–
- # 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_PRODUCT)
- ifeq ( (TARGET_BUILD_TYPE),debug)
- name := (name)_debug
- endif
- name := (name)_debug
- endif
- name := (name)-target_files-(FILE_NAME_TAG)
-
- intermediates := (FILE_NAME_TAG)
-
- intermediates := (call intermediates-dir-for,PACKAGING,target_files)
- BUILT_TARGET_FILES_PACKAGE := (intermediates)/ ( i n t e r m e d i a t e s ) / (name).zip
- (BUILT_TARGET_FILES_PACKAGE): intermediates := (BUILT_TARGET_FILES_PACKAGE): intermediates := (intermediates)
- (BUILT_TARGET_FILES_PACKAGE): \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- zip_root := (BUILT_TARGET_FILES_PACKAGE): \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- zip_root := (intermediates)/(name)
-
- # (name)
-
- # (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 " (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 " (1))" -a " (ls -A (ls -A (1))” ]; then \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- mkdir -p (2) && \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (2) && \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (ACP) -rd (strip (strip (1))/* (2); \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- fi
- endef
-
- built_ota_tools := \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (2); \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- fi
- endef
-
- built_ota_tools := \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call intermediates-dir-for,EXECUTABLES,updater)/updater
- (BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := (BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := (built_ota_tools)
-
- (BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := (BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := (RECOVERY_API_VERSION)
-
- ifeq ((TARGET_RELEASETOOLS_EXTENSIONS),)
- # default to common dir for device vendor
- (TARGET_RELEASETOOLS_EXTENSIONS),)
- # default to common dir for device vendor
- (BUILT_TARGET_FILES_PACKAGE): tool_extensions := (TARGET_DEVICE_DIR)/../common
- else
- (TARGET_DEVICE_DIR)/../common
- else
- (BUILT_TARGET_FILES_PACKAGE): tool_extensions := (TARGET_RELEASETOOLS_EXTENSIONS)
- endif
-
- # Depending on the various images guarantees that the underlying
- # directories are up-to-date.
-
- ifeq ( (TARGET_RELEASETOOLS_EXTENSIONS)
- endif
-
- # Depending on the various images guarantees that the underlying
- # directories are up-to-date.
-
- ifeq ( (TARGET_USERIMAGES_USE_EXT4),true)
- (BUILT_TARGET_FILES_PACKAGE): (BUILT_TARGET_FILES_PACKAGE): (INSTALLED_CACHEIMAGE_TARGET)
- endif
-
- (BUILT_TARGET_FILES_PACKAGE): \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (BUILT_TARGET_FILES_PACKAGE): \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_BOOTIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_RADIOIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_RADIOIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_RECOVERYIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_FACTORYIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_FACTORYIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_SYSTEMIMAGE) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_CACHEIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_CACHEIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_USERDATAIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_SECROIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_SECROIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_ANDROID_INFO_TXT_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (built_ota_tools) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (built_ota_tools) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (APKCERTS_FILE) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (HOST_OUT_EXECUTABLES)/fs_config \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- | (HOST_OUT_EXECUTABLES)/fs_config \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- | (ACP)
- @echo “Package target files: @"
- @"
- (hide) rm -rf @ @ (zip_root)
- (hide) mkdir -p (hide) mkdir -p (dir @) @) (zip_root)
- @# Components of the recovery image
- (hide) mkdir -p (hide) mkdir -p (zip_root)/RECOVERY
- (hide) (hide) (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (TARGETRECOVERYROOTOUT), ( T A R G E T R E C O V E R Y R O O T O U T ) , (zip_root)/RECOVERY/RAMDISK)
- ifdef INSTALLED_KERNEL_TARGET
- (hide) (hide) (ACP) (INSTALLED_KERNEL_TARGET) (INSTALLED_KERNEL_TARGET) (zip_root)/RECOVERY/kernel
- (hide) (hide) (ACP) (recovery_ramdisk) (recovery_ramdisk) (zip_root)/RECOVERY/ramdisk
- endif
- ifdef INSTALLED_2NDBOOTLOADER_TARGET
- (hide) (hide) (ACP) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_2NDBOOTLOADER_TARGET) (INSTALLED_2NDBOOTLOADER_TARGET) (zip_root)/RECOVERY/second
- endif
- ifdef BOARD_KERNEL_CMDLINE
- (hide) echo " (hide) echo " (BOARD_KERNEL_CMDLINE)” > (zip_root)/RECOVERY/cmdline
- endif
- ifdef BOARD_KERNEL_BASE
- (zip_root)/RECOVERY/cmdline
- endif
- ifdef BOARD_KERNEL_BASE
- (hide) echo ”(BOARD_KERNEL_BASE)" > (BOARD_KERNEL_BASE)" > (zip_root)/RECOVERY/base
- endif
- @# Components of the factory image
- (hide) mkdir -p (hide) mkdir -p (zip_root)/FACTORY
- (hide) (hide) (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (TARGETFACTORYROOTOUT), ( T A R G E T F A C T O R Y R O O T O U T ) , (zip_root)/FACTORY/RAMDISK)
- ifdef INSTALLED_KERNEL_TARGET
- (hide) (hide) (ACP) (INSTALLED_KERNEL_TARGET) (INSTALLED_KERNEL_TARGET) (zip_root)/FACTORY/kernel
- endif
- ifdef BOARD_KERNEL_PAGESIZE
- (hide) echo " (hide) echo " (BOARD_KERNEL_PAGESIZE)” > (zip_root)/RECOVERY/pagesize
- endif
- ifdef INSTALLED_2NDBOOTLOADER_TARGET
- (zip_root)/RECOVERY/pagesize
- endif
- ifdef INSTALLED_2NDBOOTLOADER_TARGET
- (hide) (ACP) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (ACP) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_2NDBOOTLOADER_TARGET) (zip_root)/FACTORY/second
- endif
- ifdef BOARD_KERNEL_CMDLINE
- (zip_root)/FACTORY/second
- endif
- ifdef BOARD_KERNEL_CMDLINE
- (hide) echo ”(BOARD_KERNEL_CMDLINE)" > (BOARD_KERNEL_CMDLINE)" > (zip_root)/FACTORY/cmdline
- endif
- ifdef BOARD_KERNEL_BASE
- (hide) echo " (hide) echo " (BOARD_KERNEL_BASE)” > (zip_root)/FACTORY/base
- endif
- @# Components of the boot image
- (zip_root)/FACTORY/base
- endif
- @# Components of the boot image
- (hide) mkdir -p (zip_root)/BOOT
- (zip_root)/BOOT
- (hide) (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (TARGET_ROOT_OUT),(zip_root)/BOOT/RAMDISK)
- ifdef INSTALLED_KERNEL_TARGET
- (zip_root)/BOOT/RAMDISK)
- ifdef INSTALLED_KERNEL_TARGET
- (hide) (ACP) (ACP) (INSTALLED_KERNEL_TARGET) (zip_root)/BOOT/kernel
- (zip_root)/BOOT/kernel
- (hide) (ACP) (ACP) (INSTALLED_RAMDISK_TARGET) (zip_root)/BOOT/ramdisk
- endif
- ifdef INSTALLED_2NDBOOTLOADER_TARGET
- (zip_root)/BOOT/ramdisk
- endif
- ifdef INSTALLED_2NDBOOTLOADER_TARGET
- (hide) (ACP) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (ACP) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (INSTALLED_2NDBOOTLOADER_TARGET) (zip_root)/BOOT/second
- endif
- ifdef BOARD_KERNEL_CMDLINE
- (zip_root)/BOOT/second
- endif
- ifdef BOARD_KERNEL_CMDLINE
- (hide) echo ”(BOARD_KERNEL_CMDLINE)" > (BOARD_KERNEL_CMDLINE)" > (zip_root)/BOOT/cmdline
- endif
- ifdef BOARD_KERNEL_BASE
- (hide) echo " (hide) echo " (BOARD_KERNEL_BASE)” > (zip_root)/BOOT/base
- endif
- ifdef BOARD_KERNEL_PAGESIZE
- (zip_root)/BOOT/base
- endif
- ifdef BOARD_KERNEL_PAGESIZE
- (hide) echo ”(BOARD_KERNEL_PAGESIZE)" > (BOARD_KERNEL_PAGESIZE)" > (zip_root)/BOOT/pagesize
- endif
- #wschen
- ifneq ”“ ”(CUSTOM_BUILD_VERNO)"
- (CUSTOM_BUILD_VERNO)"
- (hide) echo ”(CUSTOM_BUILD_VERNO)" > (CUSTOM_BUILD_VERNO)" > (zip_root)/BOOT/board
- endif
-
- #[eton begin]: added by LiuDekuan for u-boot update
- (hide) (hide) (ACP) (PRODUCT_OUT)/uboot_eyang77_ics2.bin (PRODUCT_OUT)/uboot_eyang77_ics2.bin (zip_root)/uboot.bin
- #[eton end]
-
- (hide) (hide) (foreach t,(INSTALLED_RADIOIMAGE_TARGET),\&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- mkdir -p (INSTALLED_RADIOIMAGE_TARGET),\&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- mkdir -p (zip_root)/RADIO; \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (ACP) (ACP) (t) (ziproot)/RADIO/ ( z i p r o o t ) / R A D I O / (notdir (t));)
- @# Contents of the system image
- (t));)
- @# Contents of the system image
- (hide) (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (SYSTEMIMAGE_SOURCE_DIR),(zip_root)/SYSTEM)
- @# Contents of the data image
- (zip_root)/SYSTEM)
- @# Contents of the data image
- (hide) (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;
- (TARGET_OUT_DATA),(zip_root)/DATA)
- @# Extra contents of the OTA package
- (zip_root)/DATA)
- @# Extra contents of the OTA package
- (hide) mkdir -p (zip_root)/OTA/bin
- (zip_root)/OTA/bin
- (hide) (ACP) (ACP) (INSTALLED_ANDROID_INFO_TXT_TARGET) (zip_root)/OTA/
- (zip_root)/OTA/
- (hide) (ACP) (ACP) (PRIVATE_OTA_TOOLS) (zip_root)/OTA/bin/
- @# Security information of the OTA package
- @echo "[SEC OTA] Adding Security information to OTA package"
- @echo "[SEC OTA] path : mediatek/custom/ (zip_root)/OTA/bin/
- @# Security information of the OTA package
- @echo "[SEC OTA] Adding Security information to OTA package"
- @echo "[SEC OTA] path : mediatek/custom/ (MTK_PROJECT)/security/recovery/SEC_VER.txt”
- (hide) (hide) (ACP) mediatek/custom/(MTK_PROJECT)/security/recovery/SEC_VER.txt (MTK_PROJECT)/security/recovery/SEC_VER.txt (zip_root)/OTA/
- @# Files that do not end up in any images, but are necessary to
- @# build them.
- (hide) mkdir -p (hide) mkdir -p (zip_root)/META
- (hide) (hide) (ACP) (APKCERTS_FILE) (APKCERTS_FILE) (zip_root)/META/apkcerts.txt
- (hide) echo " (hide) echo " (PRODUCT_OTA_PUBLIC_KEYS)” > (zip_root)/META/otakeys.txt
- (zip_root)/META/otakeys.txt
- (hide) echo “recovery_api_version=(PRIVATE_RECOVERY_API_VERSION)" > (PRIVATE_RECOVERY_API_VERSION)" > (zip_root)/META/misc_info.txt
- ifdef BOARD_FLASH_BLOCK_SIZE
- (hide) echo "blocksize= (hide) echo "blocksize= (BOARD_FLASH_BLOCK_SIZE)” >> (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
- (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
- (hide) echo “boot_size=(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> (BOARD_BOOTIMAGE_PARTITION_SIZE)" >> (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
- (hide) echo "recovery_size= (hide) echo "recovery_size= (BOARD_RECOVERYIMAGE_PARTITION_SIZE)” >> (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
- (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
- (hide) echo “system_size=(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> (BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_SECROIMAGE_PARTITION_SIZE
- (hide) echo "secro_size= (hide) echo "secro_size= (BOARD_SECROIMAGE_PARTITION_SIZE)” >> (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_CACHEIMAGE_PARTITION_SIZE
- (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_CACHEIMAGE_PARTITION_SIZE
- (hide) echo “cache_size=(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> (BOARD_CACHEIMAGE_PARTITION_SIZE)" >> (zip_root)/META/misc_info.txt
- endif
- ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
- (hide) echo "userdata_size= (hide) echo "userdata_size= (BOARD_USERDATAIMAGE_PARTITION_SIZE)” >> (zip_root)/META/misc_info.txt
- endif
- (zip_root)/META/misc_info.txt
- endif
- (hide) echo “tool_extensions=(tool_extensions)" >> (tool_extensions)" >> (zip_root)/META/misc_info.txt
- ifdef mkyaffs2_extra_flags
- (hide) echo "mkyaffs2_extra_flags= (hide) echo "mkyaffs2_extra_flags= (mkyaffs2_extra_flags)” >> (zip_root)/META/misc_info.txt
- endif
- ifdef INTERNAL_USERIMAGES_SPARSE_EXT_FLAG
- (zip_root)/META/misc_info.txt
- endif
- ifdef INTERNAL_USERIMAGES_SPARSE_EXT_FLAG
- (hide) echo “extfs_sparse_flag=(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> (INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> (zip_root)/META/misc_info.txt
- endif
- (hide) echo "default_system_dev_certificate= (hide) echo "default_system_dev_certificate= (DEFAULT_KEY_CERT_PAIR)” >> (zip_root)/META/misc_info.txt
- ifdef PRODUCT_EXTRA_RECOVERY_KEYS
- (zip_root)/META/misc_info.txt
- ifdef PRODUCT_EXTRA_RECOVERY_KEYS
- (hide) echo “extra_recovery_keys=(PRODUCT_EXTRA_RECOVERY_KEYS)" >> (PRODUCT_EXTRA_RECOVERY_KEYS)" >> (zip_root)/META/misc_info.txt
- endif
- @# Zip everything up, preserving symlinks
- (hide) (cd (hide) (cd (zip_root) && zip -qry ../(notdir (notdir @) .)
- @# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output
- (hide) zipinfo -1 (hide) zipinfo -1 @ | awk ‘BEGIN { FS=”SYSTEM/” } /^SYSTEM\// {print “system/”
2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt - $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print
2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt - $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print
2}' | (HOST_OUT_EXECUTABLES)/fs_config > (HOST_OUT_EXECUTABLES)/fs_config > (zip_root)/META/boot_filesystem_config.txt - (hide) zipinfo -1 (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 (hide) (cd (zip_root) && zip -q ../(notdir (notdir @) META/*filesystem_config.txt)
-
-
- target-files-package: (BUILT_TARGET_FILES_PACKAGE)
-
-
- ifneq ( (BUILT_TARGET_FILES_PACKAGE)
-
-
- ifneq ( (TARGET_PRODUCT),sdk)
- ifeq ((filter generic%, (filter generic%, (TARGET_DEVICE)),)
- ifneq ((TARGET_NO_KERNEL),true)
- ifneq ( (TARGET_NO_KERNEL),true)
- ifneq ( (recovery_fstab),)
# —————————————————————–
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 := (TARGETPRODUCT)ifeq( ( T A R G E T P R O D U C T ) i f e q ( (TARGET_BUILD_TYPE),debug)
name := (name)debugendifname:= ( n a m e ) d e b u g e n d i f n a m e := (name)-target_files-$(FILE_NAME_TAG)
intermediates := (callintermediates−dir−for,PACKAGING,targetfiles)BUILTTARGETFILESPACKAGE:= ( c a l l i n t e r m e d i a t e s − d i r − f o r , P A C K A G I N G , t a r g e t f i l e s ) B U I L T T A R G E T F I L E S P A C K A G E := (intermediates)/ (name).zip ( n a m e ) . z i p (BUILT_TARGET_FILES_PACKAGE): intermediates := (intermediates) ( i n t e r m e d i a t e s ) (BUILT_TARGET_FILES_PACKAGE): \
zip_root := (intermediates)/ ( i n t e r m e d i a t e s ) / (name)
$(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 ( s t r i p (1))" -a "$$(ls -A $(1))" ]; then \
mkdir -p $(2) && \
$(ACP) -rd $(strip $(1))/* $(2); \
fi
endef
built_ota_tools := \
(callintermediates−dir−for,EXECUTABLES,applypatch)/applypatch ( c a l l i n t e r m e d i a t e s − d i r − f o r , E X E C U T A B L E S , a p p l y p a t c h ) / a p p l y p a t c h (call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
(callintermediates−dir−for,EXECUTABLES,checkprereq)/checkprereq ( c a l l i n t e r m e d i a t e s − d i r − f o r , E X E C U T A B L E S , c h e c k p r e r e q ) / c h e c k p r e r e q (call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
(callintermediates−dir−for,EXECUTABLES,updater)/updater ( c a l l i n t e r m e d i a t e s − d i r − f o r , E X E C U T A B L E S , u p d a t e r ) / u p d a t e r (BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
(BUILTTARGETFILESPACKAGE):PRIVATERECOVERYAPIVERSION:= ( B U I L T T A R G E T F I L E S P A C K A G E ) : P R I V A T E R E C O V E R Y A P I V E R S I O N := (RECOVERY_API_VERSION)
ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
default to common dir for device vendor
(BUILTTARGETFILESPACKAGE):toolextensions:= ( B U I L T T A R G E T F I L E S P A C K A G E ) : t o o l e x t e n s i o n s := (TARGET_DEVICE_DIR)/../common
else
(BUILTTARGETFILESPACKAGE):toolextensions:= ( B U I L T T A R G E T F I L E S P A C K A G E ) : t o o l e x t e n s i o n s := (TARGET_RELEASETOOLS_EXTENSIONS)
endif
Depending on the various images guarantees that the underlying
directories are up-to-date.
ifeq ( (TARGETUSERIMAGESUSEEXT4),true) ( T A R G E T U S E R I M A G E S U S E E X T 4 ) , t r u e ) (BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_CACHEIMAGE_TARGET)
endif
(BUILTTARGETFILESPACKAGE): ( B U I L T T A R G E T F I L E S P A C K A G E ) : (INSTALLED_BOOTIMAGE_TARGET) \
(INSTALLEDRADIOIMAGETARGET) ( I N S T A L L E D R A D I O I M A G E T A R G E T ) (INSTALLED_RECOVERYIMAGE_TARGET) \
(INSTALLEDFACTORYIMAGETARGET) ( I N S T A L L E D F A C T O R Y I M A G E T A R G E T ) (INSTALLED_SYSTEMIMAGE) \
(INSTALLEDCACHEIMAGETARGET) ( I N S T A L L E D C A C H E I M A G E T A R G E T ) (INSTALLED_USERDATAIMAGE_TARGET) \
(INSTALLEDSECROIMAGETARGET) ( I N S T A L L E D S E C R O I M A G E T A R G E T ) (INSTALLED_ANDROID_INFO_TXT_TARGET) \
(builtotatools) ( b u i l t o t a t o o l s ) (APKCERTS_FILE) \
(HOSTOUTEXECUTABLES)/fsconfig | ( H O S T O U T E X E C U T A B L E S ) / f s c o n f i g | (ACP)
@echo "Package target files: @" @ " (hide) rm -rf @ @ (zip_root)
(hide)mkdir−p ( h i d e ) m k d i r − p (dir @) @ ) (zip_root)
@# Components of the recovery image
(hide)mkdir−p ( h i d e ) m k d i r − p (zip_root)/RECOVERY
(hide) ( h i d e ) (call package_files-copy-root, \
(TARGETRECOVERYROOTOUT), ( T A R G E T R E C O V E R Y R O O T O U T ) , (zip_root)/RECOVERY/RAMDISK)
ifdef INSTALLED_KERNEL_TARGET
(hide) ( h i d e ) (ACP) (INSTALLEDKERNELTARGET) ( I N S T A L L E D K E R N E L T A R G E T ) (zip_root)/RECOVERY/kernel
(hide) ( h i d e ) (ACP) (recoveryramdisk) ( r e c o v e r y r a m d i s k ) (zip_root)/RECOVERY/ramdisk
endif
ifdef INSTALLED_2NDBOOTLOADER_TARGET
(hide) ( h i d e ) (ACP) \
(INSTALLED2NDBOOTLOADERTARGET) ( I N S T A L L E D 2 N D B O O T L O A D E R T A R G E T ) (zip_root)/RECOVERY/second
endif
ifdef BOARD_KERNEL_CMDLINE
(hide)echo" ( h i d e ) e c h o " (BOARD_KERNEL_CMDLINE)" > (ziproot)/RECOVERY/cmdlineendififdefBOARDKERNELBASE ( z i p r o o t ) / R E C O V E R Y / c m d l i n e e n d i f i f d e f B O A R D K E R N E L B A S E (hide) echo " (BOARDKERNELBASE)"> ( B O A R D K E R N E L B A S E ) "> (zip_root)/RECOVERY/base
endif
@# Components of the factory image
(hide)mkdir−p ( h i d e ) m k d i r − p (zip_root)/FACTORY
(hide) ( h i d e ) (call package_files-copy-root, \
(TARGETFACTORYROOTOUT), ( T A R G E T F A C T O R Y R O O T O U T ) , (zip_root)/FACTORY/RAMDISK)
ifdef INSTALLED_KERNEL_TARGET
(hide) ( h i d e ) (ACP) (INSTALLEDKERNELTARGET) ( I N S T A L L E D K E R N E L T A R G E T ) (zip_root)/FACTORY/kernel
endif
ifdef BOARD_KERNEL_PAGESIZE
(hide)echo" ( h i d e ) e c h o " (BOARD_KERNEL_PAGESIZE)" > (ziproot)/RECOVERY/pagesizeendififdefINSTALLED2NDBOOTLOADERTARGET ( z i p r o o t ) / R E C O V E R Y / p a g e s i z e e n d i f i f d e f I N S T A L L E D 2 N D B O O T L O A D E R T A R G E T (hide) (ACP) ( A C P ) (INSTALLED_2NDBOOTLOADER_TARGET) (ziproot)/FACTORY/secondendififdefBOARDKERNELCMDLINE ( z i p r o o t ) / F A C T O R Y / s e c o n d e n d i f i f d e f B O A R D K E R N E L C M D L I N E (hide) echo " (BOARDKERNELCMDLINE)"> ( B O A R D K E R N E L C M D L I N E ) "> (zip_root)/FACTORY/cmdline
endif
ifdef BOARD_KERNEL_BASE
(hide)echo" ( h i d e ) e c h o " (BOARD_KERNEL_BASE)" > (zip_root)/FACTORY/base
endif
@# Components of the boot image (zip_root)/FACTORY/base endif @# Components of the boot image (hide) mkdir -p (ziproot)/BOOT ( z i p r o o t ) / B O O T (hide) (callpackagefiles−copy−root, ( c a l l p a c k a g e f i l e s − c o p y − r o o t , (TARGET_ROOT_OUT), (ziproot)/BOOT/RAMDISK)ifdefINSTALLEDKERNELTARGET ( z i p r o o t ) / B O O T / R A M D I S K ) i f d e f I N S T A L L E D K E R N E L T A R G E T (hide) (ACP) ( A C P ) (INSTALLED_KERNEL_TARGET) (ziproot)/BOOT/kernel ( z i p r o o t ) / B O O T / k e r n e l (hide) (ACP) ( A C P ) (INSTALLED_RAMDISK_TARGET) (ziproot)/BOOT/ramdiskendififdefINSTALLED2NDBOOTLOADERTARGET ( z i p r o o t ) / B O O T / r a m d i s k e n d i f i f d e f I N S T A L L E D 2 N D B O O T L O A D E R T A R G E T (hide) (ACP) ( A C P ) (INSTALLED_2NDBOOTLOADER_TARGET) (ziproot)/BOOT/secondendififdefBOARDKERNELCMDLINE ( z i p r o o t ) / B O O T / s e c o n d e n d i f i f d e f B O A R D K E R N E L C M D L I N E (hide) echo " (BOARDKERNELCMDLINE)"> ( B O A R D K E R N E L C M D L I N E ) "> (zip_root)/BOOT/cmdline
endif
ifdef BOARD_KERNEL_BASE
(hide)echo" ( h i d e ) e c h o " (BOARD_KERNEL_BASE)" > (ziproot)/BOOT/baseendififdefBOARDKERNELPAGESIZE ( z i p r o o t ) / B O O T / b a s e e n d i f i f d e f B O A R D K E R N E L P A G E S I Z E (hide) echo " (BOARDKERNELPAGESIZE)"> ( B O A R D K E R N E L P A G E S I Z E ) "> (zip_root)/BOOT/pagesize
endif
wschen
ifneq "" " (CUSTOMBUILDVERNO)" ( C U S T O M B U I L D V E R N O ) " (hide) echo " (CUSTOMBUILDVERNO)"> ( C U S T O M B U I L D V E R N O ) "> (zip_root)/BOOT/board
endif
[eton begin]: added by LiuDekuan for u-boot update
$(hide) $(ACP) $(PRODUCT_OUT)/uboot_eyang77_ics2.bin $(zip_root)/uboot.bin
[eton end]
$(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)
@# 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/
@# Security information of the OTA package
@echo "[SEC OTA] Adding Security information to OTA package"
@echo "[SEC OTA] path : mediatek/custom/$(MTK_PROJECT)/security/recovery/SEC_VER.txt"
$(hide) $(ACP) mediatek/custom/$(MTK_PROJECT)/security/recovery/SEC_VER.txt $(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) 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
ifdef BOARD_FLASH_BLOCK_SIZE
(hide)echo"blocksize= ( h i d e ) e c h o " b l o c k s i z e = (BOARD_FLASH_BLOCK_SIZE)” >> (ziproot)/META/miscinfo.txtendififdefBOARDBOOTIMAGEPARTITIONSIZE ( z i p r o o t ) / M E T A / m i s c i n f o . t x t e n d i f i f d e f B O A R D B O O T I M A G E P A R T I T I O N S I Z E (hide) echo "boot_size= (BOARDBOOTIMAGEPARTITIONSIZE)”>> ( B O A R D B O O T I M A G E P A R T I T I O N S I Z E ) ” >> (zip_root)/META/misc_info.txt
endif
ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
(hide)echo"recoverysize= ( h i d e ) e c h o " r e c o v e r y s i z e = (BOARD_RECOVERYIMAGE_PARTITION_SIZE)” >> (ziproot)/META/miscinfo.txtendififdefBOARDSYSTEMIMAGEPARTITIONSIZE ( z i p r o o t ) / M E T A / m i s c i n f o . t x t e n d i f i f d e f B O A R D S Y S T E M I M A G E P A R T I T I O N S I Z E (hide) echo "system_size= (BOARDSYSTEMIMAGEPARTITIONSIZE)”>> ( B O A R D S Y S T E M I M A G E P A R T I T I O N S I Z E ) ” >> (zip_root)/META/misc_info.txt
endif
ifdef BOARD_SECROIMAGE_PARTITION_SIZE
(hide)echo"secrosize= ( h i d e ) e c h o " s e c r o s i z e = (BOARD_SECROIMAGE_PARTITION_SIZE)” >> (ziproot)/META/miscinfo.txtendififdefBOARDCACHEIMAGEPARTITIONSIZE ( z i p r o o t ) / M E T A / m i s c i n f o . t x t e n d i f i f d e f B O A R D C A C H E I M A G E P A R T I T I O N S I Z E (hide) echo "cache_size= (BOARDCACHEIMAGEPARTITIONSIZE)”>> ( B O A R D C A C H E I M A G E P A R T I T I O N S I Z E ) ” >> (zip_root)/META/misc_info.txt
endif
ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
(hide)echo"userdatasize= ( h i d e ) e c h o " u s e r d a t a s i z e = (BOARD_USERDATAIMAGE_PARTITION_SIZE)” >> (ziproot)/META/miscinfo.txtendif ( z i p r o o t ) / M E T A / m i s c i n f o . t x t e n d i f (hide) echo "tool_extensions= (toolextensions)”>> ( t o o l e x t e n s i o n s ) ” >> (zip_root)/META/misc_info.txt
ifdef mkyaffs2_extra_flags
(hide)echo"mkyaffs2extraflags= ( h i d e ) e c h o " m k y a f f s 2 e x t r a f l a g s = (mkyaffs2_extra_flags)” >> (ziproot)/META/miscinfo.txtendififdefINTERNALUSERIMAGESSPARSEEXTFLAG ( z i p r o o t ) / M E T A / m i s c i n f o . t x t e n d i f i f d e f I N T E R N A L U S E R I M A G E S S P A R S E E X T F L A G (hide) echo "extfs_sparse_flag= (INTERNALUSERIMAGESSPARSEEXTFLAG)”>> ( I N T E R N A L U S E R I M A G E S S P A R S E E X T F L A G ) ” >> (zip_root)/META/misc_info.txt
endif
(hide)echo"defaultsystemdevcertificate= ( h i d e ) e c h o " d e f a u l t s y s t e m d e v c e r t i f i c a t e = (DEFAULT_KEY_CERT_PAIR)” >> (ziproot)/META/miscinfo.txtifdefPRODUCTEXTRARECOVERYKEYS ( z i p r o o t ) / M E T A / m i s c i n f o . t x t i f d e f P R O D U C T E X T R A R E C O V E R Y K E Y S (hide) echo "extra_recovery_keys= (PRODUCTEXTRARECOVERYKEYS)”>> ( P R O D U C T E X T R A R E C O V E R Y K E Y S ) ” >> (zip_root)/META/misc_info.txt
endif
@# Zip everything up, preserving symlinks
(hide)(cd ( h i d e ) ( c d (zip_root) && zip -qry ../ (notdir ( n o t d i r @) .)
@# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output
(hide)zipinfo−1 ( h i d e ) z i p i n f o − 1 @ | awk ‘BEGIN { FS=”SYSTEM/” } /^SYSTEM\// {print “system/”
2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print 2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print
2}' |
(HOST_OUT_EXECUTABLES)/fs_config > (HOST_OUT_EXECUTABLES)/fs_config > (zip_root)/META/boot_filesystem_config.txt
(hide)zipinfo−1 ( h i d e ) z i p i n f o − 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)
target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
ifneq ( (TARGETPRODUCT),sdk)ifeq( ( T A R G E T P R O D U C T ) , s d k ) i f e q ( (filter generic%, (TARGETDEVICE)),)ifneq( ( T A R G E T D E V I C E ) ) , ) i f n e q ( (TARGET_NO_KERNEL),true)
ifneq ($(recovery_fstab),)
代码段3 $(BUILT_TARGE_FILES_PACKAGE)目标的编译规则
system.img文件的重新打包是通过 (BUILTTARGEFILESPACKAGE)的依赖条件 ( B U I L T T A R G E F I L E S P A C K A G E ) 的 依 赖 条 件 (INSTALLED_SYSTEMIMAGE)目标文件的编译来完成的,而$(BUILT_TARGE_FILES_PACKAGE)所有的执行命令(代码第66行至最后)都只为完成一件事,生成差分资源包所对应的目录并将其打包为ZIP包。具体的操作包括:
- 创建 (ziproot)目录(代码第66 68行), ( z i p r o o t ) 目 录 ( 代 码 第 66 68 行 ) , (zip_root)即out/target/product//obj/PACKAGING/target_files_from_intermedias/-target_files-;
- 创建/ (ziproot)/RECOVERY目录并将COPY相关文件(代码69 86);</li><li>创建/ ( z i p r o o t ) / R E C O V E R Y 目 录 并 将 C O P Y 相 关 文 件 ( 代 码 69 86 ) ; < / l i >< l i > 创 建 / (zip_root)/FACTORY目录并将COPY相关文件(代码87~106);
- 创建/