In this chapter, we will discuss layers, a powerful mechanism for the organization and reuse of metadata. We will also discuss the creation of layers using the script yocto-layer
. Then, we will move on to various configuration options to organize the metadata and types of layers. We will cover aiding techniques of append files usage and packagegroups
. We will discuss image customization as well.
You're reading from Using Yocto Project with BeagleBone Black
We should always start with something easy, in order to keep things simple. So, a simple way to create a layer is to execute the following command from the script directory, under the poky
directory:
$ ./scripts/yocto-layer create test
This will create a directory named meta-test
in the poky
directory, from where we invoke this command. However, before that, you have to answer some questions. The answers are discussed in these steps:
Enter the layer priority you'd like to use for this layer: [default: 6] 7
Check whether you would like to have an example recipe created: (y/n) [default: n]
Check whether you would you like to have an example
bbappend
file created: (y/n) [default: n] yEnter the name you'd like to use for your bbappend file: [default: example]
helloworld
Enter the version number you'd like to use for your bbappend file, (this should match the recipe you're appending the file to): [default: 0.1]
Then, this script will notify us about enabling our newly...
We have already discussed, layers are a way of organizing our metadata. To use these layers, we have to follow a well-defined directory structure to keep the metadata as well as code, for the organization of this metadata. In this section, we will discuss how this organization is accomplished, what the minimum requirements of the directory structure are, and what contents are available under each directory. To talk about the directories in any layer, the layer should have at least two directories, which are discussed in the upcoming sections.
The minimal content in this directory is the configuration file named layer.conf
. Basically, there are two types of layers:
General layers
BSP layers
We have created a general layer in the previous experimentation, using the yocto-layer
command with its create
option. BSP layers can be created using the yocto-bsp
command, in a manner that is similar to using some extra options, which are not very different. This file...
We can use BBFILE_COLLECTIONS
to conditionally decide which recipes to include in our BBFILES
. To do this, we need to use logic that is similar to the following in our layer.conf
:
Firstly, add the following two lines to our
layer.conf
file:BBFILES += "${@' '.join('${LAYERDIR}/%s/recipes-*/*/*.bbappend' % layer \ for layer in BBFILE_COLLECTIONS.split())}" BBFILES += "${@' '.join('${LAYERDIR}/%s/recipes-*/*/*.bb' % layer \ for layer in BBFILE_COLLECTIONS.split())}"
Secondly, arrange your
recipes-*
directories under directories named according to other layers found inBBFILE_COLLECTION
. For example, we might need to add some metadata that is specific only to it, and we want it applied only when we havemeta-ti
included in ourbblayers.conf
file. What we will do in this case is create a directory under our layer—say,test/meta-t/
—and move all of therecipe-*
directories specific to it under this directory. In the current configuration...
We did not create a recipe file while creating the meta-test layer. Instead, we created an append file for the helloworld
recipe, which we already have in the meta-ybdevelop
layer. Append files are a mechanism used to override/enhance existing functionality in the recipe to which the append is being applied. This is the recommended way to do things. According to the guidelines, it is suggested that you use append files instead of copying the full recipe files to your layers. These files should have bbappend
as an extension, and the name should be the same as the recipe to which we are applying modifications. Also, you should only be modifying the contents required by you. In this append file, we used two lines. In the first line, we extended the file lookup path to be used, as follows:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
In the next line, we picked the patch file to be applied to the source code file of our helloworld recipe. This is a simple patch file, which...
We have discussed how to customize images using the append file on images, or using configuration files. These techniques are useful in some use cases, yet they could become a hassle in cases where we are dealing with logs of packages and we want to use these packages with more than one image type. In such cases, we will be performing duplications, which are certainly not clean. To avoid such cases, packagegroups
comes into play. The idea is to keep these lists of packages separate from image append files so that they can be used across multiple images.
This is a specialized recipe .bb
file with the following features. Again, it will reside in the top-level directory of our layer/recipes-*/packagegroups/<packagegroup>.bb
file:
It inherits package groups, that is, the
packagegroup.bbclass
class is used from meta/classes. This should be the first line of the code:Inherit packagegroup
All of the packagegroups that need to be created are added to the
PACKAGES
variable:PACKAGES...
In this chapter, we created one more meta-test
layer. We also performed some experimentation on this layer so that we could discuss related concepts. We discussed the contents of layers in detail, and we also discussed image customization techniques using simple configuration, bbappend
, and packagegroups
.
In next chapter, we will discuss some console-based games. For this purpose, we will select a console-based version of the popular game PAC-MAN.