All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@windriver.com>
To: <bitbake-devel@lists.openembedded.org>
Subject: Re: Question about the setVar method
Date: Thu, 25 Apr 2013 11:00:10 -0500	[thread overview]
Message-ID: <5179530A.3000202@windriver.com> (raw)
In-Reply-To: <6C486AB80682E24095E3E77A408D68F252A4D7F1@ALA-MBA.corp.ad.wrs.com>

On 4/25/13 8:08 AM, Kuhl, Brian wrote:
> I’m working on a new bitbake class which includes the following function which
> works as desired except the
>
> d.setVar( dict[cmd],retlist[0])
>
> function does not appear to have global scope, and its effects are not seen
> outside the function.
>
> How do I give this operation global scope?

Only things that run during variable loading time will get a global scope.  For 
python functions this would be the:

python() { ... }

python __anonymous() { ... }

or I believe events.  But each of these need to happen before the recipe 
building has begun.  Once the recipes are in progress, the scope becomes local. 
  If you need to share information between local scopes, then you will have to 
write out a file with the information and load it in each of the "user" 
instances.  The users will have to have a dependency on the provider.

> python rpm_spec_do_postpatch() {
>
>                 import subprocess
>
>                 dict = {'DESCRIPTION':'DESCRIPTION',
>
>                                               'LICENSE':'LICENSE',
>
>                                               'SUMMARY':'SUMMARY',
>
>                                               'URL':'HOMEPAGE' }
>
>                 harvest_spec = d.getVar('HARVEST_SPEC', True)
>
>                 if harvest_spec :
>
>                                pn = d.getVar('PN', True)
>
>                                workdir = d.getVar('WORKDIR', True)
>
>                                src_spec = d.getVar('SRCSPEC', True)
>
>                                rpm_args = d.getVar('RPM_ARGS',True)
>
>                                spec_path = os.path.join( workdir,src_spec )
>
>                                prefix = "rpm -q %s --specfile %s --qf '%%{" %
> (rpm_args,spec_path)
>
>                                postfix = "}<:>' "
>
>                                for cmd in dict:
>
>                                               cmd_str = prefix + cmd + postfix
>
>                                               retstr =
> subprocess.check_output(cmd_str, shell=True)
>
>                                               retlist = retstr.split('<:>')
>
>                                               if retlist[0]:
>
>                                                              d.setVar(
> dict[cmd],retlist[0])
>
>                                                              bb.data.update_data(d)
>
>                                                              bb.note
> ("rpm_spec_do_postpatch HARVEST_SPEC setting  %s in %s to: %s \n" %(
> (dict[cmd]),pn,retlist[0]))
>
> }
>
> Brian Kuhl
>
> Wind River
>
> kuhlenough @ skype
>
>
>
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/bitbake-devel
>




      reply	other threads:[~2013-04-25 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-25 13:08 Question about the setVar method Kuhl, Brian
2013-04-25 16:00 ` Mark Hatle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5179530A.3000202@windriver.com \
    --to=mark.hatle@windriver.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.