본문 바로가기

Build/Yocto

05. Recipe

 
BitBake는 python과 shell script로 만들어진 task scheduler로써, 
 
build하고자 하는 source를 download하고, 
 
build한 후, 최종 install하기 까지의 전 과정을 담당한다. 
 
한편 Recipe는 bitbake가 실제 build 절차를 수행하기 위해 참조하는 metadata를 일컫는다. 
 
굳이 비유를 하자면, bitbake는 요리사쯤 되겠고, recipe는 글자 그대로 요리에 사용하는 레시피가 되겠다.
 
 

Metadata
 
일차적으로 BitBake는 recipe를 포함하여 아래와 같은 내용의 metadata를 처리하게 된다.
 
recipes
 
확장자가 bb 나 bbappend 로 끝남. 
bb 의 경우 source code build 관련 모든 정보를 담고 있음.
bbappend 의 경우 recipe의 내용을 확장(override or extend)하는 역할 수행
 
include
 
확장자가 .inc로 끝남. 다른 recipe에서 incude(or require) 시켜 사용하는 공통내용을 담고 있음.
 
classes
 
확장자가 .bbclass로 끝남. common build information(공통 정보를 class로 만듦)을 담고 있음. 
다른 recipe에서 상속 받아 사용함(inherit keyword를 사용함).
 
configuration
 
확장자가 .conf로 끝남. build 수행시 필요한 다양한 환경 변수를 담고 있음.
 
 

Task
 
Metadata를 읽은 BitBake가 다음으로 하게 되는 일은 
 
python & shell code로 구성된 task를 실행하는 것이라고 말할 수 있다.
 
주로 아래와 같은 Task 가 많이 사용된다.
 
 
do_fetch : source code를 가져온다(download)
 
do_unpack : source code의 압축을 푼다(tar.gz, zip, xz, tar ..)
 
do_patch : source code에 적용할 patch가 있다면 이를 적용한다.
 
do_configure : source code에 configure script가 있을 경우 이를 수행한다.
 
do_compile : compile을 진행한다.
 
do_install : build 결과물을 rootfs에 포함시킨다.
 
do_package : 패키지를 만든다.
 
do_rootfs : rootfs 이미지를 생성한다.
 
 

Bitbake
 
bitbake를 이용하면 전체 image를 생성해 낼 수 있다. 
 
뿐만 아니라 각각의 개별 package(정확히는 recipe)를 build 하는 것도 당연히 가능하다. 
 
작성한 recipe 상의 bb 파일에 do_comile 함수가 있으면 
 
-c compile 이라고 명령을 내려서 컴파일만 수행할 수 있고
 
그냥 -c recipeName 을 입력하면 있는 함수는 순서대로 수행하게 된다.
 
# Bitbake 사용법 요약
$ bitbake <recipe>
   => 예) $ bitbake helloworld
   => 예) $ bitbake -c listtasks core-image-minimal
$ bitbake  -c <task> <recipe>
   => 예) $ bitbake -c fetch busybox
   => 예) $ bitbake -c compile busybox
 
# Bitbake Help
bitbake --help
 
