make otapackage 流程分析

原文链接: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

        本文将对此命令的执行过程进行分析。

[plain] view plain copy
print ?
  1. # —————————————————————–  
  2. # OTA update package  
  3.   
  4. name := (TARGET_PRODUCT)  
  5. ifeq ( (TARGET_PRODUCT)  ifeq ( (TARGET_BUILD_TYPE),debug)  
  6.   name := (name)_debug  
  7. 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)  
  8.     @echo “Package OTA: @"  
  9.      @"       (hide) ./build/tools/releasetools/ota_from_target_files -v \  
  10.        -n \  
  11.        -p (HOST_OUT) \  
  12.            -k  (HOST_OUT) \             -k  (KEY_CERT_PAIR) \  
  13.            (BUILT_TARGET_FILES_PACKAGE)  (BUILT_TARGET_FILES_PACKAGE)  @  
  14.   
  15. .PHONY: otapackage  
  16. otapackage: (INTERNAL_OTA_PACKAGE_TARGET)  
  17.   # -----------------------------------------------------------------  # The update package    name :=  (INTERNAL_OTA_PACKAGE_TARGET)    # -----------------------------------------------------------------  # The update package    name :=  (TARGET_PRODUCT)  
  18. ifeq ((TARGET_BUILD_TYPE),debug)  
  19.   name :=  (TARGET_BUILD_TYPE),debug)    name :=  (name)_debug  
  20. endif  
  21. 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/otafromtargetfilesv 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)

[plain] view plain copy
print ?
  1. 代码段1 Makefile文件中目标otapackage的执行代码  
