patchyocto-recipe

How to SRC_URI:append per $MACHINE


I have a yocto native recipe that should apply a different patch to the source code depending on the target ${MACHINE} that it bitbakes for. The folder struct looks like this:

recipe-folder
  |-files
  |   |-machine1
  |   |     |-p1.patch
  |   |
  |   |-machine2
  |   |     |-p2.patch
  |   |
  |   |-common.patch
  |
  |-recipe-native_0.1.bb

then the important contents of the recipe are

inherit native
SRC_URI = <some git repo>
SRC_URI:append = "file://common.patch"
SRC_URI:append:machine1 = "file://p1.patch"
SRC_URI:append:machine2 = "file://p2.patch"

do_configure() {
    ./configure --static
}

do_compile() {
    oe_runmake tool1
}

do_install() {
    # Default sigtrace installation directory
    install -d ${D}${bindir}
    install -m 0755 ${S}/output/linux/${release}/tool1 ${D}/${bindir}/tool1
}

The above does not work - only the common patch gets applied.

I also tried

SRC_URI = <some git repo>
SRC_URI:append = "\
    file://common.patch \
    file://p1.patch \
    file://p2.patch \
"

which applies all patches in all targets. Also not what I aim for.

Am I using the command wrong? Is there another way to achieve this?


Solution

  • You should try something like this:

    SRC_URI:append = "file://common.patch"
    SRC_URI:append:machine1 = "file://machine1/p1.patch"
    SRC_URI:append:machine2 = "file://machine2/p2.patch"
    

    The filename you specify within the URL can be either an absolute or relative path to a file.

    More details can be found here:

    https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-fetching.html#local-file-fetcher-file

    https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-ref-variables.html#term-FILESPATH