首页 > 其他分享 >OPTIONS.info_dict的tool_extensions取值过程分析

OPTIONS.info_dict的tool_extensions取值过程分析

时间:2023-09-06 14:05:00浏览次数:36  
标签:info files target tool xxx extensions device


1 首先在build/core/envsetup.mk中有:


board_config_mk := \          


                      $(strip $(wildcard \          


                      $(SRC_TARGET_DIR)           /board/           $(TARGET_DEVICE)           /BoardConfig           .mk \          


                      $(shell            test            -d device &&            find            device -maxdepth 4 -path            '*/$(TARGET_DEVICE)/BoardConfig.mk'           ) \          


                      $(shell            test            -d vendor &&            find            vendor -maxdepth 4 -path            '*/$(TARGET_DEVICE)/BoardConfig.mk'           ) \          


                      ))


SRC_TARGET_DIR值为$(TOPDIR)build/target,TARGET_DEVICE取值xxx(机型名)


在build/target/xxx 和device、vendor等目录的xxx子目录下查找所有的BoardConfig.mk文件,而且device和vendor下必须符合xxx/BoardConfig.mk的形式,

xxx,只在****/xxx/下存在名为xxx的子目录,因此最终board_config_mk就代表这个文件

对board_config_mk取值的错误情况做出判断后,然后直接通过 include $(board_config_mk)将这个BoardConfig.mk文件include进来,假设这个文件中定义了xxx

 

2  根据在 ota升级包编译过程中firmware如何添加进来 中的分析可知,BUILT_TARGET_FILES_PACKAGE是编译target-file.zip的目标

