Bug 2222 - [yocto-bsp] fails to create bsp with json file
Summary: [yocto-bsp] fails to create bsp with json file
Status: VERIFIED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.2 M4
Assignee: Tom Zanussi
QA Contact:
URL:
Whiteboard: (1.2)(patch submitted for review)
Depends on:
Blocks: 1610
  Show dependency tree
 
Reported: 2012-04-01 06:52 UTC by Jiajun Xu
Modified: 2012-04-23 07:42 UTC (History)
6 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 Jiajun Xu 2012-04-01 06:52:56 UTC
tree/branch: poky/1.2 M4
commit: da6233ea034f35eff59306fdad31f318c340c359

With 1.2 M4, I could create bsp layer with yocto-bsp command by manual. If I use a predefined json file with parameters defined, it will report error as below:
###########

Traceback (most recent call last):
  File "/home/jxu49/osel/m4/scripts/yocto-bsp", line 137, in <module>
    ret = main()
  File "/home/jxu49/osel/m4/scripts/yocto-bsp", line 132, in main
    invoke_subcommand(args, parser, yocto_bsp_help_usage, subcommands)
  File "/home/jxu49/osel/m4/scripts/lib/bsp/help.py", line 73, in invoke_subcommand
    subcommands.get(args[0], subcommand_error)[0](args[1:], usage)
  File "/home/jxu49/osel/m4/scripts/yocto-bsp", line 76, in yocto_bsp_create_subcommand
    yocto_bsp_create(machine, karch, scripts_path, bsp_output_dir, options.codedump, options.properties_file)
  File "/home/jxu49/osel/m4/scripts/lib/bsp/engine.py", line 1244, in yocto_bsp_create
    run_program_lines(program_lines, codedump)
  File "<string>", line 287
     of.write("\n")
###########

The file I used for testing as below:
##########
{"kernel_choice":"linux-yocto_3.2","use_default_kernel":"n","keyboard":"y","qemuarch":"x86","smp_linux_yocto_3_2":"y","touchscreen":"n","new_kbranch_linux_yocto_3_2":"y","base_kbranch_linux_yocto_3_2":"standard\/default\/base"}
##########
Comment 1 Tom Zanussi 2012-04-10 14:43:42 UTC
These json properties were from an earlier version of yocto-bsp - some details were changed in the committed version and those properties will no longer work.

Specifically, some properties that previously were uniquely named no longer are, such as new_kbranch_linux_yocto_3_2, which is now just new_kbranch, but nonetheless still need to be qualified in order to be set.  The same thing is the case for listing specific property values.

I need to update the interface in both these cases to allow for arbitrary nesting of properties using a dot notation in the properties themselves e.g.

linux_yocto_2.3.new_kbranch

Until this is changed, the JSON interface won't work for some properties such as in this case.
Comment 2 Tom Zanussi 2012-04-11 19:50:20 UTC
The following branch contains a fix for this bug, which also fixes the support for 'yocto-bsp list property' (see details below).

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/2222-fix

I won't submit it until Jessica verifies that it supplies what she needs for the ADT integration.

I tested it with the following new JSON file:

{"kernel_choice":"linux-yocto_3.2","use_default_kernel":"n","keyboard":"y","qemuarch":"i386","smp":"y","touchscreen":"n","need_new_kbranch":"y","new_kbranch":"standard/default/base"}

The new 'yocto-bsp list property' support accounts for the change in the way variables are named.  Looking at the output of 'yocto-bsp list properties' you see that some input properties are contained within a top-level 'property'.  For example, the 'new_kbranch' input property is contained within the "if kernel_choice == "linux-yocto-rt_3.0":" 'property'.  Similarly, the same-named 'new_kbranch' property is also listed under other "if kernel_choice == ..." properties.

