Bug 3039 - Can't add new tasks to sstate without modifying sstate.bbclass
Summary: Can't add new tasks to sstate without modifying sstate.bbclass
Status: VERIFIED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.3 M4
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard: Patch out for review
Depends on:
Blocks:
 
Reported: 2012-08-29 16:49 UTC by Jerrod Peach
Modified: 2012-11-13 13:27 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerrod Peach 2012-08-29 16:49:48 UTC
I tried to add a new task to my task graph, and that task used sstate.  The task was called do_log_srcrev, and I added the following to my bbclass to try to enable sstate:

SSTATETASKS += "do_log_srcrev"
do_log_srcrev[sstate-name] = "log-srcrev"
do_log_srcrev[sstate-inputdirs] = "${SRCREV_WORKDIR}"
do_log_srcrev[sstate-outputdirs] = "${SRCREV_INSTALL_DIR}"

python do_log_srcrev_setscene () {
        sstate_setscene(d)
}
addtask do_log_srcrev_setscene

After I inherited the class and built, I hit a nasty error that ended like this:

 File "<string>", line 1, in <module>
  File "sstate.bbclass", line 16, in sstate_checkhashes
<omitted mounds of stuff passed to the function>
KeyError: 'do_log_srcrev'

I looked over in sstate.bbclass at the top of the sstate_checkhashes() function to find the source of my problem:

       # This needs to go away, FIXME
    mapping = {
        "do_populate_sysroot" : "populate-sysroot",
        "do_populate_lic" : "populate-lic",
        "do_package_write_ipk" : "deploy-ipk",
        "do_package_write_deb" : "deploy-deb",
        "do_package_write_rpm" : "deploy-rpm",
        "do_package" : "package",
        "do_deploy" : "deploy",
    }

    for task in range(len(sq_fn)):
        sstatefile = d.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".tgz")

If I added a mapping for my task, the problem disappeared and everything worked normally.  However, I figure it shouldn't be necessary to modify the base tools in order to make my task use sstate.  If you git show 35d095c2, you should be able to see how this was added.  Can it be made to go away by using information like the sstate-name?  Without a fix for this, it would seem I'm in a situation where I can't write custom tasks without maintaining local patches for this, which is something I'm trying to avoid.
Comment 1 Richard Purdie 2012-08-31 00:00:30 UTC
Thanks for the reminder, this does need to go away, as per the comment!
Comment 3 Jerrod Peach 2012-09-12 12:27:02 UTC
(In reply to comment #2)
> Fixed in master:
> http://git.yoctoproject.org/cgit.cgi/poky/commit/
> ?id=1c64c6b3002b4a01e590263c730e22c89d869bb7

Not exactly.  As we discussed in the IRC channel 'EXTRASSTATEMAPS = "do_deploy:deploy"' should use a "+=" instead of an "=", at the very least.  Otherwise, there's no way for me to inherit a task as a part of a package and have the mapping work.  At least this way, I can add more mappings to EXTRASSTATEMAPS.

By the way, the documentation at http://www.yoctoproject.org/docs/current/poky-ref-manual/poky-ref-manual.html#shared-state says I should just be able to add my task to the SSTATETASKS variable within my bbclass file.  Is there any reason that can't work?   Do we actually need EXTRASSTATEMAPS?
Comment 4 Richard Purdie 2012-09-12 13:27:40 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Fixed in master:
> > http://git.yoctoproject.org/cgit.cgi/poky/commit/
> > ?id=1c64c6b3002b4a01e590263c730e22c89d869bb7
> 
> Not exactly.  As we discussed in the IRC channel 'EXTRASSTATEMAPS =
> "do_deploy:deploy"' should use a "+=" instead of an "=", at the very least. 
> Otherwise, there's no way for me to inherit a task as a part of a package
> and have the mapping work.  At least this way, I can add more mappings to
> EXTRASSTATEMAPS.

Fixed in master to use an append: http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=5a71f258258d4cfa6730b45f58bfe44888903683

> By the way, the documentation at
> http://www.yoctoproject.org/docs/current/poky-ref-manual/poky-ref-manual.
> html#shared-state says I should just be able to add my task to the
> SSTATETASKS variable within my bbclass file.  Is there any reason that can't
> work?   Do we actually need EXTRASSTATEMAPS?

As we discussed on IRC, it all worlks fine if your extension applies for all recipes and is included as part of the core config (INHERIT += "xxxx" for example). It the class is only included on a per recipe basis (e.g. inherit deploy), the core cannot know about the specific sstate task but this function does need to know about it. This is when EXTRASSTATEMAPS is needed.
Comment 5 Stoicescu Cornel 2012-11-13 13:27:47 UTC
Verified in master: 7e1e3066e37a458b21294e1f5cfc3ed96efd5c7c