[poky] Not able to set env var from anon function

Nithyakala Sainath nithisai at gmail.com
Fri Jul 10 04:33:35 PDT 2015


Thanks Richard and Ross. That answers my question.

Nithya.

On Fri, Jul 10, 2015 at 1:38 PM, Richard Purdie <
richard.purdie at linuxfoundation.org> wrote:

> On Thu, 2015-07-09 at 17:42 +0530, Nithyakala Sainath wrote:
> > I was playing with environmental variables and datastore that I fell
> > into this situation:
> >
> > In a reccipe a.bb
> >
> > export TEMPDIR = "temp"
> >
> > python() {
> >         os.environ["TEMPDIR"] = "randomvalue"
> > }
> >
> > do_compile() {
> >         echo ${TEMPDIR }
> > }
> >
> > gives me "temp" as the answer. I was expecting "randomvalue". Can I
> > not modify the environmental variables and create new ones in anon
> > functions ?
> >
> > But d.setVar("TEMPDIR", "randomvalue") in place of os.environ does the
> > mgic. Why can't we manipulate the environmental variable using
> > os.environ ?
> >
> > In bitbake.conf, we see that we can get env vars using os.getenv.
>
> bitbake tightly controls the task execution environment. Only variables
> marked as "export" will be exported and the value used for them is that
> from the datastore. Therefore, os.environ set in anonymous python will
> simply get overwritten. You can't have one value in the datastore and
> another in the environment.
>
> As Ross points out, ${TEMPDIR} will get expanded by bitbake anyway so it
> would print the datastore value anyway.
>
> Cheers,
>
> Richard
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/poky/attachments/20150710/90e86c16/attachment.html>


More information about the poky mailing list