[bitbake-devel] How to prevent expansion of bitbake variables inside tasks?

Christopher Larson clarson at kergoth.com
Tue Aug 30 14:59:37 UTC 2016


On Mon, Aug 29, 2016 at 7:12 PM, Andre McCurdy <armccurdy at gmail.com> wrote:

> Say I want to create a do_install() task which does:
>
>   do_install() {
>     echo '${BP} was ${BP}' > ${D}/test
>   }
>
> but I don't want first ${BP} bitbake variable to be expanded. ie after
> the task has run I want ${D}/test to contain the string "${BP} was
> foo-1.0".
>
> What's the recommended way to escape the first ${BP} in do_install()?
>

Sadly this was an oversight when the file format was originally created, so
there's no real way to escape the variable reference to make bitbake not
expand it. There are workarounds, of course. You could do some or all of
the work in python rather than shell, since python functions don't get
their variable references of that sort expanded, for example, or you could
construct the output / break up the reference, i.e. echo '$' >, echo '{BP}'
>, or easier, use printf to do it with format strings, i.e. printf '${%s}
was ${%s}\n' BP BP >${D}/test.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/bitbake-devel/attachments/20160830/24be44da/attachment-0002.html>


More information about the bitbake-devel mailing list