Bug 9972

Summary: recipetool: setvar fails on empty bbappend file
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Paul Eggleton <bluelightning>
Component: Scripts and ToolsAssignee: Paul Eggleton <bluelightning>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: ross.burton, sgw
Version: 2.0   
Target Milestone: 2.2 M3   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Paul Eggleton 2016-07-19 09:22:06 UTC
If you use recipetool setvar on an empty bbappend file you get a traceback:

--------- snip ---------
$ recipetool newappend ../meta-poky kbd
../meta-poky/recipes-core/kbd/kbd_2.0.3.bbappend
$ recipetool setvar -r ../meta-poky/recipes-core/kbd/kbd_2.0.3.bbappend SOMEVAR "value"

Traceback (most recent call last):
  File "/home/paul/poky/poky/scripts/recipetool", line 117, in <module>
    ret = main()
  File "/home/paul/poky/poky/scripts/recipetool", line 108, in main
    ret = args.func(args)
  File "/home/paul/poky/poky/scripts/lib/recipetool/setvar.py", line 52, in setvar
    patches = [oe.recipeutils.patch_recipe_file(args.recipefile, varvalues, patch=args.patch)]
  File "/home/paul/poky/poky/meta/lib/oe/recipeutils.py", line 279, in patch_recipe_file
    _, tolines = patch_recipe_lines(fromlines, values)
  File "/home/paul/poky/poky/meta/lib/oe/recipeutils.py", line 261, in patch_recipe_lines
    if tolines[-1].strip() != '':
IndexError: list index out of range
--------- snip ---------

If the file has one or more lines no error is produced.