Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create machine specific recipes?

I want to know if there is an opportunity to create machine specific recipes just by file name in order that I have a similar layer structure like this:

\-> recipes-example
     \-> example
         \-> example_1.0.bb_machine1
         \-> example_1.0.bb_machine2

I have read almost the complete Yocto Documentation a while ago and thought I once stumbled over this opportunity to create machine specific recipes, but couldn't refind it.

Alternatives are also appreciated, however I know about the bash solutions like this example:

do_install() {
   case ${MACHINE} in
      < case statements [...] >
}
like image 482
h0ch5tr4355 Avatar asked Dec 15 '22 09:12

h0ch5tr4355


1 Answers

No, there's no way to create machine-specific recipe just by their name.

Assuming there's only a few files / patches that differs, the most common way to do this would be to add the different files in a machine specific directory see e.g.:

\-> recipes-example
  \-> example
    \-> example
      \-> machine1
        \-> defconfig
        \-> mach1.patch
      \-> machine2
        \-> defconfig
    \-> defconfig

That would allow you to write things like: (Note that in my example, there's a generic defconfig file, and two machine specific ones. The correct one will automatically be chosen, due to MACHINEOVERRIDES)

SRC_URI += "file://defconfig"
SRC_URI_machine1 += "file://mach1.patch"

In this example, mach1.patch will only be applied for machine1.

If you need to do something special for a machine in e.g. the do_install, you could use:

do_install_append_machine1 () {
    do something here
}

UPDATE: (after graugans comment)

Yes, COMPATIBLE_MACHINE could also be used. One way would be to create example-mach1.bb, example-mach2.bb, and exampe-machs.bb Which would include a couple of lines such as:

PROVIDES += "virtual/example"
COMPATIBLE_MACHINE = "machine1"

and for `example-machs.bb"

PROVIDES += "virtual/example"
COMPATIBLE_MACHINE = "(machine3|machine4)"

In your image recipe, you then add IMAGE_INSTALL += "virtual/example".

like image 65
Anders Avatar answered Jan 17 '23 22:01

Anders