Search code examples
recipebitbake

Using bitbake is it possible to have a different do_install for a package based on the target image?


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?


Solution

  • 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
    }