Yocto中一個軟件包是放在bb文件里的,然后非常多的bb文件集成一個recipe(配方),然后很多的recipe又組成一個meta layer。因此,要加入一個包事實上就是在recipe以下加入一個bb(bitbake配置文件)。以下使用helloworld作為一個樣例。
clone bb文件
首先是進入到一個recipe文件夾下,比如以下就是到了recipes-graphics:
$ pwd /media/work/iMX6/Yocto/sources/meta-fsl-arm/recipes-graphics
然后clone Package配置與source文件夾的repo:
git clone https://github.com/tonyho/helloYocto.git
查看軟件包是否已經在Yocto中
09:25 hexiongjun:imx6qsabresd_build $ bitbake -s | grep hello hello :3-r0
確認在了以后,就能夠運行編譯等task了,假設有須要也能夠deploy到rootfs中。這些操作能夠參考我曾經的一些博客。
一個軟件包的結構
使用tree能夠看到,其有一個bb文件,然后當中另一個文件夾放着Makefile與source code:
當中的bb文件內容例如以下:
DESCRIPTION = "Hello World and Zlib test" DEPENDS = "zlib" SECTION = "libs" LICENSE = "MIT" PV = "3" PR = "r0" SRC_URI = " \ file://helloYocto.c \ file://zlibtest.c \ file://makefile \ " LIC_FILES_CHKSUM = "file://helloYocto.c;md5=2dac018fa193620dc085aa1402e0b346" S = "${WORKDIR}" do_compile () { make } do_install () { install -d ${D}${bindir}/ install -m 0755 ${S}/helloYocto ${D}${bindir}/ install -m 0755 ${S}/zlibtest ${D}${bindir}/ } FILES_${PN} = "${bindir}/helloYocto \ ${bindir}/zlibtest "
能夠看到。bb文件里指定了以下幾個變量的值:
- SRC_URI
- LIC_FILES_CHKSUM:這個是checksum,假設是基於版本號管理的source,那么不須要,比如git與svn
- FILES_$(PN):PN是Package number,指代軟件版本號使用的PV與PR結合表示,即前面bitbake -s中看到的3-r0
還有兩個方法,這2個方法重載了bitbake中默認方法:
- do_compile
- do_install
這兩個方法。相應了Package中的compile與install task。