[bitbake-devel] Question about the setVar method
Mark Hatle
mark.hatle at windriver.com
Thu Apr 25 16:00:10 UTC 2013
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 at lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/bitbake-devel
>
More information about the bitbake-devel
mailing list