http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html 参考手册
http://www.yoctoproject.org/docs/1.6.1/dev-manual/dev-manual.html 开发手册
http://elinux.org/Bitbake_Cheat_Sheet
https://community.freescale.com/docs/DOC-94953
https://wiki.yoctoproject.org/wiki/How_do_I
https://wiki.yoctoproject.org/wiki/Multilib 支持multilib (32bit 64bit)
https://lists.yoctoproject.org/pipermail/yocto/2013-October/016624.html 设置默认密码
https://wiki.yoctoproject.org/wiki/FAQ:How_do_I_set_or_change_the_root_password 设置密码
https://github.com/louiskoo/adb 移植adb到arm-linux 在 meta-smartphone中也有adbd的移植
RM_WORK_EXCLUDE += "icu-native icu busybox" 设置跳过rm_work任务,保留构建的临时目录文件等信息,适合像rootfs这类的包
TARGET_CXXFLAGS="xxxx" 可添加一些自定义的编译参数
详细见meta/classes/toolchain-scripts.bbclass
nativesdk-qt4-tools_4.8.4.bbappend
DEPENDS := "${@oe_filter_out('nativesdk-libx11', '${DEPENDS}′, d)}"
oe_filter_out --> 来自 classes/utils.bbclass --> lib/oe/utils.py 过滤排除指定字符串
https://github.com/MentorEmbedded/meta-ro-rootfs/blob/master/classes/volatile.bbclass
只读文件系统, 其中通过systemd-tmpfile来创建
可通过 man 5 tmpfiles.d来查看规则,如 vim /usr/lib/tmpfiles.d/* 查找systemd中的现成规则参考
git clone git://github.com/Angstrom-distribution/setup-scripts.git cd setup-scripts git checkout -b angstrom-v2012.12-yocto1.3 origin/angstrom-v2012.12-yocto1.3 --track
conf/local.conf
INHERIT += "own-mirrors" SOURCE_MIRROR_URL = "http://downloads.yoctoproject.org/mirror/sources"
https://wiki.yoctoproject.org/wiki/How_do_I
local.conf
SOURCE_MIRROR_URL ?= "file://source_mirror/sources/" INHERIT += "own-mirrors" BB_GENERATE_MIRROR_TARBALLS = "1" BB_NO_NETWORK = "1"
http://www.crashcourse.ca/wiki/index.php/OE-Core
http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032049.html
[OE-core] [PATCH 1/1] libpam: QA Issue: installed in the base_prefix, requires a shared library under exec_prefix
oe-core/meta/recipes-rt/images/core-image-rt-sdk.bb
IMAGE_FEATURES += "dev-pkgs 等"
通过core-image.bbclass 可得知通过IMAGE_FEATURES特性来选择不同的PACKAGE_GROUP
image.bbclass 通过 feature判断选择 globs.append("*-dev") 等
禁止make -jn并行编译
PARALLEL_MAKE = ""
支持native编译包
BBCLASSEXTEND = "native"
修改包的架构名,如原来的armv7a会被成machine的名字
PACKAGE_ARCH = "${MACHINE_ARCH}"
使能所有架构都可用,如update-rc.d包
inherit allarch
IMAGE_INSTALL += "strace" 在image添加strace包
IMAGE_INSTALL_append_pn-core-image-minimal = " strace" 只针对 core-image-minimal的image添加 strace包 PACKAGE_ARCH = "${MACHINE_ARCH}" INHIBIT_DEFAULT_DEPS = "1" 尽量用_prepend, _append代替 += , =+
工作目录
${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
TMPDIR
: The top-level build output directory
MULTIMACH_TARGET_SYS
: The target system identifier
PN
: The recipe name
EXTENDPE
: The epoch - (if PE
is not specified, which is usually the case for most recipes, then EXTENDPE
is blank)
PV
: The recipe version
PR
: The recipe revision
指定命名下载包方便做校验
SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \ ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8" SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d" SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92" SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430"
http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-BPN BPN为bare的PN, 去除像 -cross , -native等
PARALLEL_MAKE = "" 禁止并行make
拆包方式,类似debian的包拆分,比如可以分为-dev, -dbg等 PACKAGES =+ "sxpm cxpm" FILES_cxpm = "${bindir}/cxpm" FILES_sxpm = "${bindir}/sxpm"
COMPATIBLE_MACHINE = '(qemux86|qemumips)' 兼容指定的机器类型 标准包打包分类文件原型
PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-dev ${PN}-staticdev ${PN}-locale" PACKAGES_DYNAMIC = "${PN}-locale-*" FILES = "" FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \ ${sysconfdir} ${sharedstatedir} ${localstatedir} \ ${base_bindir}/* ${base_sbindir}/* \ ${base_libdir}/*${SOLIBS} \ ${datadir}/${BPN} ${libdir}/${BPN}/* \ ${datadir}/pixmaps ${datadir}/applications \ ${datadir}/idl ${datadir}/omf ${datadir}/sounds \ ${libdir}/bonobo/servers" FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \ ${datadir}/gnome/help" SECTION_${PN}-doc = "doc" FILES_${PN}-dev = "${includedir} ${libdir}/lib*${SOLIBSDEV} ${libdir}/*.la \ ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \ ${datadir}/aclocal ${base_libdir}/*.o" SECTION_${PN}-dev = "devel" ALLOW_EMPTY_${PN}-dev = "1" RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})" FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a" SECTION_${PN}-staticdev = "devel" RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
将一些包排除在你的image之外
BAD_RECOMMENDATIONS
: Use this variable to specify "recommended-only" packages that you do not want installed.
NO_RECOMMENDATIONS
: Use this variable to prevent all "recommended-only" packages from being installed.
PACKAGE_EXCLUDE
: Use this variable to prevent specific packages from being installed regardless of whether they are "recommended-only" or not. You need to realize that the build process could fail with an error when you prevent the installation of a package whose presence is required by an installed package.
允许针对不同的发行版修改包别名
Following is an example that shows how you specify the DISTRO_PN_ALIAS
variable:
DISTRO_PN_ALIAS_pn-PACKAGENAME = "distro1=package_name_alias1 \ distro2=package_name_alias2 \ distro3=package_name_alias3 \ ..."
$ bitbake world -f -c distro_check 高级用法
python populate_packages_prepend () { lighttpd_libdir = d.expand('${libdir}') do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$', 'lighttpd-module-%s', 'Lighttpd module for %s', extra_depends='') }
PACKAGES_DYNAMIC = "lighttpd-module-.*"
构建包索引
$ bitbake package-index
$ bitbake <some-package> package-index
针对包的ptest
DISTRO_FEATURES_append = " ptest" EXTRA_IMAGE_FEATURES += "ptest-pkgs"
Be sure the recipe inherits the ptest
class: Include the following line in each recipe:
inherit ptest
Create run-ptest
: This script starts your test. Locate the script where you will refer to it using SRC_URI
. Here is an example that starts a test for dbus
:
#!/bin/sh cd test make -k runtest-TESTS
依赖关系需要加上所需的 RDEPENDS_${PN}-ptest += "make"
针对编译test完成的工作 do_compile_ptest() { oe_runmake buildtest-TESTS }
Ensure special configurations are set: If the package requires special configurations prior to compiling the test code, you must insert a do_configure_ptest
function into the recipe.
Install the test suite: The ptest
class automatically copies the file run-ptest
to the target and then runs make install-ptest
to run the tests. If this is not enough, you need to create a do_install_ptest
function and make sure it gets called after the "make install-ptest" completes.
使用外部源代码
INHERIT += "externalsrc" EXTERNALSRC_pn-myrecipe = "/some/path/to/your/source/tree" 另一项指定BUILD
EXTERNALSRC_BUILD_pn-myrecipe = "/path/to/my/source/tree"
针对发行版的init管理器设置 DISTRO_FEATURES_append = " systemd" VIRTUAL-RUNTIME_init_manager = "systemd"
You can also prevent the SysVinit distribution feature from being automatically enabled as follows:
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
Doing so removes any redundant SysVinit scripts.
To remove initscripts from your image altogether, set this variable also:
VIRTUAL-RUNTIME_initscripts = "" DISTRO_FEATURES_append = " systemd" VIRTUAL-RUNTIME_init_manager = "systemd"
外部SCM
PV = "1.2.3+git${SRCPV}
Then, you can add the following to your local.conf
:
SRCREV_pn-<PN> = "${AUTOREV}"
SRCREV = "${AUTOREV}"
The Yocto Project provides a distribution named poky-bleeding
, whose configuration file contains the line:
require conf/distro/include/poky-floating-revisions.inc
This line pulls in the listed include file that contains numerous lines of exactly that form:
SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
只读文件系统
IMAGE_FEATURES = "read-only-rootfs"
$ bitbake gdb-cross
INHERIT += "archiver" ARCHIVER_MODE[src] = "original"
One requirement that is often overlooked is inclusion of license text. This requirement also needs to be dealt with prior to generating the final image. Some licenses require the license text to accompany the binary. You can achieve this by adding the following to your local.conf
file:
COPY_LIC_MANIFEST = "1" COPY_LIC_DIRS = "1"
添加调试输出信息
do_my_function() {
bbdebug 2 "Running do_my_function" }
python do_listtasks() { bb.debug(2, "Starting to figure out the task list")
}
构建历史记录信息
INHERIT += "buildhistory" BUILDHISTORY_COMMIT = "1" 只针对image构建信息有兴趣
INHERIT += "buildhistory" BUILDHISTORY_COMMIT = "0" BUILDHISTORY_FEATURES = "image"
PKGD
- The destination directory for packages before they are split.
PKGDATA_DIR
- A shared, global-state directory that holds data generated during the packaging process.
PKGDESTWORK
- A temporary work area used by the do_package
task.
PKGDEST
- The parent directory for packages after they have been split.
IMAGE_INSTALL
: Lists out the base set of packages to install from the Package Feeds area.
PACKAGE_EXCLUDE
: Specifies packages that should not be installed.
IMAGE_FEATURES
: Specifies features to include in the image. Most of these features map to additional packages for installation.
PACKAGE_CLASSES
: Specifies the package backend to use and consequently helps determine where to locate packages within the Package Feeds area.
IMAGE_LINGUAS
: Determines the language(s) for which additional language support packages are installed.
DEPLOY_DIR
: Points to the deploy
directory.
SDKMACHINE
: Specifies the architecture of the machine on which the cross-development tools are run to create packages for the target hardware.
SDKIMAGE_FEATURES
: Lists the features to include in the "target" part of the SDK.
TOOLCHAIN_HOST_TASK
: Lists packages that make up the host part of the SDK (i.e. the part that runs on the SDKMACHINE
). When you use bitbake -c populate_sdk <imagename>
to create the SDK, a set of default packages apply. This variable allows you to add more packages.
TOOLCHAIN_TARGET_TASK
: Lists packages that make up the target part of the SDK (i.e. the part built for the target hardware).
SDKPATH
: Defines the default SDK installation path offered by the installation script.
DEPLOYDIR = "${WORKDIR}/deploy-${PN}" SSTATETASKS += "do_deploy" do_deploy[sstate-name] = "deploy" do_deploy[sstate-inputdirs] = "${DEPLOYDIR}" do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" python do_deploy_setscene () { sstate_setscene(d) } addtask do_deploy_setscene do_deploy[dirs] = "${DEPLOYDIR} ${B}"
The naming scheme for kernel output binaries has been changed to now include PE
as part of the filename:
KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PE}-${PV}-${PR}-${MACHINE}-${DATETIME}"
BP
The base recipe name and version but without any special recipe name suffix (i.e. -native
, lib64-
, and so forth). BP
is comprised of the following:
${BPN}-${PV}
BPN
The bare name of the recipe. This variable is a version of the PN
variable but removes common suffixes such as "-native" and "-cross" as well as removes common prefixes such as multilib's "lib64-" and "lib32-". The exact list of suffixes removed is specified by theSPECIAL_PKGSUFFIX
variable. The exact list of prefixes removed is specified by the MLPREFIX
variable. Prefixes are removed formultilib
and nativesdk
cases.
EXTRA_OECMAKE
Additional cmake
options.
EXTRA_OECONF
Additional configure
script options.
EXTRA_OEMAKE
Additional GNU make
options.
EXTRA_OESCONS
When a recipe inherits the scons
class, this variable specifies additional configuration options you want to pass to the scons
command line.
EXTRA_QMAKEVARS_POST
Configuration variables or options you want to pass to qmake
. Use this variable when the arguments need to be after the .pro
file list on the command line.
This variable is used with recipes that inherit the qmake_base
class or other classes that inherit qmake_base
.
EXTRA_QMAKEVARS_PRE
Configuration variables or options you want to pass to qmake
. Use this variable when the arguments need to be before the .pro
file list on the command line.
This variable is used with recipes that inherit the qmake_base
class or other classes that inherit qmake_base
.
EXTRA_USERS_PARAMS
When a recipe inherits the extrausers
class, this variable provides image level user and group operations. This is a more global method of providing user and group configuration as compared to using the useradd
class, which ties user and group configurations to a specific recipe.
The set list of commands you can configure using the EXTRA_USERS_PARAMS
is shown in the extrausers
class. These commands map to the normal Unix commands of the same names:
# EXTRA_USERS_PARAMS = "\ # useradd -p '' tester; \ # groupadd developers; \ # userdel nobody; \ # groupdel -g video; \ # groupmod -g 1020 developers; \ # usermod -s /bin/sh tester; \ # "
如果widget添加了,自动添加p1, p2 FEATURE_PACKAGES_widget = "package1 package2"
In this example, if "widget" were added to IMAGE_FEATURES
, "package1" and "package2" would be included in the image.
在.bbappend里最常用的
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
FILESOVERRIDES
A subset of OVERRIDES
used by the OpenEmbedded build system for creating FILESPATH
. You can find more information on how overrides are handled in the BitBake Manual that is located at bitbake/doc/manual
in the Source Directory.
By default, the FILESOVERRIDES
variable is defined as:
FILESOVERRIDES = "${TRANSLATED_TARGET_ARCH}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}"
构建image的处理命令
IMAGE_POSTPROCESS_COMMAND += "<shell_command>; ... "
IMAGE_ROOTFS_EXTRA_SPACE
INHIBIT_PACKAGE_STRIP
If set to "1", causes the build to not strip binaries in resulting packages.
KBRANCH_DEFAULT = "standard/base" KBRANCH = "${KBRANCH_DEFAULT}" --------------------------------- COMPATIBLE_MACHINE_crownbay = "crownbay" KMACHINE_crownbay = "crownbay" KBRANCH_crownbay = "standard/crownbay" KERNEL_FEATURES_append_crownbay = " features/drm-emgd/drm-emgd-1.18 cfg/vesafb" COMPATIBLE_MACHINE_crownbay-noemgd = "crownbay-noemgd" KMACHINE_crownbay-noemgd = "crownbay" KBRANCH_crownbay-noemgd = "standard/crownbay" KERNEL_FEATURES_append_crownbay-noemgd = " cfg/vesafb"
在local.conf中添加
PACKAGE_CLASSES ?= "package_ipk package_tar"
MACHINEOVERRIDES
Lists overrides specific to the current machine. By default, this list includes the value of MACHINE
. You can extend the list to apply variable overrides for classes of machines. For example, all QEMU emulated machines (e.g. qemuarm, qemux86, and so forth) include a common file named meta/conf/machine/include/qemu.inc
that prepends MACHINEOVERRIDES
with the following variable override:
MACHINEOVERRIDES =. "qemuall:"
自动加载模块
module_autoload_<modname> = "modname1 modname2 modname3"
PACKAGECONFIG 重要,在参考手册尾部有详细说明
指定打补丁工具
PATCHTOOL = "patch" PATCHTOOL = "quilt" PATCHTOOL = "git"
PE ---- The epoch of the recipe. By default, this variable is unset. The variable is used to make upgrades possible when the versioning scheme changes in some backwards incompatible way.
PRINC
The PRINC
variable has been deprecated and triggers a warning if detected during a build. For PR
increments on changes, use the PR service instead. You can find out more about this service in the "Working With a PR Service" section in the Yocto Project Development Manual.
ROOT_HOME
Defines the root home directory. By default, this directory is set as follows in the BitBake configuration file:
ROOT_HOME ??= "/home/root"
ROOTFS_POSTPROCESS_COMMAND
Added by classes to run post processing commands once the OpenEmbedded build system has created the root filesystem. You can specify shell commands separated by semicolons:
ROOTFS_POSTPROCESS_COMMAND += "<shell_command>; ... "
SYSTEMD_SERVICE
For recipes that inherit the systemd
class, this variable specifies the systemd service name for a package.
When you specify this file in your recipe, use a package name override to indicate the package to which the value applies. Here is an example from the connman recipe:
SYSTEMD_SERVICE_${PN} = "connman.service"
qmake5_base.bbclass中示例
do_configure[prefuncs] += " "
do_configure[postfuncs] += ""