はじめに
bitbakeでビルド可能なイメージについて調査する。
pokyのmetaレイヤに含まれるものは下記のようになっている。
イメージのレシピ | ディレクトリ |
---|---|
build-appliance-image_15.0.0.bb | recipes-core/images |
core-image-base.bb | recipes-core/images |
core-image-minimal-dev.bb | recipes-core/images |
core-image-minimal-initramfs.bb | recipes-core/images |
core-image-minimal-mtdutils.bb | recipes-core/images |
core-image-minimal.bb | recipes-core/images |
core-image-ptest-all.bb | recipes-core/images |
core-image-ptest-fast.bb | recipes-core/images |
core-image-tiny-initramfs.bb | recipes-core/images |
core-image-sato-dev.bb | recipes-sato/images |
core-image-sato-sdk.bb | recipes-sato/images |
core-image-sato.bb | recipes-sato/images |
core-image-rt-sdk.bb | recipes-rt/images |
core-image-rt.bb | recipes-rt/images |
core-image-weston-sdk.bb | recipes-graphics/images |
core-image-weston.bb | recipes-graphics/images |
core-image-x11.bb | recipes-graphics/images |
core-image-full-cmdline.bb | recipes-extended/images |
core-image-kernel-dev.bb | recipes-extended/images |
core-image-testcontroller-initramfs.bb | recipes-extended/images |
core-image-testcontroller.bb | recipes-extended/images |
この内、いくつかをピックアップして調査する。
レシピの内容を確認
これらのレシピは下記のような変数に影響受けることが多い。
- MACHINE_FEATURES
- DISTRO_FEATURES
- IMAGE_FEATURES
ここではこれらをまとめてFEATURES変数
と呼ぶ。
core-image-minimal
最小構成のイメージ。ターゲットのブートに最低限必要なパッケージを含んでいる。
具体的には下記のように設定されている。
IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
packagegroup-core-boot
が最低限ブートに必要なパッケージを含んでいる。
実際のpackagegroup-core-bootの中身は、bitbake実行時の変数の値によって異なるため単純に一覧にすることはできない。
CORE_IMAGE_EXTRA_INSTALL
は任意にイメージに追加したいパッケージの変数となる。この変数はlocal.confでのみ記述することができる。
パッケージ追加にはよくlocal.confにIMAGE_INSTALL:append
を記載する例を見かけるが、CORE_IMAGE_EXTRA_INSTALLに設定された値も最終的にIMAGE_INSTALL変数に代入されるため、
結果的には同じような働きをする。
core-image-minimal-dev
core-image-minimalの内容に、下記の内容が追加される。
IMAGE_FEATURES += "dev-pkgs"
dev-pkgsについては下記のように説明されている。
# - dbg-pkgs - debug symbol packages for all installed packages in the rootfs
core-image-minimal-initramfs
core-image-minimalとは全く異なる。パッケージのインストールに関わる部分は下記のようになっている。
INITRAMFS_SCRIPTS ?= "\ initramfs-framework-base \ initramfs-module-setup-live \ initramfs-module-udev \ initramfs-module-install \ initramfs-module-install-efi \ " PACKAGE_INSTALL = "${INITRAMFS_SCRIPTS} ${VIRTUAL-RUNTIME_base-utils} udev base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}"
このイメージはIMAGE_INSTALL
変数の影響を受けない。
core-image-minimal-mtdutils
core-image-minimalに下記が追加される。
IMAGE_INSTALL += "mtd-utils"
IMAGE_INSTALLに対して+=
を使用しているが、local.confではこの記述は許容されていないので注意が必要。
Using IMAGE_INSTALL with the += BitBake operator within the /conf/local.conf file or from within an image recipe is not recommended. Use of this operator in these ways can cause ordering issues. Since core-image.bbclass sets IMAGE_INSTALL to a default value using the ?= operator, using a += operation against IMAGE_INSTALL results in unexpected behavior when used within conf/local.conf. Furthermore, the same operation from within an image recipe may or may not succeed depending on the specific situation. In both these cases, the behavior is contrary to how most users expect the += operator to work.
core-image-full-cmdline
内容としてはcore-image-minimal + packagegroup-core-full-cmdline + αという感じだが、レシピの作りとしてはcore-image-minimalをベースにはしていない。 パッケージのインストールに関わる部分は下記のようになっている。
IMAGE_FEATURES += "splash ssh-server-openssh" IMAGE_INSTALL = "\ packagegroup-core-boot \ packagegroup-core-full-cmdline \ ${CORE_IMAGE_EXTRA_INSTALL} \ "
core-image-base
コンソール主体のイメージのレシピの中で実はこれが分かりづらい。レシピ全体を示す。
SUMMARY = "A console-only image that fully supports the target device \ hardware." IMAGE_FEATURES += "splash" LICENSE = "MIT" inherit core-image
このイメージはcore-image.bbclassがインストールしようとするものを全てインストールするようなものになっている。
MACHINE_FEATURESなどのFEATURES変数で設定した値が全て反映されるため、fully supports the target device hardware.
という位置づけになっている。
逆にcore-image-minimalもcore-image-full-cmdlineもIMAGE_INSTALL
変数に=
で値を設定することによって、core-image.bbclassでインストールされるパッケージに対して制限をかけている。
core-image-x11
core-image-baseにx11-base
関連のFEATURESが追加されている。
IMAGE_FEATURES += "splash package-management x11-base" REQUIRED_DISTRO_FEATURES = "x11"
core-image-weston
core-image-baseにweston
関連のFEATUREが追加されている。
IMAGE_FEATURES += "splash package-management ssh-server-dropbear hwcodecs weston" CORE_IMAGE_BASE_INSTALL += "gtk+3-demo" CORE_IMAGE_BASE_INSTALL += "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'weston-xwayland matchbox-terminal', '', d)}"
DISTRO_FEATURES
にx11
が設定されている場合、weston-xwaylandとmatchbox-terminalが追加されるようになっている。
BSPによってはこの部分がトラブルを起こすことがある。下記のようにDISTRO_FEATURESからx11
を削除する必要となるケースがある。
DISTRO_FEATURES:remove = "x11"
core-image-sato
core-image-baseにx11-sato
関連のFEATURESが追加されている。
IMAGE_FEATURES += "splash package-management x11-base x11-sato ssh-server-dropbear hwcodecs"
FEATURES変数とpackagegroup
イメージのレシピでは一部を除いてIMAGE_INSTALL
で直接パッケージを使用せずにFEATURES変数の有無で必要なパッケージが選択されるようになっている。
これはFEATURES変数とpackagegroupは紐付けられていて、FEATRUESを設定することで、その機能の実現に必要なパッケージを含むpackagegroupが選択されるようになっているためである。
core-image.bbclassに下記のように定義されている。
FEATURE_PACKAGES_weston = "packagegroup-core-weston" FEATURE_PACKAGES_x11 = "packagegroup-core-x11" FEATURE_PACKAGES_x11-base = "packagegroup-core-x11-base" FEATURE_PACKAGES_x11-sato = "packagegroup-core-x11-sato" FEATURE_PACKAGES_tools-debug = "packagegroup-core-tools-debug" FEATURE_PACKAGES_eclipse-debug = "packagegroup-core-eclipse-debug" FEATURE_PACKAGES_tools-profile = "packagegroup-core-tools-profile" FEATURE_PACKAGES_tools-testapps = "packagegroup-core-tools-testapps" FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk packagegroup-core-standalone-sdk-target" FEATURE_PACKAGES_nfs-server = "packagegroup-core-nfs-server" FEATURE_PACKAGES_nfs-client = "packagegroup-core-nfs-client" FEATURE_PACKAGES_ssh-server-dropbear = "packagegroup-core-ssh-dropbear" FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh"
厳密にはFEATURES変数と1:1で定義されている訳ではないが、その関係性を推測することはできる。
基本的にはpackagegroup内ではパッケージ間の依存関係が考慮されており、 packagegroup単位での追加、削除を行う場合には、パッケージ間の依存関係でトラブルになる可能性は低いであろうことが予想できる。
まとめ
pokyでビルド可能なイメージのレシピのうち下記のものを調査した。
- core-image-minimal
- core-image-minimal-dev
- core-image-minimal-initramfs
- core-image-minimal-mtdutils
- core-image-full-cmdline
- core-image-base
- core-image-x11
- core-image-weston
- core-image-sato
それぞれのイメージがどのようにパッケージを選択しているのかなど、ざっくりと理解できた。 FEATURES変数により選択されるパッケージが変化するため、IMAGE_INSTALL変数に直接パッケージを羅列している訳ではないということがわかった。 core-image-minimal-initramfsについては名前に反してcore-image-minimalはベースにしておらず、IMAGE_INSTALL変数が作用しないこともわかった。
基本的にはコンソール環境では、core-image-baseを選択するのが良さそう。 core-image-x11やcore-image-westonなどのGUIを含むイメージはcore-image-baseをベースとしている。