如何实现新增镜像

1.[ohos_var.gni]添加变量

declare_args() {
    ............
   #soc_platform package dir 
​
  platform_base_dir = "soc_platform"
}

2.【ohos/images/BUILD.gn】中添加需要制作出新镜像的一些参数

group("new_image") {
  deps = []
  if (is_standard_system) {
    deps += [
      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
    ]
  }
  foreach(_platform, target_platform_list) {
    deps += [ ":${_platform}_soc_platform_image" ]
  }
}
#制作镜像的动作
group("make_image"){
        ....
":${_platform}_new_image",   #添加新镜像的内容
}
foreach(_platform, target_platform_list) {
              ......
              new_image      #新增的镜像
}
​

3.ohos/images/build_image.py

_dir_list = [
    ............
     new_image   //新增的镜像
​
]

4.[ohos/images/mkimage/dac.txt]中

new_image,                     00755,      0,          2000,       0
new_image/bin,                 00751,      0,          2000,       0       设置大小
new_image/bin/*,               00755,      0,          2000,       0

5.[ohos/images/mkimage/debug/soc_platform_image_conf.txt]

/new_image          #挂载位置
104857600           #挂载大小
--fs_type=ext4      #格式
--dac_config ../../build/ohos/images/mkimage/dac.txt
--file_context obj/base/security/selinux_adapter/file_contexts.bin

6.ohos/images/mkimage/soc_platform_image_conf.txt

/new_imaage
104857600         
--fs_type=ext4    
--dac_config ../../build/ohos/images/mkimage/dac.txt
--file_context obj/base/security/selinux_adapter/file_contexts.bin

7.[ohos/packages/modules_install.py]

 

def main():
​
             ..........................
    platform_install_base_dir = os.path.join(args.platform_installed_path,
                                           'soc_platform')
    if os.path.exists(platform_install_base_dir):
        shutil.rmtree(platform_install_base_dir)
        print('remove soc_platform dir...')

8.[templates/metadata/gen_module_info.py]

def gen_install_dests(..................,new_image_dir){
​
  ........................
     elif image == 'new_image':
            dest = _gen_install_dest(platform_base_dir, module_install_dir,
                                     relative_install_dir, module_type)
}
 if args.install_images:
  install_dests = gen_install_dests(.....................new_image_dir)

9.[templates/metadata/module_info.gni]

action(target_name) {
    args = [ 
    .............
     "--platform-base-dir",
      platform_base_dir,
      
      ]

 

 

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