在build/core/Makefile中有


ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)          


           # default to common dir for device vendor          


           $(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/..           /common          


           else          


           $(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)          


           endif


 因此编译target-file.zip的过程中,如果之前在BoardConfig.mk中定义了TARGET_RELEASETOOLS_EXTENSIONS为device/****/xxx,那么tool_extensions就取值device/****/xxx,如果之前没有定义TARGET_RELEASETOOLS_EXTENSIONS,那么这个值就是device/****/xxx/../common

 

3  在build/core/Makefile接下来,在构建target BUILT_TARGET_FILES_PACKAGE下面要执行的命令行中,还有:


build/core/Makefile

$(hide)            echo            "tool_extensions=$(tool_extensions)"            >> $(zip_root)           /META/misc_info           .txt


根据在 ota升级包编译过程中firmware如何添加进来 中的分析,zip_root就是用来产生target-files.zip的中间文件夹,在这里取值就是out/target/product/xxx/obj/PACKAGING/target_files_intermediates/xxx-target_files-eng.username

username/META/misc_info.txt中输入了 tool_extensions=$(tool_extensions)这一行,$(tool_extensions)代表tool_extensions的值

 

4 在之后执行build/tools/releasetools/ota_from_target_files.py时,在main中有:


build/tools/releasetools/ota_from_target_files.py

OPTIONS.input_tmp, input_zip            =            common.UnzipTemp(args[           0           ])          


           OPTIONS.target_tmp            =            OPTIONS.input_tmp          


           OPTIONS.info_dict            =            common.LoadInfoDict(input_zip)


根据在 ota升级包编译过程中firmware如何添加进来 中的分析,input_zip代表用zipfile.ZipFile打开的target-files.zip文件。

这里调用同目录下common.py中的LoadInfoDict,按行加载misc_info.txt中保存的元数据


build/tools/releasetools/common.py

def            LoadInfoDict(input_file):          


                      """Read and parse the META/misc_info.txt key/value pairs from the          


                      input target files and return a dict."""          


                      def            read_helper(fn):          


                      if            isinstance           (input_file, zipfile.ZipFile):          


                      return            input_file.read(fn)          


                      else           :          


                      path            =            os.path.join(input_file,            *           fn.split(           "/"           ))          


                      try           :          


                      with            open           (path) as f:          


                      return            f.read()          


                      except            IOError as e:          


                      if            e.errno            =           =            errno.ENOENT:          


                      raise            KeyError(fn)          


                      d            =            {}          


                      try           :          


                      d            =            LoadDictionaryFromLines(read_helper(           "META/misc_info.txt"           ).split(           "\n"           ))          


                      except            KeyError:          


                      # ok if misc_info.txt doesn't exist          


                      pass          


                      # backwards compatibility: These values used to be in their own          


                      # files.  Look for them, in case we're processing an old          


                      # target_files zip.          


                      if            "mkyaffs2_extra_flags"            not            in            d:          


                      try           :          


                      d[           "mkyaffs2_extra_flags"           ]            =            read_helper(          


                      "META/mkyaffs2-extra-flags.txt"           ).strip()          


                      except            KeyError:          


                      # ok if flags don't exist          


                      pass          


                      if            "recovery_api_version"            not            in            d:          


                      try           :          


                      d[           "recovery_api_version"           ]            =            read_helper(          


                      "META/recovery-api-version.txt"           ).strip()          


                      except            KeyError:          


                      raise            ValueError(           "can't find recovery API version in input target-files"           )          


                      if            "tool_extensions"            not            in            d:          


                      try           :          


                      d[           "tool_extensions"           ]            =            read_helper(           "META/tool-extensions.txt"           ).strip()          


                      except            KeyError:          


                      # ok if extensions don't exist          


                      pass          


                      if            "fstab_version"            not            in            d:          


                      d[           "fstab_version"           ]            =            "1"          


                      try           :          


                      data            =            read_helper(           "META/imagesizes.txt"           )          


                      for            line            in            data.split(           "\n"           ):          


                      if            not            line:          


                      continue          


                      name, value            =            line.split(           " "           ,            1           )          


                      if            not            value:          


                      continue          


                      if            name            =           =            "blocksize"           :          


                      d[name]            =            value          


                      else           :          


                      d[name            +            "_size"           ]            =            value          


                      except            KeyError:          


                      pass          


                      def            makeint(key):          


                      if            key            in            d:          


                      d[key]            =            int           (d[key],            0           )          


                      makeint(           "recovery_api_version"           )          


                      makeint(           "blocksize"           )          


                      makeint(           "system_size"           )          


                      makeint(           "vendor_size"           )          


                      makeint(           "userdata_size"           )          


                      makeint(           "cache_size"           )          


                      makeint(           "recovery_size"           )          


                      makeint(           "boot_size"           )          


                      makeint(           "fstab_version"           )          


                      d[           "fstab"           ]            =            LoadRecoveryFSTab(read_helper, d[           "fstab_version"           ])          


                      d[           "build.prop"           ]            =            LoadBuildProp(read_helper)          


                      return            d


在LoadInfoDict中建立字典d,read_helper("META/misc_info.txt")会读取target-files.zip的META下的misc_info.txt,然后在LoadDictionaryFromLines中按key/value对的形式逐行解析读取到的内容,因此在这里就可以获得d["tool_extensions"] = device/****/xxx 或者 device/****/xxx/../common

如果misc_info.txt中读取tool_extensions失败,接下来还会尝试从META/tool-extensions.txt中读取。最后返回ota_from_target_files.py的main,将字典d传给OPTIONS.info_dict

 

5  在ota_from_target_files.py的main中,接下来有:


build/tools/releasetools/ota_from_target_files.py

if            OPTIONS.device_specific            is            None           :          


                      from_input            =            os.path.join(OPTIONS.input_tmp,            "META"           ,            "releasetools.py"           )          


                      if            os.path.exists(from_input):          


                      print            "(using device-specific extensions from target_files)"          


                      print            "releasetools.py exists"          


                      print           (from_input)          


                      OPTIONS.device_specific            =            from_input          


                      else           :          


                      print            "releasetools.py don't exists"          


                      # device/qcom/common          


                      OPTIONS.device_specific            =            OPTIONS.info_dict.get(           "tool_extensions"           ,            None           )          


           if            OPTIONS.device_specific            is            not            None           :          


                      OPTIONS.device_specific            =            os.path.abspath(OPTIONS.device_specific)


这里首先从产生target-files.zip的中间文件夹是out/target/product/xxx/obj/PACKAGING/target_files_intermediates/xxx-target_files-eng.username/META下读取releasetools.py,如果这个文件不存在,就从上一部获得的字典 OPTIONS.info_dict中查找tool_extensions这个键的值,最终赋值给OPTIONS.device_specific。

标签:info,files,target,tool,xxx,extensions,device
From: https://blog.51cto.com/u_16248677/7386438

相关文章

  • Android官方资料--OTA Package Tools
    OTAPackageToolsINTHISDOCUMENTFullupdatesIncrementalupdatesUpdatepackagesThe ota_from_target_files toolprovidedinbuild/tools/releasetools canbuildtwotypesofpackage: full andincremental.Thetooltakesthe target-files .zipfileproduc......
  • 关于你的nastool为什么有些人刮削不成功,怎么解决?
    各位亲,感谢你惠顾本小店nastool为什么有些人刮削不成功,原因归纳起来有两大类:你的原因他的原因你的原因:你的网络情况不好。连通性有问题。正常情况下是这样的测试结果。你设置nastool,设置问题你的视频名称有问题,与资料库的名字相差过大他的原因影片是你自导自演......
  • Node.js 使用 officecrypto-tool 读取加密的 Excel 和 Word 文档, 支持 xlsx 和 docx
    Node.js使用officecrypto-tool读取加密的Excel(xls,xlsx)和Word(docx)文档,还支持xlsx和docx文件的加密(具体使用看文档)。暂时不支持doc文件的解密传送门:officecrypto-tool读取加密的Excel示例一:xlsx-populate//只支持xlsx,xlsx-populate自带了解密功能......
  • Metinfo6.0.0任意文件读取漏洞复现
    1.1、漏洞描述漏洞名称:MetInfo任意文件读取漏洞简介:MetInfo是一套使用PHP和MySQL开发的内容管理系统,其中的/app/system/include/module/old_thumb.class.php文件存在任意文件读取漏洞,攻击者可利用该漏洞读取网站的敏感文件。下载地址:历史版本安装文件下载Ver_6.0.01.2、漏洞......
  • Metinfo5.0.4-任意文件包含漏洞复现
    目录文件包含漏洞描述:漏洞等级影响版本漏洞利用蚁剑连接图片马读取敏感目录读取php源码登录管理员界面http://127.0.0.1/MetInfo5.0.4/admin/上传一句话木马,或者图片马制作图片木马copy1.jpg/b+1.php/a2.jpg文件包含首页漏洞描述:MetInfo是一个专业的企业级CMS建......
  • Node.js 使用 officecrypto-tool 读取加密的 Excel (xls, xlsx) 和 Word( docx)文档
    Node.js使用officecrypto-tool读取加密的Excel(xls,xlsx)和Word(docx)文档,还支持xlsx和docx文件的加密(具体使用看文档)。暂时不支持doc文件的解密传送门:officecrypto-tool读取加密的Excel示例一:xlsx-populate//只支持xlsx,xlsx-populate自带了解密功能,/......
  • 笔记 | element table show-overflow-tooltip 位置偏移的问题
    一、问题因为我目前的项目是微前端的工程,最外层有一个50px的通用头部,所以页面要减去50px。所有页面看似都很完美,但是使用el-table-column的show-overflow-tooltip属性时,tooltip会向下偏移50px。想到的解决办法:按照el-tooltip的属性更改placement="right"能解决。但......
  • 【ToolChains】CLion(VS2019) + CMake + Vcpkg 的使用
    参考博客:https://blog.51cto.com/u_15075510/4201238http://t.csdn.cn/pADDUhttps://zhuanlan.zhihu.com/p/454233496https://blog.csdn.net/weixin_43803955/article/details/123544106Vcpkg概述Vcpkg是微软社区开发的一个跨平台的C++包管理工具。它旨在解决C++......
  • 安装VMwareTools
    2.1、挂载VMwareTools镜像2.2、安装VMwareTools1、安装[root@centos7~]#mkdir/mnt/cdrom/[root@centos7~]#ls/mnt/cdrom/[root@centos7~]#mount-tauto/dev/cdrom/mnt/cdrom/mount:/dev/sr0写保护,将以只读方式挂载[root@centos7~]#cd/mnt/cdrom/[root@centos7cdro......
  • cefsharp - WinForms 和 Wpf 示例之间的巨大性能差异
    https://www.coder.work/article/7217456我注意到在使用 http://www.vsynctester.com 时CefSharp.WinForms.Example和CefSharp.Wpf.Example之间存在非常重要的性能差异(以FPS计)在我的显卡控制面板和CefExampleInit()中的设置中关闭VSync时settings.CefCommandLi......