2015年2月27日 星期五

OpenEmbedded User Manual - CH3, Writing Meta Data (Adding packages)


如同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/Makefile
all: 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;
}


    參考資料:
  1. OpenEmbedded User Manual
  2. OpenEmbedded - Style Guide
  3. OpenEmbedded - Recipe License Fields


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。


6 則留言:

  1. wrap origin task,
    do_compile() {
    do_something_you_want
    oe_runmake
    }

    do_install() {
    do_something_you_want
    oe_runmake install
    }

    回覆刪除
  2. Basic Logging Tutorial, https://docs.python.org/3/howto/logging.html
    example,

    import logging

    # create logger
    logger = logging.getLogger('simple_example')
    logger.setLevel(logging.DEBUG)
    # 'application' code
    logger.debug('debug message')
    logger.info('info message')
    logger.warn('warn message')
    logger.error('error message')
    logger.critical('critical message')

    回覆刪除
  3. porting 某些package時會出現"automatic de-ANSI-fication support has been removed"是因為automake1.12之後,就不在支援該功能了
    修改Makefile.am
    --- a/Makefile.am
    +++ b/Makefile.am
    @@ -20,7 +20,7 @@
    # MA 02111-1307, USA.
    -AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr
    +AUTOMAKE_OPTIONS = gnu no-dependencies

    修改configure.in
    --- a/configure.in
    +++ b/configure.in
    @@ -1501,7 +1501,9 @@ echo " MPN_PATH=\"$path\""
    # Automake ansi2knr support.
    -AM_C_PROTOTYPES
    +AC_C_PROTOTYPES
    +AC_HEADER_STDC
    +AC_CHECK_HEADERS("string.h")

    https://autotools.io/forwardporting/automake.html

    回覆刪除
  4. https://lists.yoctoproject.org/pipermail/yocto/2013-November/017434.html
    [yocto] How to use pre-built external Yocto toolchain
    We don't support this; if you're going to use our toolchain it's expected that
    you let the build system take care of building it. If what you want is to
    accelerate repeat builds or builds of the same source on different machines,
    the solution for that is to use shared state (using SSTATE_MIRRORS to share
    between different build machines, if needed).

    回覆刪除
  5. https://stackoverflow.com/questions/30802811/bitbake-runtime-vs-build-dependency?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

    As you say, bitbake is concerned with building and deploying the packages, and it needs to deploy all the packages that are needed to satisfy runtime dependencies on the target system.

    If your recipe says that target T DEPENDS on a target P, that tells bitbake that it must build P before T, because T can't be built without P.

    If your recipe says that T RDEPENDS on P, that tells bitbake that it must deploy P to the target system if it deploys T, because T can't be used without P.

    For example, you can't build tar without the C compiler, but you don't need the C compiler to use tar. You can deploy tar without deploying the C compiler. So that's a DEPEND.

    On the other hand, you can't use tar without the runtime C library. If tar is deployed, the runtime C library must also be deployed. So that's an RDEPEND.

    The bitake technicalities are:

    If T DEPENDS on P then T's do_configure task is made to depend on P's do_populate_sysroot task.

    If T RDEPENDS on P then T's do_build task ia made to depend on P's do_package_write task.

    回覆刪除
  6. brook@vista:/home/brook/poky/build$ bitbake -vvv iperf
    NOTE: Reconnecting to bitbake server...
    NOTE: Retrying server connection... (Traceback (most recent call last):
    File "/home/brook/poky/bitbake/lib/bb/main.py", line 464, in setup_bitbake
    server_connection = bb.server.process.connectProcessServer(sockname, featureset)
    File "/home/brook/poky/bitbake/lib/bb/server/process.py", line 497, in connectProcessServer
    sock.connect(os.path.basename(sockname))
    BlockingIOError: [Errno 11] Resource temporarily unavailable
    )

    try to rm poky/build/bitbake.sock and poky/build/bitbake.lock

    回覆刪除

熱門文章