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

Peter Kjellerstedt peter.kjellerstedt at axis.com
Tue Sep 6 08:57:27 UTC 2016


> -----Original Message-----
> From: bitbake-devel-bounces at lists.openembedded.org [mailto:bitbake-
> devel-bounces at lists.openembedded.org] On Behalf Of Andre McCurdy
> Sent: den 30 augusti 2016 22:41
> To: Christopher Larson
> Cc: bitbake-devel
> Subject: Re: [bitbake-devel] How to prevent expansion of bitbake
> variables inside tasks?
> 
> 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.

Why complicate it? This should work:

	echo '$''{BP} was ${BP}' > ${D}/test

//Peter




More information about the bitbake-devel mailing list