yocto-compat-layer.py: avoid adding layers more than once

add_layer_dependencies() might get called more than once, or one of
the layer dependencies might already be present. The function should
not add layers again because doing so can cause warnings like:

  WARNING: Duplicate inclusion for .../meta-openembedded/meta-oe/conf/distro/include/meta_oe_security_flags.inc in .../meta-openembedded/meta-oe/conf/layer.conf

(From OE-Core rev: 9821cec1ca52deee444ae3ff14dc548c8312ba3c)

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Patrick Ohly 2017-06-27 17:33:38 +02:00 committed by Richard Purdie
parent 8a08f866fc
commit 7546daec4f
1 changed files with 15 additions and 2 deletions

View File

@ -4,6 +4,7 @@
# Released under the MIT license (see COPYING.MIT)
import os
import re
import subprocess
from enum import Enum
@ -189,10 +190,22 @@ def add_layer_dependencies(bblayersconf, layer, layers, logger):
if layer_depends is None:
return False
else:
# Don't add a layer that is already present.
added = set()
output = check_command('Getting existing layers failed.', 'bitbake-layers show-layers').decode('utf-8')
for layer, path, pri in re.findall(r'^(\S+) +([^\n]*?) +(\d+)$', output, re.MULTILINE):
added.add(path)
for layer_depend in layer_depends:
logger.info('Adding layer dependency %s' % layer_depend['name'])
name = layer_depend['name']
path = layer_depend['path']
if path in added:
continue
else:
added.add(path)
logger.info('Adding layer dependency %s' % name)
with open(bblayersconf, 'a+') as f:
f.write("\nBBLAYERS += \"%s\"\n" % layer_depend['path'])
f.write("\nBBLAYERS += \"%s\"\n" % path)
return True
def add_layer(bblayersconf, layer, layers, logger):