How do I overwrite multiple files with one recipe in Yocto

I have a layer that I am writing for Yocto. I want to have two configurations for the hardware. One would be a standard generic config, one would be a use case specific config, and I can’t figure out how to do this.

Here is an example of what I want. let’s say in the generic-image recipe, I want network interfaces to be configured for DHCP. And in the use-case-image recipe I want it configured for a static IP.

I could write a bbappend to override the standard the file for init-ifupdown recipe, but that would change the file for all instances that use the init-ifupdown recipe. I only want the file changed when building a use-case-image recipe and not generic-image.

And to take this 1 step further. I have about a dozen files that I want to replace in the rootfs. I don’t want to have to write a bbappend for each and every one.

Any idea how to write a recipe that will replace a few files without getting the ” that file is already provided by package” error? And not have to write a dozen bbappend files?

I know in buildroot this is easily done with an overlay, unfortunately I am stuck with yocto.


Asked By: AllenKll


The solution is that this can not happen.

My research led me to discover that this has been called “flavoring” of a build. And Yocto is not created in such a way to allow this to happen at this time. And as far as I can tell it is not going to happen in the near future.

There have been some independent efforts to do this using a single ‘.inc’ file that is included in any affected recipes that will allow the recipe to choose it path to completing its package, but the data inside this “.inc” file needs to be manipulated manually using tools outside the yocto system.

here is a thread I found on the topic in the yocto mail list:

As for the multiple file replacements in one recipe, I have also found that this is also not possible, unless I believe there is a disabling of the “insanity check” perhaps, either way I have not figured this out and am dropping work on it.

Answered By: AllenKll

To achieve what you are talking about, you can use PREFERRED_VERSION within an appropriate distro .conf file to vary with your build based on a package version. A package version can then be created to match the PREFERRED_VERSION in your distro .conf files. This allows the same project to produce varying images with different configurations, etc. based on the distro being built. Incorporation into an existing project will depend on the structure of said project, but this is your general direction.

Answered By: FkBrd

One method I use is to create a new machine conf file in my layer. This allows me to use OVERRIDE syntax for different machines.

        -- default gets copied to WORKDIR
        -- gets copied to WORKDIR for newmachine only
      SRC_URI += "file://specfic.conf"
Answered By: mmitchel
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.