1
votes

I have a layer with recipes that is compatible with rocko. I'd like to add compatibility for thud. LAYERSERIES_COMPAT_layer supports a list, so supporting more than one release with a layer seems to be intended.

Thud contains some version bumps to libraries that break compatibility. An example would be protobuf-3.6, which contains incompatible API changes to the earlier version used in rocko.

For all packages in the layer, I have patches for their sources that make them compatible with the new API versions (only).

Currently, there is a culture of creating different branches (or even forks) of meta-layers in order to support different library versions. This causes heavy fragmentation and deviation between the projects and departments.

If I can create recipes that work independent of, for example, the exact version of protobuf used in a build, then I can merge back some of those forks and branches and maintain one repo.

  • I tried some approach with conditional .bbappend, but couldn't find a way to do it. There seems to be no equivalent for COMPATIBLE_MACHINE, for example, that I could use to differentiate between releases.

  • I also tried an approach of conditionally patching the sources depending on actual PV of a dependency. Basically trying to do what is described in the following snipped of recipe pseudo code:

DEPENDS += "protobuf"
SRC_URI = "git://github.com/foo/bar;"

if ${protobuf_PV} larger_or_equal "3.6.0"
  SRC_URI_append = " file://replace_protobuf_scoped_ptr.patch"
endif

I found an existing answer here which made me doubt that this is possible: How can I reference/find the ${PV} of one recipe in another recipe in Yocto/Bitbake?

So, what mechanisms, if any, does bitbake provide to help me make a recipe compatible with different versions of dependencies in general, and with different yocto releases in particular?

1

1 Answers

4
votes

You can indeed use multiple compatible versions in LAYERSERIES_COMPAT_layer, see here for example. It's what Poky do when master branch becomes a new version, and set compatibity for current and next simultaneously.

Generally, we use same branching model as Yocto meta layers, so one branch for rockoand one branch for thud.

In your case, what you can do is having a small layer with Yocto branching model, that will only configure PREFERRED_VERSION for recipes that are different between rocko and thud, and another global layer with every recipes. You can also create two distros for each Yocto version and use overrides.

Finally you can try the following pattern:

SRC_URI += "${@bb.utils.contains("DISTRO_CODENAME", "thud", " file://replace_protobuf_scoped_ptr.patch ", "", d)}"