Bug 9603

Summary: bitbake example class uses old getVarFlag() syntax
Product: [Build System, Metadata & Runtime] BitBake Reporter: Alexe Radu <alexeRadu2007>
Component: bitbakeAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: jku, poky.bs.watcher, poky.watcher
Version: unspecified   
Target Milestone: 2.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Alexe Radu 2016-05-06 09:07:47 UTC
I have just downloaded a fresh copy of bitbake and I've been going through this tutorial: http://a4z.bitbucket.org/docs/BitBake/guide.html#_exploring_recipes_and_tasks.

When I try to list the tasks using:

bitbake -c listtasks second

I get the following error: 


radu@testy:~/work/bbtutorial/build$ bitbake -c listtasks second
Parsing recipes: 100% |####################################################################################################################| Time: 00:00:00
Parsing of 2 .bb files complete (0 cached, 2 parsed). 2 targets, 0 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
NOTE: Preparing RunQueue
NOTE: Executing RunQueue Tasks
ERROR: second-1.0-r1 do_listtasks: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_listtasks(d)
     0003:
File: '/home/radu/work/bbtutorial/build/../meta-tutorial/classes/base.bbclass', lineno: 55, function: do_listtasks
     0051:do_listtasks[nostamp] = "1"
     0052:python do_listtasks() {
     0053:	import sys
     0054:	for e in bb.data.keys(d):
 *** 0055:		if d.getVarFlag(e, 'task'):
     0056:			bb.plain("%s" % e)
     0057:}
     0058:
     0059:addtask build
Exception: TypeError: getVarFlag() takes at least 4 arguments (3 given)

ERROR: second-1.0-r1 do_listtasks: Function failed: do_listtasks
ERROR: Logfile of failure stored in: /home/radu/work/bbtutorial/build/tmp/work/second-1.0-r1/temp/log.do_listtasks.3349
ERROR: Task 0 (/home/radu/work/bbtutorial/build/../meta-tutorial/recipes-tutorial/second/second_1.0.bb, do_listtasks) failed with exit code '1'
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/radu/work/bbtutorial/build/../meta-tutorial/recipes-tutorial/second/second_1.0.bb, do_listtasks
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.


If I modify the the function do_listtasks() from base.class to:

...
if d.getVarFlag(e, 'task', False):
...

it works perfectly.

PS:
- the same problem/solution is for the "showdata()" function
- I am running ubuntu in a virtual machine
- I was at chapter 6.3 in the tutorial when this happened (so that you might recreate my project)
Comment 1 Jussi Kukkonen 2016-05-09 07:39:18 UTC
Since earlier this year getVarFlag() requires the expand parameter to be present (this is in preparation for future when expand will default to True).

So this is not a bug in bitbake or yocto but an API change. I'm not closing the bug yet since it seems the documentation is not up-to-date yet (e.g. https://www.yoctoproject.org/docs/current/bitbake-user-manual/bitbake-user-manual.html#accessing-datastore-variables-using-python).


I'll send the tutorial author an email, maybe he wants to fix that as well.
Comment 2 Alexe Radu 2016-05-09 09:14:00 UTC
The comment is not only in the documentation but also in the default base.bbclass provided by bitbake.

Problems are at line 46 and line 55. Here the old API is used.
Comment 3 Jussi Kukkonen 2016-05-09 10:22:46 UTC
I assume you mean this base.bbclass:

> home/radu/work/bbtutorial/build/../meta-tutorial/classes/base.bbclass

This file seems to be part of the tutorial you are using, not bitbake or oe-core.
Comment 4 Alexe Radu 2016-05-09 11:02:49 UTC
The base.bbclass is located in <bitbake-path>/classes that comes with the standard bitbake I cloned from the github repository.

The tutorial pointed out that I should use it which I did.
Comment 5 Jussi Kukkonen 2016-05-09 12:01:52 UTC
(In reply to comment #4)
> The base.bbclass is located in <bitbake-path>/classes that comes with the
> standard bitbake I cloned from the github repository.
> 
> The tutorial pointed out that I should use it which I did.

Ah, you copied the example class to the tutorial directory and that one is not updated. Got it, sorry for my slowness (it is monday).

Updating title.
Comment 6 Alexe Radu 2016-05-09 14:29:32 UTC
No problem.