5

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?

Konstantin Shemyak
  • 2,369
  • 5
  • 21
  • 41
  • As far as I know and understand the documentation `IMAGE_INSTALL*` should only be used in "image recipes", but there its usage is perfectly fine. Where (package recipe, image recipe, config, ...) did you added `IMAGE_INSTALL_append_machine1`? – g0hl1n Mar 03 '16 at 14:20
  • @g0hl1n: I have added it to the image recipe. – Konstantin Shemyak Mar 03 '16 at 14:37
  • Then it should be fine as far as I know. The only improvement i can imagine is to "append to the append": `IMAGE_INSTALL_append_machine1 += " package1"`. That's the way I'm using it for years without problems. – g0hl1n Mar 03 '16 at 14:51
  • @g0hl1n Could you explain how `IMAGE_INSTALL_append_machine1 += " package1"` work? If IMAGE_INSTALL is an array, what would IMAGE_INSTALL be like with IMAGE_INSTALL_append_machine1 + = " "? 2D array? Sorry, I have never seen this way of using IMAGE_INSTALL_append. – Charles C. Mar 03 '16 at 20:27
  • @LightenS to be honest, I don't know for sure how it really works. I am only guessing: `IMAGE_INSTALL` is basically a string containing package names, separated by spaces. The same goes for `IMAGE_INSTALL_append` and `IMAGE_INSTALL_append_machine`. So it should be possible to just attach another "space separated" String to those variables. Finally somewhere in the core all `IMAGE_INSTALL` variables get merged and are then intepreted... _As I already wrote, this is only my understanding of the process, don't take it as a fact!_ P.S.: If somebody has a link to the "real facts", please share! – g0hl1n Mar 04 '16 at 07:43
  • @g0hl1n I did some experiment regarding IMAGE_INSTALL the way you did and use `bitbake -e | grep IMAGE_INSTALL`. You would only need to use `IMAGE_INSTALL_append_machine1 = " "`. When the machine variable is equal to `machine`, the item will be added to `IMAGE_INSTALL`, interesting. – Charles C. Mar 05 '16 at 01:00

1 Answers1

4

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

Charles C.
  • 3,725
  • 4
  • 28
  • 50