代码段1 Makefile文件中目标otapackage的执行代码

       

        首先,make otapackage命令会执行Makefile(./build/core/Makefile)中otapackage的目标代码(如代码1所示)。由代码可知,otapackage目标的执行只依赖于 (INTERNALOTAPACKAGETARGET)(MakefileTABotapackagename) ( 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的编译规则如下所示

[plain] view plain copy
print ?
  1. OTATOOLS :=  (HOST_OUT_EXECUTABLES)/minigzip \  
  2.        (HOST_OUT_EXECUTABLES)/minigzip \         (HOST_OUT_EXECUTABLES)/mkbootfs \  
  3.       (HOST_OUT_EXECUTABLES)/mkbootimg \  
  4.        (HOST_OUT_EXECUTABLES)/mkbootimg \         (HOST_OUT_EXECUTABLES)/fs_config \  
  5.       (HOST_OUT_EXECUTABLES)/mkyaffs2image \  
  6.        (HOST_OUT_EXECUTABLES)/mkyaffs2image \         (HOST_OUT_EXECUTABLES)/zipalign \  
  7.       (HOST_OUT_EXECUTABLES)/aapt \  
  8.        (HOST_OUT_EXECUTABLES)/aapt \         (HOST_OUT_EXECUTABLES)/bsdiff \  
  9.       (HOST_OUT_EXECUTABLES)/imgdiff \  
  10.        (HOST_OUT_EXECUTABLES)/imgdiff \         (HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \  
  11.       (HOST_OUT_JAVA_LIBRARIES)/signapk.jar \  
  12.        (HOST_OUT_JAVA_LIBRARIES)/signapk.jar \         (HOST_OUT_EXECUTABLES)/mkuserimg.sh \  
  13.       (HOST_OUT_EXECUTABLES)/genext2fs \  
  14.        (HOST_OUT_EXECUTABLES)/genext2fs \         (HOST_OUT_EXECUTABLES)/tune2fs \  
  15.       (HOST_OUT_EXECUTABLES)/e2fsck \  
  16.        (HOST_OUT_EXECUTABLES)/e2fsck \         (HOST_OUT_EXECUTABLES)/make_ext4fs  
  17.   
  18. .PHONY: otatools  
  19. 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/linuxx86/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)的编译规则如下所示:

[plain] view plain copy
print ?
  1. # —————————————————————–  
  2. # A zip of the directories that map to the target filesystem.  
  3. # This zip can be used to create an OTA package or filesystem image  
  4. # as a post-build step.  
  5. #  
  6. name := (TARGET_PRODUCT)  
  7. ifeq ( (TARGET_PRODUCT)  ifeq ( (TARGET_BUILD_TYPE),debug)  
  8.   name := (name)_debug  
  9. endif  name :=  (name)_debug  endif  name :=  (name)-target_files-(FILE_NAME_TAG)    intermediates :=  (FILE_NAME_TAG)    intermediates :=  (call intermediates-dir-for,PACKAGING,target_files)  
  10. BUILT_TARGET_FILES_PACKAGE :=  (intermediates)/ ( i n t e r m e d i a t e s ) / (name).zip  
  11. (BUILT_TARGET_FILES_PACKAGE): intermediates :=  (BUILT_TARGET_FILES_PACKAGE): intermediates :=  (intermediates)  
  12. (BUILT_TARGET_FILES_PACKAGE): \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  13.         zip_root :=  (BUILT_TARGET_FILES_PACKAGE): \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;         zip_root :=  (intermediates)/(name)     (name)    (1): Directory to copy  
  14. (2): Location to copy it to  
  15. # 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;amp;nbsp; 
  16.     mkdir -p (2) && \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  17.      (2) && \&amp;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;amp;nbsp;   fi  endef    built_ota_tools := \&amp;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;amp;nbsp;   fi  endef    built_ota_tools := \&amp;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;amp;nbsp; 
  18.     (call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  19.      (call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \&amp;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;amp;nbsp; 
  20.     (call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  21.      (call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;      (call intermediates-dir-for,EXECUTABLES,updater)/updater  
  22. (BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS :=  (BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS :=  (built_ota_tools)  
  23.   
  24. (BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION :=  (BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION :=  (RECOVERY_API_VERSION)  
  25.   
  26. ifeq ((TARGET_RELEASETOOLS_EXTENSIONS),)  
  27. # 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)  
  28. (BUILT_TARGET_FILES_PACKAGE):  (BUILT_TARGET_FILES_PACKAGE):  (INSTALLED_CACHEIMAGE_TARGET)  
  29. endif  
  30.   
  31. (BUILT_TARGET_FILES_PACKAGE): \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  32.          (BUILT_TARGET_FILES_PACKAGE): \&amp;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;amp;nbsp; 
  33.         (INSTALLED_RADIOIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  34.          (INSTALLED_RADIOIMAGE_TARGET) \&amp;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;amp;nbsp; 
  35.         (INSTALLED_FACTORYIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  36.          (INSTALLED_FACTORYIMAGE_TARGET) \&amp;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;amp;nbsp; 
  37.         (INSTALLED_CACHEIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  38.          (INSTALLED_CACHEIMAGE_TARGET) \&amp;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;amp;nbsp; 
  39.         (INSTALLED_SECROIMAGE_TARGET) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  40.          (INSTALLED_SECROIMAGE_TARGET) \&amp;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;amp;nbsp; 
  41.         (built_ota_tools) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  42.          (built_ota_tools) \&amp;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;amp;nbsp; 
  43.         (HOST_OUT_EXECUTABLES)/fs_config \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  44.         |  (HOST_OUT_EXECUTABLES)/fs_config \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp;         |  (ACP)  
  45.     @echo “Package target files: @"  
  46.      @"       (hide) rm -rf (zip_root)  
  47.     (hide) mkdir -p  (hide) mkdir -p  (dir @)  @)  (zip_root)  
  48.     @# Components of the recovery image  
  49.     (hide) mkdir -p  (hide) mkdir -p  (zip_root)/RECOVERY  
  50.     (hide)  (hide)  (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  51.          (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)  
  52. ifdef INSTALLED_KERNEL_TARGET  
  53.     (hide)  (hide)  (ACP) (INSTALLED_KERNEL_TARGET)  (INSTALLED_KERNEL_TARGET)  (zip_root)/RECOVERY/kernel  
  54.     (hide)  (hide)  (ACP) (recovery_ramdisk)  (recovery_ramdisk)  (zip_root)/RECOVERY/ramdisk  
  55. endif  
  56. ifdef INSTALLED_2NDBOOTLOADER_TARGET  
  57.     (hide)  (hide)  (ACP) \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  58.         (INSTALLED_2NDBOOTLOADER_TARGET)  (INSTALLED_2NDBOOTLOADER_TARGET)  (zip_root)/RECOVERY/second  
  59. endif  
  60. ifdef BOARD_KERNEL_CMDLINE  
  61.     (hide) echo " (hide) echo " (BOARD_KERNEL_CMDLINE)” > (zip_root)/RECOVERY/cmdline  
  62. 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  
  63. endif  
  64.     @# Components of the factory image  
  65.     (hide) mkdir -p  (hide) mkdir -p  (zip_root)/FACTORY  
  66.     (hide)  (hide)  (call package_files-copy-root, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  67.          (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)  
  68. ifdef INSTALLED_KERNEL_TARGET  
  69.     (hide)  (hide)  (ACP) (INSTALLED_KERNEL_TARGET)  (INSTALLED_KERNEL_TARGET)  (zip_root)/FACTORY/kernel  
  70. endif  
  71. ifdef BOARD_KERNEL_PAGESIZE  
  72.     (hide) echo " (hide) echo " (BOARD_KERNEL_PAGESIZE)” > (zip_root)/RECOVERY/pagesize  
  73. 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;amp;nbsp;          (ACP) \&amp;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  
  74. endif  
  75. ifdef BOARD_KERNEL_BASE  
  76.     (hide) echo " (hide) echo " (BOARD_KERNEL_BASE)” > (zip_root)/FACTORY/base  
  77. 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;amp;nbsp;          (call package_files-copy-root, \&amp;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;amp;nbsp;          (ACP) \&amp;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  
  78. endif  
  79. ifdef BOARD_KERNEL_BASE  
  80.     (hide) echo " (hide) echo " (BOARD_KERNEL_BASE)” > (zip_root)/BOOT/base  
  81. 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  
  82. endif  
  83. #wschen  
  84. ifneq ”“ ”(CUSTOM_BUILD_VERNO)"  
  85.      (CUSTOM_BUILD_VERNO)"       (hide) echo ”(CUSTOM_BUILD_VERNO)" >  (CUSTOM_BUILD_VERNO)" >  (zip_root)/BOOT/board  
  86. endif  
  87.   
  88. #[eton begin]: added by LiuDekuan for u-boot update  
  89.     (hide)  (hide)  (ACP) (PRODUCT_OUT)/uboot_eyang77_ics2.bin  (PRODUCT_OUT)/uboot_eyang77_ics2.bin  (zip_root)/uboot.bin  
  90. #[eton end]  
  91.   
  92.     (hide)  (hide)  (foreach t,(INSTALLED_RADIOIMAGE_TARGET),\&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;nbsp; 
  93.                 mkdir -p  (INSTALLED_RADIOIMAGE_TARGET),\&amp;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;amp;nbsp; 
  94.                 (ACP)  (ACP)  (t)  (ziproot)/RADIO/ ( z i p r o o t ) / R A D I O / (notdir (t));)  
  95.     @# 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;amp;nbsp;          (call package_files-copy-root, \&amp;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;amp;nbsp;          (call package_files-copy-root, \&amp;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”  
  96.     (hide)  (hide)  (ACP) mediatek/custom/(MTK_PROJECT)/security/recovery/SEC_VER.txt  (MTK_PROJECT)/security/recovery/SEC_VER.txt  (zip_root)/OTA/  
  97.     @# Files that do not end up in any images, but are necessary to  
  98.     @# build them.  
  99.     (hide) mkdir -p  (hide) mkdir -p  (zip_root)/META  
  100.     (hide)  (hide)  (ACP) (APKCERTS_FILE)  (APKCERTS_FILE)  (zip_root)/META/apkcerts.txt  
  101.     (hide) echo " (hide) echo " (PRODUCT_OTA_PUBLIC_KEYS)” > (zip_root)/META/otakeys.txt  
  102.      (zip_root)/META/otakeys.txt       (hide) echo “recovery_api_version=(PRIVATE_RECOVERY_API_VERSION)" >  (PRIVATE_RECOVERY_API_VERSION)" >  (zip_root)/META/misc_info.txt  
  103. ifdef BOARD_FLASH_BLOCK_SIZE  
  104.     (hide) echo "blocksize= (hide) echo "blocksize= (BOARD_FLASH_BLOCK_SIZE)” >> (zip_root)/META/misc_info.txt  
  105. 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  
  106. endif  
  107. ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE  
  108.     (hide) echo "recovery_size= (hide) echo "recovery_size= (BOARD_RECOVERYIMAGE_PARTITION_SIZE)” >> (zip_root)/META/misc_info.txt  
  109. 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  
  110. endif  
  111. ifdef BOARD_SECROIMAGE_PARTITION_SIZE  
  112.     (hide) echo "secro_size= (hide) echo "secro_size= (BOARD_SECROIMAGE_PARTITION_SIZE)” >> (zip_root)/META/misc_info.txt  
  113. 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  
  114. endif  
  115. ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE  
  116.     (hide) echo "userdata_size= (hide) echo "userdata_size= (BOARD_USERDATAIMAGE_PARTITION_SIZE)” >> (zip_root)/META/misc_info.txt  
  117. endif       (zip_root)/META/misc_info.txt  endif       (hide) echo “tool_extensions=(tool_extensions)" >>  (tool_extensions)" >>  (zip_root)/META/misc_info.txt  
  118. ifdef mkyaffs2_extra_flags  
  119.     (hide) echo "mkyaffs2_extra_flags= (hide) echo "mkyaffs2_extra_flags= (mkyaffs2_extra_flags)” >> (zip_root)/META/misc_info.txt  
  120. 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  
  121. endif  
  122.     (hide) echo "default_system_dev_certificate= (hide) echo "default_system_dev_certificate= (DEFAULT_KEY_CERT_PAIR)” >> (zip_root)/META/misc_info.txt  
  123. 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  
  124. endif  
  125.     @# Zip everything up, preserving symlinks  
  126.     (hide) (cd  (hide) (cd  (zip_root) && zip -qry ../(notdir  (notdir  @) .)  
  127.     @# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output  
  128.     (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  
  129.     $(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 := (callintermediatesdirfor,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 := \
    (callintermediatesdirfor,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 \
    (callintermediatesdirfor,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 \
    (callintermediatesdirfor,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)mkdirp ( h i d e ) m k d i r − p (dir @) @ ) (zip_root)
    @# Components of the recovery image
    (hide)mkdirp ( 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)mkdirp ( 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) (callpackagefilescopyroot,  ( 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)zipinfo1 ( 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)zipinfo1 ( 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)/RECOVERYCOPY(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);
    • 创建/

    你可能感兴趣的:(Android源码)