android related image generation
android related image generation
调用build_image.py的cmd如下,system.img、userdata.img、cache.img、vendor.img都是调用这个cmd去生成image的
./build/tools/releasetools/build_image.py $TARGET_OUT $IMAGE_INFO $PRODUCT_OUT/$PARTITION_NAME.img $PRODUCT_OUT/system
比如为system.img时,$IMAGE_INFO为$PRODUCT_OUT/obj/PACKAGING/systemimage_intermediates/system_image_info.txt,这个文件里的内容如下:
system_reserved_size=52428800 system_selinux_fc=out/target/product/device/obj/ETC/file_contexts.bin_intermediates/file_contexts.bin ext_mkuserimg=mkuserimg_mke2fs fs_type=ext4 extfs_sparse_flag=-s squashfs_sparse_flag=-s f2fs_sparse_flag=-S avb_avbtool=avbtool avb_system_hashtree_enable=true avb_system_add_hashtree_footer_args=--prop com.android.build.system.fingerprint:customer/device_an64/device:11/RP1A.200720.011/$date:userdebug/test-keys --prop com.android.build.system.os_version:11 --prop com.android.build.system.security_patch:2022-04-05 root_dir=out/target/product/device/root use_dynamic_partition_size=true skip_fsck=true
对于userdata.img,userdata_image_info.txt里的内容如下:
userdata_fs_type=f2fs userdata_size=1073741824 needs_casefold=1 needs_projid=1 userdata_selinux_fc=out/target/product/device/obj/ETC/file_contexts.bin_intermediates/file_contexts.bin ext_mkuserimg=mkuserimg_mke2fs fs_type=ext4 extfs_sparse_flag=-s squashfs_sparse_flag=-s f2fs_sparse_flag=-S avb_avbtool=avbtool avb_system_hashtree_enable=true avb_system_add_hashtree_footer_args=--prop com.android.build.system.fingerprint:customer/device_an64/device:11/RP1A.200720.011/$date:userdebug/test-keys --prop com.android.build.system.os_version:11 --prop com.android.build.system.security_patch:2022-04-05 root_dir=out/target/product/device/root use_dynamic_partition_size=true skip_fsck=true
build/make/tools/releasetools/build_image.py
def main(argv): 763 if len(argv) != 4: 764 print(__doc__) 765 sys.exit(1) 766 767 common.InitLogging() 768 769 in_dir = argv[0] 770 glob_dict_file = argv[1] 771 out_file = argv[2] 772 target_out = argv[3] 773 774 glob_dict = LoadGlobalDict(glob_dict_file) 775 if "mount_point" in glob_dict: 776 # The caller knows the mount point and provides a dictionary needed by 777 # BuildImage(). 778 image_properties = glob_dict 779 else: 780 image_filename = os.path.basename(out_file) 781 mount_point = "" 782 if image_filename == "system.img": 783 mount_point = "system" 784 elif image_filename == "system_other.img": 785 mount_point = "system_other" 786 elif image_filename == "userdata.img": 787 mount_point = "data" 788 elif image_filename == "cache.img": 789 mount_point = "cache" 790 elif image_filename == "vendor.img": 791 mount_point = "vendor" 792 elif image_filename == "odm.img": 793 mount_point = "odm" 794 elif image_filename == "oem.img": 795 mount_point = "oem" 796 elif image_filename == "product.img": 797 mount_point = "product" 798 elif image_filename == "system_ext.img": 799 mount_point = "system_ext" 800 else: 801 logger.error("Unknown image file name %s", image_filename) 802 sys.exit(1) 803 804 image_properties = ImagePropFromGlobalDict(glob_dict, mount_point) 805 806 try: 807 BuildImage(in_dir, image_properties, out_file, target_out)
上面BuildImage函数将解析image_properties prop_dict(由$IMAGE_INFO文件而来)去调用生成对应文件系统的cmd去生成image,如果这个image是有开AVB的,比如hashtree,则会调用avbtool add_hashtree_footer去生成hashtree、vbmeta、footer并依次将它们append到out_file($PRODUCT_OUT/$PARTITION_NAME.img)
注:ImagePropFromGlobalDict(glob_dict, mount_point)里会设置image_properties里的partition_name为mount_point,比如设置为"system"
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
2021-05-15 Power Off Notification (PON) SHORT & LONG ---the difference
2021-05-15 really_probe()