如同User manual提的,讓我們從寫package的description跟license開始,我們寫一個brook_1.0.bb開始
description
DESCRIPTION = "Brook's first application" HOMEPAGE = "http://www.brook.com/oe/" LICENSE = "Brook-Proprietary"基本上這些參數都只是描述,也就是字串,至於LICENSE有公用哪些選項,請參考Recipe License Fields。
define dependency
DEPENDS = "gtk+" RDEPENDS = "cool-ttf-fonts"DEPENDS是build時需要哪個package,RDEPENDS則是執行時需要哪個package,也就是說如果該brook_1.0被加到image,則RDEPENDS所列的也都會被加到image之中。
source location
SRC_URI = "http://127.0.0.1/brook/${P}.tar.bz2" SRC_URI[md5sum] = "6abf52e3f874f67bc4663d0986493970" SRC_URI[sha256sum] = "7aa5130f9648f0948ebaad270a4fe1112e4cc06895580dab85da26baa37fd4f6"SRC_URI是指定檔案所在的位置,可以支援http、ftp、git、svn、file等,詳情可參考SRC_URI variable,SRC_URI[md5sum]與SRC_URI[sha256sum]是去驗證檔案是否正確,可以透過md5sum file_name與sha256sum file_name算出。當中的${P}=${PN}-${PV},${PN}是Package Name,${PV}是Package Version。
build system selection
在開始真正build package之前,我們必須決定這個package使用哪個build system,如果這個package需要先執行configure script然後在make,那麼通常就會選用autotools,更多關於autotools class,其他inherit之後再來討論。到此可以真正開始build brook這個package了,bitbake brook。
完整brook_1.0.bb
DESCRIPTION = "Brook's first application" HOMEPAGE = "http://www.brook.com/oe/" LICENSE = "Brook-Proprietary" LIC_FILES_CHKSUM = "file://COPYING;md5=dcb2a5c2b6d6fea1a0835c08d71ad817" SRC_URI = "http://127.0.0.1/brook/${P}.tar.bz2" SRC_URI[md5sum] = "6abf52e3f874f67bc4663d0986493970" SRC_URI[sha256sum] = "7aa5130f9648f0948ebaad270a4fe1112e4cc06895580dab85da26baa37fd4f6" inherit autotools
Example of Source Code
brook-1.0/Makefileall: brook brook: main.o ${CC} $? -o $@ install: install -d -m 755 ${DESTDIR}/bin install -m 755 brook ${DESTDIR}/bin
brook-1.0/main.c
#include <stdio.h> int main(int argc, char *argv[]) { printf("Hello world, Brook\n"); return 0; }
LIC_FILES_CHKSUM does not match
如果出現以下錯誤ERROR: brook: Recipe file does not have license file information (LIC_FILES_CHKSUM) ERROR: Licensing Error: LIC_FILES_CHKSUM does not match, please fix可以在bb file中加入
LIC_FILES_CHKSUM = "file://COPYING;md5=dcb2a5c2b6d6fea1a0835c08d71ad817"
其中COPYING就是LICENSE檔案位置,我是指到source file解開後的COPYING檔案位置與其對應的md5sum。