Fix layerconfparser lifetime handling

* Setting of the object has to be before the try: or otherwise the
  finally block can get called if that doesn't succeed with the result
  that the layerconfparser object won't have a value, which will
  trigger an exception
* We shouldn't be using the config_data object after shutting down
  tinfoil, so avoid doing that

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2017-01-16 09:58:25 +13:00
parent 15748efcc1
commit a5a3c47b69
2 changed files with 5 additions and 5 deletions

View File

@ -375,14 +375,14 @@ def main():
layerdep.layerbranch = layerbranch
layerdep.dependency = core_layer
layerdep.save()
try:
layerconfparser = LayerConfParse(logger=logger)
try:
config_data = layerconfparser.parse_layer(layerbranch, layerdir)
finally:
layerconfparser.shutdown()
if config_data:
utils.add_dependencies(layerbranch, config_data, logger=logger)
utils.add_recommends(layerbranch, config_data, logger=logger)
finally:
layerconfparser.shutdown()
# Get some extra meta-information
readme_files = glob.glob(os.path.join(layerdir, 'README*'))

View File

@ -266,8 +266,8 @@ def main():
# dependencies that may have been missed. Note that creating the
# dependencies is a best-effort and continues if they are not found.
for branch in branches:
try:
layerconfparser = LayerConfParse(logger=logger, bitbakepath=bitbakepath)
try:
for layer in layerquery:
layerbranch = layer.get_layerbranch(branch)