Search code examples
cross-platformyoctobitbake

bitbake: how to add package depending on MACHINE?


My images, built with bitbake, must contain different packages for different machines (say, I need to add package package1 to image for machine1, but not for machine2).

It is possible to add line

IMAGE_INSTALL_append_machine1 = " package1"

to the image recipe. But I do not think this is sustainable, as IMAGE_INSTALL_append_machine1 may be defined in some other recipe (which is not under my control) and the earlier definition gets overwritten with the later one. This is what I think Yocto Project Development manual warns about using IMAGE_INSTALL.

Is my concern valid? What is the proper way to write the recipe(s) in this case?


Solution

  • I believe the function you are looking for is base_contains

    This functions is used to set a variable to one of two values based on the definition of a third variable.

    ${@base_contains('variable-name', 'value', 'true-result', 'false-result',d)}" where:

    variable-name This is the name of a variable to check.

    value This is the value to compare the variable against.

    true-result If the variable equals the value then this is what is returned by the function.

    false-result If the variable does not equal the value then this is what is returned by the function.

    One more thing, you could use ??= to provide a default value. The differences between ?= and ??= is that with ??= the assignment does not occur until the end of the parsing process.

    You could take a look at one of the example here for image recipe

    http://www.embeddedlinux.org.cn/OEManual/recipes_advanced_python.html