"if kernel_choice == "linux-yocto-rt_3.0":" : {
    "smp" : {
        "default" : y
        "msg" : Do you need SMP support? (y/n)
        "type" : boolean
        "prio" : 30
        "filename" : /usr/local/dev/yocto/yocto-bsp-fix/scripts/lib/bsp/substrate/target/arch/qemu/recipes-kernel/linux/{{ if kernel_choice == "linux-yocto-rt_3.0": }} linux-yocto-rt_3.0.bbappend
    }
    "new_kbranch" : {
        "prio" : 20
        "default" : yocto/standard/preempt-rt
        "nameappend" : mips
        "filename" : /usr/local/dev/yocto/yocto-bsp-fix/scripts/lib/bsp/substrate/target/arch/qemu/recipes-kernel/linux/{{ if kernel_choice == "linux-yocto-rt_3.0": }} linux-yocto-rt_3.0.bbappend
        "msg" : Please choose a machine branch to base this BSP on:
        "type" : choicelist
        "gen" : bsp.kernel.all_branches
    }

"if kernel_choice == "linux-yocto_3.2":" : {
    "smp" : {
        "default" : y
        "msg" : Do you need SMP support? (y/n)
        "type" : boolean
        "prio" : 30
        "filename" : /usr/local/dev/yocto/yocto-bsp-fix/scripts/lib/bsp/substrate/target/arch/qemu/recipes-kernel/linux/{{ if kernel_choice == "linux-yocto_3.2": }} linux-yocto_3.2.bbappend
    }
    "new_kbranch" : {
        "prio" : 20
        "default" : standard/default
        "nameappend" : mips
        "filename" : /usr/local/dev/yocto/yocto-bsp-fix/scripts/lib/bsp/substrate/target/arch/qemu/recipes-kernel/linux/{{ if kernel_choice == "linux-yocto_3.2": }} linux-yocto_3.2.bbappend
        "msg" : Please choose a machine branch to base this BSP on:
        "type" : choicelist
        "gen" : bsp.kernel.all_branches
    }

In order to allow the contained properties to be specified unambiguously, the standard '.' notation used in JSON is supported.  For example:

$ yocto-bsp list i386 property "if kernel_choice == \"linux-yocto-rt_3.2\".new_kbranch

To make it easier to use, a subset of the top-level property can be specified instead (it will return the first match, so should be unique, which the full string always would be, but here specifying just the kernel name is too):

$ yocto-bsp list i386 property \"linux-yocto-rt_3.2\".new_kbranch
Comment 3 Tom Zanussi 2012-04-11 19:54:28 UTC
(In reply to comment #2)
> The following branch contains a fix for this bug, which also fixes the support
> for 'yocto-bsp list property' (see details below).
> 
> http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/2222-fix
> 
> I won't submit it until Jessica verifies that it supplies what she needs for
> the ADT integration.
> 
> I tested it with the following new JSON file:
> 
> {"kernel_choice":"linux-yocto_3.2","use_default_kernel":"n","keyboard":"y","qemuarch":"i386","smp":"y","touchscreen":"n","need_new_kbranch":"y","new_kbranch":"standard/default/base"}
> 
> The new 'yocto-bsp list property' support accounts for the change in the way
> variables are named.  Looking at the output of 'yocto-bsp list properties' you
> see that some input properties are contained within a top-level 'property'. 
> For example, the 'new_kbranch' input property is contained within the "if
> kernel_choice == "linux-yocto-rt_3.0":" 'property'.  Similarly, the same-named
> 'new_kbranch' property is also listed under other "if kernel_choice == ..."
> properties.
> 
> "if kernel_choice == "linux-yocto-rt_3.0":" : {
>     "smp" : {
>         "default" : y
>         "msg" : Do you need SMP support? (y/n)
>         "type" : boolean
>         "prio" : 30
>         "filename" :
> /usr/local/dev/yocto/yocto-bsp-fix/scripts/lib/bsp/substrate/target/arch/qemu/recipes-kernel/linux/{{
> if kernel_choice == "linux-yocto-rt_3.0": }} linux-yocto-rt_3.0.bbappend
>     }
>     "new_kbranch" : {
>         "prio" : 20
>         "default" : yocto/standard/preempt-rt
>         "nameappend" : mips
>         "filename" :
> /usr/local/dev/yocto/yocto-bsp-fix/scripts/lib/bsp/substrate/target/arch/qemu/recipes-kernel/linux/{{
> if kernel_choice == "linux-yocto-rt_3.0": }} linux-yocto-rt_3.0.bbappend
>         "msg" : Please choose a machine branch to base this BSP on:
>         "type" : choicelist
>         "gen" : bsp.kernel.all_branches
>     }
> 
> "if kernel_choice == "linux-yocto_3.2":" : {
>     "smp" : {
>         "default" : y
>         "msg" : Do you need SMP support? (y/n)
>         "type" : boolean
>         "prio" : 30
>         "filename" :
> /usr/local/dev/yocto/yocto-bsp-fix/scripts/lib/bsp/substrate/target/arch/qemu/recipes-kernel/linux/{{
> if kernel_choice == "linux-yocto_3.2": }} linux-yocto_3.2.bbappend
>     }
>     "new_kbranch" : {
>         "prio" : 20
>         "default" : standard/default
>         "nameappend" : mips
>         "filename" :
> /usr/local/dev/yocto/yocto-bsp-fix/scripts/lib/bsp/substrate/target/arch/qemu/recipes-kernel/linux/{{
> if kernel_choice == "linux-yocto_3.2": }} linux-yocto_3.2.bbappend
>         "msg" : Please choose a machine branch to base this BSP on:
>         "type" : choicelist
>         "gen" : bsp.kernel.all_branches
>     }
> 
> In order to allow the contained properties to be specified unambiguously, the
> standard '.' notation used in JSON is supported.  For example:
> 
> $ yocto-bsp list i386 property "if kernel_choice ==
> \"linux-yocto-rt_3.2\".new_kbranch
> 
> To make it easier to use, a subset of the top-level property can be specified
> instead (it will return the first match, so should be unique, which the full
> string always would be, but here specifying just the kernel name is too):
> 
> $ yocto-bsp list i386 property \"linux-yocto-rt_3.2\".new_kbranch

Just one note that I forgot - because the property separator is '.', if you have a portion of the property that itself contains a '.', you need to put that part of it in double quotes.
Comment 4 Jessica 2012-04-11 21:40:43 UTC
Modified Eclipse plug-in according to the latest changes and everything works, from query property value to using JSON file create BSP
Comment 6 Jiajun Xu 2012-04-23 07:42:25 UTC
I tested denzil branch that the bug is fixed.