Usage: bitbake [options] [recipename/target recipe:do_task ...]
 
    Executes the specified task (default is 'build') for a given set of target recipes (.bb files).
    It is assumed there is a conf/bblayers.conf available in cwd or in BBPATH which
    will provide the layer, BBFILES and other configuration information.
 
Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -b BUILDFILE, --buildfile=BUILDFILE
                        Execute tasks from a specific .bb recipe directly.
                        WARNING: Does not handle any dependencies from other
                        recipes.
  -k, --continue        Continue as much as possible after an error. While the
                        target that failed and anything depending on it cannot
                        be built, as much as possible will be built before
                        stopping.
  -a, --tryaltconfigs   Continue with builds by trying to use alternative
                        providers where possible.
  -f, --force           Force the specified targets/task to run (invalidating
                        any existing stamp file).
  -c CMD, --cmd=CMD     Specify the task to execute. The exact options
                        available depend on the metadata. Some examples might
                        be 'compile' or 'populate_sysroot' or 'listtasks' may
                        give a list of the tasks available.
  -C INVALIDATE_STAMP, --clear-stamp=INVALIDATE_STAMP
                        Invalidate the stamp for the specified task such as
                        'compile' and then run the default task for the
                        specified target(s).
  -r PREFILE, --read=PREFILE
                        Read the specified file before bitbake.conf.
  -R POSTFILE, --postread=POSTFILE
                        Read the specified file after bitbake.conf.
  -v, --verbose         Output more log message data to the terminal.
  -D, --debug           Increase the debug level. You can specify this more
                        than once.
  -q, --quiet           Output less log message data to the terminal.
  -n, --dry-run         Don't execute, just go through the motions.
  -S SIGNATURE_HANDLER, --dump-signatures=SIGNATURE_HANDLER
                        Dump out the signature construction information, with
                        no task execution. The SIGNATURE_HANDLER parameter is
                        passed to the handler. Two common values are none and
                        printdiff but the handler may define more/less. none
                        means only dump the signature, printdiff means compare
                        the dumped signature with the cached one.
  -p, --parse-only      Quit after parsing the BB recipes.
  -s, --show-versions   Show current and preferred versions of all recipes.
  -e, --environment     Show the global or per-recipe environment complete
                        with information about where variables were
                        set/changed.
  -g, --graphviz        Save dependency tree information for the specified
                        targets in the dot syntax.
  -I EXTRA_ASSUME_PROVIDED, --ignore-deps=EXTRA_ASSUME_PROVIDED
                        Assume these dependencies don't exist and are already
                        provided (equivalent to ASSUME_PROVIDED). Useful to
                        make dependency graphs more appealing
  -l DEBUG_DOMAINS, --log-domains=DEBUG_DOMAINS
                        Show debug logging for the specified logging domains
  -P, --profile         Profile the command and save reports.
  -u UI, --ui=UI        The user interface to use (depexp, knotty or ncurses -
                        default knotty).
  -t SERVERTYPE, --servertype=SERVERTYPE
                        Choose which server type to use (process or xmlrpc -
                        default process).
  --token=XMLRPCTOKEN   Specify the connection token to be used when
                        connecting to a remote server.
  --revisions-changed   Set the exit code depending on whether upstream
                        floating revisions have changed or not.
  --server-only         Run bitbake without a UI, only starting a server
                        (cooker) process.
  --foreground          Run bitbake server in foreground.
  -B BIND, --bind=BIND  The name/address for the bitbake server to bind to.
  -T IDLE_TIMEOUT, --idle-timeout=IDLE_TIMEOUT
                        Set timeout to unload bitbake server due to inactivity
  --no-setscene         Do not run any setscene tasks. sstate will be ignored
                        and everything needed, built.
  --setscene-only       Only run setscene tasks, don't run any real tasks.
  --remote-server=REMOTE_SERVER
                        Connect to the specified server.
  -m, --kill-server     Terminate the remote server.
  --observe-only        Connect to a server as an observing-only client.
  --status-only         Check the status of the remote bitbake server.
  -w WRITEEVENTLOG, --write-log=WRITEEVENTLOG
                        Writes the event log of the build to a bitbake event
                        json file. Use '' (empty string) to assign the name
                        automatically.
 
 

Recipe Runtime Variable
 
PN
    package name(recipe file 명으로 부터 추출)
 
PR
   package revision
 
PV
   package version
 
S
    bitbake가 package를 풀어서 두는 곳(source가 위치하는 곳)
    $ bitbake -e hello | grep ^S=
    S="/home/chyi/Atmel/yocto_rootfs/poky/build-atmel/tmp/work/cortexa5hf-vfp-poky-linux-gnueabi/hello/0.1-r0"
 
D
    생성 task가 output 파일을 가져다 놓는 디렉토리 full path(쉽게 말해 destination directory)
    $ bitbake -e hello | grep ^D=
     D="/home/chyi/Atmel/yocto_rootfs/poky/build-atmel/tmp/work/cortexa5hf-vfp-poky-linux-gnueabi/hello/0.1-r0/image"
 
bindir
   /usr/bin, 단독으로 사용하는 것이 아니라, D 디렉토리에 연이어 붙여 사용한다
 
sbindir
   /usr/sbin
 
libdir
   /usr/lib
 
libexecdir
   /usr/lib
 
sysconfdir
   /etc
 
datadir
   /usr/share
 
mandir 
   /usr/share/man
 
includedir
   /usr/include
 
 

Sample Recipe
 
 
 

Source
 
# Metadata 추가 방법
 
$  cd poky/
$  gedit ~/poky/build/conf/bblayers.conf
  /home/sheen/poky/meta-packt_rpi \
$  source oe-init-build-env
$ bitbake -C compile gpio-packt # 컴파일만 실행
$ bitbake -C compile example-packt # 컴파일만 실행
$ bitbake -C compile raspberry-packt-image # 인스톨
 
raspberry-packt-image 의 내용
# IMAGE_INSTALL 에 recipe 를 추가하면 do_install 이 실행된다.
 
# Base this image on core-image-minimal
include recipes-core/images/core-image-minimal.bb
 
DESCRIPTION = "Image for raspberry-pi"
 
IMAGE_FEATURES += "ssh-server-dropbear splash"
 
# Include modules in rootfs
IMAGE_INSTALL += " \
    kernel-modules \
    gpio-packt    \
    example-packet \   example-packt
    "
 
 
 
 

'Build > Yocto' 카테고리의 다른 글

04. Layer 추가  (1) 2020.01.23
03. 빌드 설정  (0) 2020.01.23
02. 빌드  (0) 2020.01.23
01. 구성  (2) 2020.01.23