* Question about the setVar method
@ 2013-04-25 13:08 Kuhl, Brian
2013-04-25 16:00 ` Mark Hatle
0 siblings, 1 reply; 2+ messages in thread
From: Kuhl, Brian @ 2013-04-25 13:08 UTC (permalink / raw)
To: bitbake-devel@lists.openembedded.org
[-- Attachment #1: Type: text/plain, Size: 1953 bytes --]
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?
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
[-- Attachment #2: Type: text/html, Size: 9767 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Question about the setVar method
2013-04-25 13:08 Question about the setVar method Kuhl, Brian
@ 2013-04-25 16:00 ` Mark Hatle
0 siblings, 0 replies; 2+ messages in thread
From: Mark Hatle @ 2013-04-25 16:00 UTC (permalink / raw)
To: bitbake-devel
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-25 16:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25 13:08 Question about the setVar method Kuhl, Brian
2013-04-25 16:00 ` Mark Hatle
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.