Bitbake recipe not applying patch as expected

你离开我真会死。 提交于 2019-12-03 01:53:50
aicastell

My variable ${S} was re-defined inside my recipe with this content:

S = "${WORKDIR}/${PN}-${PV}"

But the fetchers downloads my.patch and src/ inside ${WORKDIR}, not inside ${S} directory, so:

${WORKDIR}/my.path
${WORKDIR}/src.tar.gz

And tarball was also extracted inside ${WORKDIR}

${WORKDIR}/src/

The fix was setting "patchdir" attribute properly, replacing ${S} by ${WORKDIR}

SRC_URI = " \
    file://my.patch;patchdir=${WORKDIR}/src \
    file://src.tar.gz \
"

That is already working!

Though the author provided their own solution to their distinct problem, this question is the first result that comes up when searching for solutions to the "can't find file to patch" error in Yocto builds, so I want to share a solution for a different situation that produces the same error output.

In my case, I was trying to use a .bbappend file to apply an override controlled patch to a pre-existing recipe, and was receiving the "can't find file to patch" error. The thread at https://community.nxp.com/thread/474138 identified the solution: using the '_append' syntax instead of the '+=' syntax. That is, use:

SRC_URI_append_machineoverride = " file://my.patch"

Instead of

SRC_URI_machineoverride += "file://my.patch"

Note that the use of '_append' requires a leading space (contra the trailing space noted in the thread linked above). I have not yet investigated this enough to explain why this syntax is necessary, but I thought this would still be a valuable addition to the record for this question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!