yocto 打包外部应用到 system.img
项目中难免需要将第三方编译完成的库或者应用打包到系统中使用,这里记录yocto中以shell 命令追加的方法:
- 添加bbclass文件
在项目源码中找到打包system.img的bbclass(类似于create-system-image,bbclass),在同级目录中添加add_test.bbclass
vim add_test.class 添加类似于如下内容:add_test () { mkdir ${IMAGE_ROOTFS}/usr/bin/test/ cp -rf xxx ${IMAGE_ROOTFS}/usr/bin/test/ } ROOTFS_POSTINSTALL_COMMAND += "add_test;"
- 在local.conf中引用他
在源码目录中找到conf文件,类似于local.conf.sample:USER_CLASSES ?= "buildstats xxx add_test"
- source环境,并打包rootfs
source setup
bitbake xxx-image -c rootfs
一般可以在rootfs中看到添加的内容,打包image后存在我们依赖项