By: fu linux
E-mail: fulinux@sina.com
Blog: https://blog.csdn.net/fulinus
喜欢的盆友欢迎点赞和订阅!
你的喜欢就是我写作的动力!
BitBake全过程
镜像文件制作
一旦完成包的拆分并存储在Package Feeds区域中后,构建系统将使用BitBake生成根文件系统映像,如下图所示:
do_rootfs任务
镜像制作生成过程由几个阶段组成,并依赖于多个任务和变量。do_rootfs任务为映像创建根文件系统(文件和目录结构)。此任务使用几个关键变量来帮助创建要实际安装的包列表:
IMAGE_INSTALL变量
列出要从“包源”区域安装的包的基本集。参考如下:
build]$ bitbake -e learnyocto | grep ^IMAGE_INSTALL
IMAGE_INSTALL=" learnyocto"
build]$ bitbake -e core-image-sato | grep ^IMAGE_INSTALL
IMAGE_INSTALL=" packagegroup-core-boot packagegroup-base-extended learnyocto"
IMAGE_INSTALL_COMPLEMENTARY=""
IMAGE_INSTALL_DEBUGFS=""
- 1
- 2
- 3
- 4
- 5
- 6
- 7
PACKAGE_EXCLUDE变量
用来指定不应安装到镜像(image)中的包。参考如下:
build]$ bitbake -e core-image-sato | grep ^PACKAGE_EXCLUDE=
PACKAGE_EXCLUDE=""
- 1
- 2
目前没有被排斥在外的软件包, 如果需要指定不安装的包可以在:
poky/build/conf/local.conf
- 1
文件中后面添加,形如:
PACKAGE_EXCLUDE_append = "xxxx"
- 1
其中xxxx是recipe名,就是bb文件下划线前面的部分。
IMAGE_FEATURES变量
指定要包含在镜像中的特性。这些特性中的大多数映射到附加的安装包。参考如下:
build]$ bitbake -e core-image-sato | grep ^IMAGE_FEATURES=
IMAGE_FEATURES="debug-tweaks hwcodecs package-management splash ssh-server-dropbear x11-base x11-sato"
- 1
- 2
PACKAGE_CLASSES变量
用来指定是什么类型的包(比如RPM,DEB, 或者IPK),帮助决定将包放在何处。如下所示:
build]$ bitbake -e core-image-sato | grep ^PACKAGE_CLASSES=
PACKAGE_CLASSES="package_rpm"
- 1
- 2
IMAGE_LINGUAS变量
确定为其安装其他语言支持包的语言。参考如下:
build]$ bitbake -e learnyocto | grep ^IMAGE_LINGUAS
IMAGE_LINGUAS="en-us en-gb"
build]$ bitbake -e core-image-sato | grep ^IMAGE_LINGUAS
IMAGE_LINGUAS="en-us en-gb"
- 1
- 2
- 3
- 4
- 5
指定在根文件系统构造过程中要安装到镜像中,比如添加中文语言支持时,可以在build/conf/local.conf文件中添加:
IMAGE_LINGUAS_append = " zh-cn" #前面加个空格
- 1
加完后需要重新source, 如下所示:
poky]$ source oe-init-build-env
build]$ bitbake -e core-image-sato | grep ^IMAGE_LINGUAS
IMAGE_LINGUAS="en-us en-gb zh-cn"
- 1
- 2
- 3
参考:
嵌入式Linux下中文字体显示
具体没有验证,以后有机会在验证。
字体库一般是在:
root@qemux86-64:~# ls /usr/share/fonts/ttf/
LiberationMono-Bold.ttf LiberationMono-Regular.ttf ...
- 1
- 2
PACKAGE_INSTALL变量
传递给包管理器以安装到镜像中的包的最终列表。参考如下:
build]$ bitbake -e core-image-sato | grep PACKAGE_INSTALL
...
export PACKAGE_INSTALL=" packagegroup-core-boot packagegroup-base-extended learnyocto run-postinsts rpm dnf psplash packagegroup-core-ssh-dropbear packagegroup-core-x11-base packagegroup-core-x11-sato"
...
- 1
- 2
- 3
- 4
其中一些packagegroup-*相当于子集。
IMAGE_ROOTFS变量
指向文件系统创建过程中的目录位置,参考如下所示:
build]$ bitbake -e core-image-sato | grep ^IMAGE_ROOTFS=
IMAGE_ROOTFS="/home/peeta/poky/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0-r0/rootfs"
- 1
- 2
这个目录还是很有用处的,通常要看自己的的项目有没有正取的安装到镜像文件系统中,可以在这个目录中查看,比如:
build]$ ls -l tmp/work/qemux86_64-poky-linux/core-image-sato/1.0-r0/rootfs/usr/bin/learnyocto
-rwxr-xr-x 1 peeta peeta 14296 3月 9 2018 tmp/work/qemux86_64-poky-linux/core-image-sato/1.0-r0/rootfs/usr/bin/learnyocto
- 1
- 2
do_rootfs最后处理的内容包括创建文件清单和优化等工作。
IMAGE_MANIFEST变量
文件清单(.manifest)与根文件系统镜像位于同一目录中。此文件逐行列出已安装的软件包。文件清单非常有用,参考如下文件路径:
build]$ bitbake -e core-image-sato | grep ^IMAGE_MANIFEST=
IMAGE_MANIFEST="/home/peeta/poky/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0-r0/deploy-core-image-sato-image-complete/core-image-sato-qemux86-64-20201201114447.rootfs.manifest"
- 1
- 2
IMAGE_FSTYPES变量
可以指定文件系统类型和压缩类型,通常ext4的文件系统镜像很大,因为文件系统有预留空间,经过tar.bz2类型的压缩后可以减小镜像的总体大小,默认的参考如下:
build]$ bitbake -e core-image-sato | grep ^IMAGE_FSTYPES=
IMAGE_FSTYPES=" tar.bz2 ext4"
- 1
- 2
bitbake core-image-sato -c listtasks
该命令可以列出构建core-image-sato过程中需要执行的任务,如下所示:
build]$ bitbake core-image-sato -c listtasks
do_build Default task for a recipe - depends on all other normal tasks required to 'build' a recipe
do_checkuri Validates the SRC_URI value
do_clean Removes all output files for a target
do_cleanall Removes all output files, shared state cache, and downloaded source files for a target
do_cleansstate Removes all output files and shared state cache for a target
do_compile Compiles the source in the compilation directory
do_configure Configures the source by enabling and disabling any build-time and configuration options for the software being built
do_deploy_source_date_epoch
do_deploy_source_date_epoch_setscene (setscene version)
do_devpyshell Starts an interactive Python shell for development/debugging
do_devshell Starts a shell with the environment set up for development/debugging
do_fetch Fetches the source code
do_image
do_image_complete
do_image_complete_setscene (setscene version)
do_image_ext4
do_image_qa
do_image_qa_setscene (setscene version)
do_image_tar
do_install Copies files from the compilation directory to a holding area
do_listtasks Lists all defined tasks for a target
do_package Analyzes the content of the holding area and splits it into subsets based on available packages and files
do_package_qa_setscene Runs QA checks on packaged files (setscene version)
do_package_setscene Analyzes the content of the holding area and splits it into subsets based on available packages and files (setscene version)
do_package_write_rpm_setscene Creates the actual RPM packages and places them in the Package Feed area (setscene version)
do_packagedata Creates package metadata used by the build system to generate the final packages
do_packagedata_setscene Creates package metadata used by the build system to generate the final packages (setscene version)
do_patch Locates patch files and applies them to the source code
do_populate_lic_deploy
do_populate_lic_setscene Writes license information for the recipe that is collected later when the image is constructed (setscene version)
do_populate_sdk Creates the file and directory structure for an installable SDK
do_populate_sdk_ext
do_populate_sysroot_setscene Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes (setscene version)
do_prepare_recipe_sysroot
do_rootfs Creates the root filesystem (file and directory structure) for an image
do_rootfs_wicenv
do_sdk_depends
do_unpack Unpacks the source code into a working directory
do_write_qemuboot_conf
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40