We have a single MACHINE which we use to build two target images; foo-image and foobar-image. Both images consume the same version of a package, but we would like to add a change to the do_install task based on which image is built. So that the recipe file for the package looks something like this:
do_install (){
//Some work
}
do_install_append_foobar-image(){
//Some foobar work
}
Eventually when we do the build for the two images:
MACHINE=custom bitbake foo-image
MACHINE=custom bitbake foobar-image
The image for foobar will contain the installed package that has done the work in the appends task, but the image for foo will not.
Is there any way to do what I have outlined or what would be an alternative?
No, you can't perform different tasks in a recipe based on which image is being built. There might be a possibility of checking the image name in the do_install
though I'm highly unsure.
What I'd do is the following:
- In the recipe, add a 2nd package which includes the additional files (if that's what you want to do).
- Have your 2nd image recipe include this 2nd package.
Another possibility, depending on if you can detect which image you have built, is to add a post_install
-script, that does the modification for you. A third, maybe less good option would be to do changes in a ROOTFS_POSTPROCESS_COMMAND
.
Which solution you choose, will depend on what kind of customization you want to.
After some deliberation we were probably thinking about this backwards. We probably want to inject separation at the MACHINE level. Since both will be separate products in the end this makes the most sense. Doing it this way will allow us to introduce changes to packages for that specific product.
Our build lines will become:
MACHINE=custom1 bitbake foo-image
MACHINE=custom2 bitbake foobar-image
And our install task for the package can be:
do_install (){
//Some work
}
do_install_append_custom2(){
//Some more work
}