はじめに
前前回 Scarthgapのリリースに伴うbitbake-layers
の新機能を紹介した。この機能がかなり強力なので具体的な例を示してみる。
今回紹介する機能
Scarthgapで追加された下記のサブコマンドについて紹介する。
- save-build-conf
save-build-conf
このコマンドを実行すると、現在のlocal.confやbblayers.confからtemplateconfを生成し、指定のレイヤに保存する。
setup-buildスクリプト
create-layers-setup
で作成したserup-layersスクリプトの実行結果は以下のようになっている。
output/ ├── build │ └── meta-tools-test ├── poky │ ├── LICENSE │ ├── LICENSE.GPL-2.0-only │ ├── LICENSE.MIT │ ├── MAINTAINERS.md │ ├── MEMORIAM │ ├── README.OE-Core.md │ ├── README.hardware.md -> meta-yocto-bsp/README.hardware.md │ ├── README.md -> README.poky.md │ ├── README.poky.md -> meta-poky/README.poky.md │ ├── README.qemu.md │ ├── SECURITY.md │ ├── bitbake │ ├── contrib │ ├── documentation │ ├── meta │ ├── meta-openembedded │ ├── meta-poky │ ├── meta-selftest │ ├── meta-skeleton │ ├── meta-yocto-bsp │ ├── oe-init-build-env │ └── scripts └── setup-build -> poky/scripts/oe-setup-build
この環境を使用してbitbakeを実行するにはsetup-build
スクリプトを実行する。
すると下記のようにコンフィグレーションを選択するようにメニューとプロンプトが表示される。
今回はpoky-default
しかないのでこれを選択する。
t$ ./setup-build Available build configurations: 1. poky-default This is the default build configuration for the Poky reference distribution. Re-run with 'list -v' to see additional information. Please choose a configuration by its number: 1
プロンプトを抜けるとoe-init-build-env
が実行された状態になる。
このときのビルドディレクトリはbuild-poky-default
となっている。
ビルド対象レイヤ
ビルド対象レイヤを確認する。
$ bitbake-layers show-layers NOTE: Starting bitbake server... layer path priority ======================================================================================================== core /home/mickey/seagate/yocto/scarthgap-qemu/build/dest-dir02/output/poky/meta 5 yocto /home/mickey/seagate/yocto/scarthgap-qemu/build/dest-dir02/output/poky/meta-poky 5 yoctobsp /home/mickey/seagate/yocto/scarthgap-qemu/build/dest-dir02/output/poky/meta-yocto-bsp 5
レイヤの状態は初期状態
local.conf
local.confの内容を確認する。
$ tail conf/local.conf # has completed. This means subsequent commands can run faster since there is no need # for bitbake to reload cache files and so on. Number is in seconds, after which the # server will shut down. # #BB_SERVER_TIMEOUT = "60" # CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to # track the version of this file when it was generated. This can safely be ignored if # this doesn't mean anything to you. CONF_VERSION = "2"
こちらも初期状態。せっかくsetup-layers
スクリプトで、ビルド環境を再現したのに、
bblayers.confやlocal.confが初期状態なのは使いづらい。
そこで今回紹介するsave-build-conf
が役に立つ。
save-build-confの使い方
作業環境
元となるbitbake環境のビルドディレクトリで作業する。 現在はこのような状態になっている
$ build ├── cache ├── conf ├── dest-dir01 ├── dest-dir02 ├── meta-tools-test ├── sstate-cache └── tmp
試しに追加下meta-tools-test
レイヤが含まれている状態。今回はここにtemplateconfを保存する。
実行
bitbake-layers save-build-conf
を実行してみる。
$ bitbake-layers save-build-conf ./meta-tools-test Test
今回はmeta-tools-test
レイヤにTest
という名前で設定を保存する。
出力結果
出力結果を確認する。
$ tree meta-tools-test/conf/ meta-tools-test/conf/ ├── layer.conf └── templates └── Test ├── bblayers.conf.sample ├── conf-notes.txt ├── conf-summary.txt └── local.conf.sample
conf/templates
の下にTest
が作成されており、その配下に下記のファイルが保存されている。
- bblayers.conf.sample
- conf-notes.txt
- conf-summary.txt
- local.conf.sample
bblayers.conf.sample
作成されたbblayers.conf.sample
の内容を確認する。
$ cat meta-tools-test/conf/templates/Test/bblayers.conf.sample # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf # changes incompatibly POKY_BBLAYERS_CONF_VERSION = "2" BBPATH = "${TOPDIR}" BBFILES ?= "" BBLAYERS ?= " \ ##OEROOT##/meta \ ##OEROOT##/meta-poky \ ##OEROOT##/meta-yocto-bsp \ ##OEROOT##/meta-openembedded/meta-oe \ ##OEROOT##/../build/meta-tools-test \ "
meta-oeとmeta-tools-testが追加された状態であることがわかる。
local.conf.sample
$ tail meta-tools-test/conf/templates/Test/local.conf.sample CONF_VERSION = "2" MACHINE ?= "qemuarm64" QB_OPT_APPEND:append = " -echr 0x14" INIT_MANAGER ?= "systemd" DL_DIR ?= "${TOPDIR}/../downloads"
create-layers-setupと組み合わせて使用
save-build-confの結果をpush
setup-layersではリモートリポジトリを取得するので、ローカルに保存したtemplateconfをリモートに反映する必要がある。
$ cd meta-tools-test $ git add . $ git commit -m "Add Test templateconf" $ git push example master
create-layers-setupの実行
save-build-conf
で設定を保存した状態のレイヤをcreate-layers-setupで保存する。
$ bitbake-layers create-layers-setup dest-dir03
setup-layersスクリプトの実行
setup-layersスクリプトを実行する。
$ cd dest-dir03 $ ./setup-layers --destdir output
setup-buildビルドスクリプトの実行
setup-buildスクリプトを実行する。
$ cd output $ ./setup-build Available build configurations: 1. tools-test-Test FIXME: Please place here the short summary of what this build configuration is for. It will be shown to the users when they set up their builds via TEMPLATECONF. 2. poky-default This is the default build configuration for the Poky reference distribution. Re-run with 'list -v' to see additional information. Please choose a configuration by its number: 1
meta-tools-testレイヤに保存されたTestがメニューに表示される。 ここで1を選択するとsave-build-confで保存したtemplateconfが使用される。
ビルド対象レイヤ
$ bitbake-layers show-layers NOTE: Starting bitbake server... layer path priority ======================================================================================================== core /home/mickey/seagate/yocto/scarthgap-qemu/build/dest-dir03/output/poky/meta 5 yocto /home/mickey/seagate/yocto/scarthgap-qemu/build/dest-dir03/output/poky/meta-poky 5 yoctobsp /home/mickey/seagate/yocto/scarthgap-qemu/build/dest-dir03/output/poky/meta-yocto-bsp 5 openembedded-layer /home/mickey/seagate/yocto/scarthgap-qemu/build/dest-dir03/output/poky/meta-openembedded/meta-oe 5 meta-tools-test /home/mickey/seagate/yocto/scarthgap-qemu/build/dest-dir03/output/poky/../build/meta-tools-test 6
local.conf
$ tail conf/local.conf CONF_VERSION = "2" MACHINE ?= "qemuarm64" QB_OPT_APPEND:append = " -echr 0x14" INIT_MANAGER ?= "systemd" DL_DIR ?= "${TOPDIR}/../downloads" IMAGE_INSTALL:append = " emacs"
まとめ
create-layers-setupを使用すると、レイヤの環境を再現するためのスクリプトと設定ファイルが出力される。 save-build-confを使用すると、ビルド設定を再現するためのtemplateconfが出力される。 これらを組み合わせて使用すると、 kasやrepoなどの外部ツールを使用しなくても、ビルド環境の再現が可能となる。