ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

yocto: 22-Packagegroup

yocto: 22-Packagegroup 第12课Packagegroup — 学会用packagegroup-myproduct 管理摘要本课详细介绍了Yocto项目中Packagegroup的概念与使用方法。Packagegroup是一种管理软件包集合的机制用于将产品所需的所有软件包组织在一起使Image Recipe只需引用一个Packagegroup即可安装所有必要软件。文章通过对比传统直接在Image Recipe中列出所有软件包的繁琐方式展示了使用Packagegroup的优势提高可维护性、分离关注点Image定义系统形态Packagegroup定义软件组成。教程内容包括Packagegroup的定义与作用、创建目录结构、编写Packagegroup Recipe、修改Image Recipe以使用Packagegroup、验证Packagegroup是否生效的方法以及推荐的产品组织结构。最后文章总结了Yocto产品开发的完整知识体系。结果# myproduct-image.bbSUMMARYMy Product ImageLICENSEMITinherit core-image IMAGE_FEATURESssh-server-opensshIMAGE_INSTALL \ packagegroup-myproduct # myproduct-image.bbappend空的# packagegroup-myproductSUMMARYMy Product Package GroupLICENSEMITinherit packagegroup RDEPENDS:${PN} \ hello-script \ product-test \ hello-yocto \ execute-c \ network-config \ hello-systemd \ mypackage \ hello-driver \ 整个产品的软件组成。这一课非常重要。前面我们一直是这样安装软件IMAGE_INSTALL \ hello-script \ product-test \ hello-driver \ 开始只有2~3个package看起来没问题。但是真正的产品通常会有-ssh- network - wifi - bluetooth - app - driver - factory tool - debug tool - upgrade tool - web server - database - logger - watchdog -...最后可能几十甚至上百个package。如果全部写在Image Recipe里面会变成IMAGE_INSTALL \ package1 \ package2 \ package3 \ package4 \ package5 \ package6 \ package7 \ package8 \ ... 几个月以后没人敢改。所以Yocto官方推荐Image负责系统长什么样Packagegroup负责安装哪些软件。本课目标学会建立packagegroup-myproduct以后Image只安装一个PackagegroupIMAGE_INSTALLpackagegroup-myproduct整个产品的软件都由Packagegroup管理。这是所有商业Yocto BSP几乎都会采用的方法。一、什么是Packagegroup可以理解成Linux的软件包集合。例如packagegroup-base里面可能包含bashbusybox dropbear net-tools安装packagegroup-base实际上就是安装了四个package。Packagegroup本身没有程序。它只是RDEPENDS例如packagegroup-myproduct里面可以写RDEPENDS:${PN}\ hello-script \ product-test \ hello-driver \ 安装它以后hello-script product-test hello-driver全部进入rootfs。二、建立目录进入自己的layermeta-myproduct/建立recipes-core/ packagegroups/最终meta-myproduct └── recipes-core └── packagegroups └── packagegroup-myproduct.bb三、编写 recipe新建packagegroup-myproduct.bb内容SUMMARYMy Product Package GroupLICENSEMITinherit packagegroup RDEPENDS:${PN} \ hello-script \ product-test \ 只有几行。真正重要的是inherit packagegroup它告诉BitBake这是Packagegroup。四、修改 Image以前IMAGE_INSTALL \ hello-script \ product-test \ 改成IMAGE_INSTALL \ packagegroup-myproduct \ 结束。以后增加软件以前改image现在改packagegroupImage基本不用动。五、以后增加Driver例如以后学到Kernel Module。以前ImageIMAGE_INSTALL \ hello-driver \ 现在不用。只改PackagegroupRDEPENDS:${PN} \ hello-script \ product-test \ hello-driver \ 重新build即可。六、验证Packagegroup是否生效首先查看recipe是否存在bitbake-layers show-recipes|greppackagegroup应该看到packagegroup-myproduct然后查看依赖bitbake-epackagegroup-myproduct|grep^RDEPENDS例如RDEPENDS:packagegroup-myproducthello-script product-test再重新制作imagebitbake myproduct-image查看rootfsfindtmp/work-path*/myproduct-image/*/rootfs/*或者验证包是否进入镜像oe-pkgdata-util list-pkgs|grephello-script以及findtmp/work-path*/myproduct-image/*/rootfs/*-namehello-script如果 hello-script、product-test 等都进入 rootfs说明 packagegroup-myproduct已经正确发挥作用。七、推荐的产品组织结构经过前面几课现在你的 meta-myproduct 建议组织成下面这样meta-myproduct/ ├── conf/ │ └── layer.conf │ ├── recipes-core/ │ ├── images/ │ │ └── myproduct-image.bb │ │ │ ├── packagegroups/ │ │ └── packagegroup-myproduct.bb │ │ │ └── network-config/ │ ├── network-config.bb │ └── files/ │ ├── recipes-test/ │ ├── hello-script/ │ └── product-test/ │ ├── recipes-kernel/ │ └── hello-driver/ │ └── recipes-bsp/这样每种职责都分离- Image定义镜像类型和总体组成。 - Packagegroup定义产品包含哪些软件包。 - 各个 Recipe分别构建应用、脚本、驱动、配置等独立软件。本课完成后你已经掌握了 Yocto 产品开发的核心组织方式至此你已经学习了1.创建 Layer2.编写 Recipe.bb3.do_install4.Systemd/启动服务5.Image Recipe6.RDEPENDS7.Kernel menuconfig8.Device Tree9.SDK10.BSP/Product11.Kernel Module12.Packagegroup产品软件组成管理
返回列表