• 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"

  • 相关阅读:
    bootstrap按钮
    bootstrap输入框组
    bootstrap单选
    bootstrap复选框
    bootstrap输入框
    bootstrap浮动
    HO引擎近况20201017
    C#.NET项目中引用EXCEL报错的问题
    MATLAB实例:读取Fashion MNIST数据,保存为.mat文件,并展示部分样例
    MATLAB实例:BP神经网络用于回归任务
  • 原文地址:https://www.cnblogs.com/aspirs/p/16275050.html
Copyright © 2020-2023  润新知