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

Andre McCurdy armccurdy at gmail.com
Tue Aug 30 20:40:59 UTC 2016


On Tue, Aug 30, 2016 at 7:59 AM, Christopher Larson <clarson at kergoth.com> wrote:
>
> 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.

My solution up to now has been:

  echo '{BP}' | sed 's|^|$|'

but printf looks a little cleaner. Thanks.

> --
> Christopher Larson
> clarson at kergoth dot com
> Founder - BitBake, OpenEmbedded, OpenZaurus
> Maintainer - Tslib
> Senior Software Engineer, Mentor Graphics



More information about the bitbake-devel mailing list