Preferring and providing recipes

The dependency relation between recipes is essential to BitBake and Poky. It is defined inside each recipe file, with a variable that describes on what a recipe depends (DEPENDS) and what a recipe provides to the system (PROVIDES). These two variables together build the dependency graph used by BitBake during dependency resolution.

So, if a recipe called foo_1.0.bb depends on bar, BitBake lists all recipes providing bar. The bar dependency can be satisfied by the following:

  • A recipe with the bar_<version>.bb format, because every recipe provides itself
  • A recipe where the PROVIDES variable includes bar

A dependency can be satisfied by several recipes (for example, if two or more recipes have PROVIDES += "bar"). In this case, we must inform BitBake which specific provider to use.

The virtual/kernel provider is a clear example where this mechanism is used. The virtual/ namespace is the convention adopted when we have a set of commonly overridden providers.

All recipes that require the kernel to build can add virtual/kernel to the dependency list (DEPENDS), and BitBake makes sure to satisfy the dependency. When we have more than one recipe with an alternative provider, we must choose one to be used, for example, PREFERRED_PROVIDER_virtual/kernel = "linux-mymachine".

The virtual/kernel provider is commonly set in the machine definition file, as it may vary from one machine to another. We will see how to create a machine definition file in Chapter 11, ;Creating Custom Layers.

When BitBake cannot satisfy a dependency due to a missing provider, an error is raised.

In the same system, two recipes cannot use different providers for the same dependency. When BitBake has two providers with different versions, it uses the highest version by default. We can force BitBake to use a different version by using PREFERRED_VERSION. This is commonly found in BSPs, such as bootloaders, where vendors may use specific versions for a board.

When we have a development or an unreliable version of a recipe, and we do not want it to be used by default, we can use DEFAULT_PREFERENCE = "-1" in the recipe file. So, even if the version is higher, it is not taken without it being explicitly set (using PREFERRED_VERSION).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.252.8