0
votes

I have a custom meta-layer with a bitbake recipe that add some files to the final image running do_install().

I want to execute this do_install (or the entire recipe) only if machine name contain a specific substring.

For example if I have 3 possibile machine names: "machine1", "machiABCne2", "machABine3", and the substring that I evaluating is "ABC", only if MACHINE="machiABCne2" I want include and run my custom recipe.

How can I do that in a general way, without creating multiple files and directories with all possibile machine names, but searching for the substring inside the machine name?

It's ok also running the content of do_install based on machine if not possibile in other ways.

1

1 Answers

0
votes

Try to add below macro in your recipe(example.bb) file.

COMPATIBLE_MACHINE  =  "machiABCne2"

if the machine name is "machiABCne2" then only example.bb file will compile and add to your rootfs otherwise bitbake throws error. OR you can also add this recipe for more machine using below function in your example.bb

python () {
        machine = d.getVar("MACHINE", True)

        import re
        if re.match('imx6qpdlsolox',machine):
                subplatform = 'mx6qsabresd'
        elif re.match('imx6ul7d',machine):
                subplatform = 'mx6ulevk'
        elif re.match('imx6ull',machine):
                subplatform = 'mx6ullevk'
        elif re.match('imx',machine):
                subplatform = machine[1:]
        else:
                bb.fatal("optee-os-imx doesn't recognize this MACHINE")
        d.setVar("OPTEE_PLATFORM", subplatform)
}

hope the function will help you.