aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2019-02-12 18:06:27 +0800
committerRobert Yang <liezhi.yang@windriver.com>2019-02-12 18:15:25 +0800
commita5abeb20791dade2fc900ce1940b13f584a8807e (patch)
tree7b0eabd45b38514747a54b0e3fa47eeed12ec2f3
parentb8d94b5b58d4a3572ae32accb269b71d3aeb934a (diff)
downloadopenembedded-core-contrib-rbt/check.tar.gz
openembedded-core-contrib-rbt/check.tar.bz2
openembedded-core-contrib-rbt/check.zip
checklayer: Avoid adding the layer if it is already presentrbt/check
* Rename add_layer() to add_layers() so that add_layer_dependencies() can re-use it. * Avoid adding the layer if it is already present [YOCTO #13148] Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
-rw-r--r--scripts/lib/checklayer/__init__.py36
-rwxr-xr-xscripts/yocto-check-layer6
2 files changed, 20 insertions, 22 deletions
diff --git a/scripts/lib/checklayer/__init__.py b/scripts/lib/checklayer/__init__.py
index ca7863a19e..670f0eea39 100644
--- a/scripts/lib/checklayer/__init__.py
+++ b/scripts/lib/checklayer/__init__.py
@@ -196,31 +196,29 @@ 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:
- name = layer_depend['name']
- path = layer_depend['path']
+ add_layers(bblayersconf, layer_depends, logger)
+
+ return True
+
+def add_layers(bblayersconf, layers, logger):
+ # 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)
+
+ with open(bblayersconf, 'a+') as f:
+ for layer in layers:
+ logger.info('Adding layer %s' % layer['name'])
+ name = layer['name']
+ path = layer['path']
if path in added:
- continue
+ logger.info('%s is already in %s' % (name, bblayersconf))
else:
added.add(path)
- logger.info('Adding layer dependency %s' % name)
- with open(bblayersconf, 'a+') as f:
f.write("\nBBLAYERS += \"%s\"\n" % path)
return True
-def add_layer(bblayersconf, layer, layers, logger):
- logger.info('Adding layer %s' % layer['name'])
- with open(bblayersconf, 'a+') as f:
- f.write("\nBBLAYERS += \"%s\"\n" % layer['path'])
-
- return True
-
def check_command(error_msg, cmd, cwd=None):
'''
Run a command under a shell, capture stdout and stderr in a single stream,
diff --git a/scripts/yocto-check-layer b/scripts/yocto-check-layer
index 9b7e53679b..106c955251 100755
--- a/scripts/yocto-check-layer
+++ b/scripts/yocto-check-layer
@@ -22,7 +22,7 @@ import scriptpath
scriptpath.add_oe_lib_path()
scriptpath.add_bitbake_lib_path()
-from checklayer import LayerType, detect_layers, add_layer, add_layer_dependencies, get_signatures
+from checklayer import LayerType, detect_layers, add_layers, add_layer_dependencies, get_signatures
from oeqa.utils.commands import get_bb_vars
PROGNAME = 'yocto-check-layer'
@@ -157,7 +157,7 @@ def main():
layers_tested = layers_tested + 1
continue
- if any(map(lambda additional_layer: not add_layer(bblayersconf, additional_layer, dep_layers, logger),
+ if any(map(lambda additional_layer: not add_layers(bblayersconf, [additional_layer], logger),
additional_layers)):
logger.info('Skipping %s due to missing additional layers.' % layer['name'])
results[layer['name']] = None
@@ -179,7 +179,7 @@ def main():
continue
td['machines'] = args.machines
- if not add_layer(bblayersconf, layer, dep_layers, logger):
+ if not add_layers(bblayersconf, [layer], logger):
logger.info('Skipping %s ???.' % layer['name'])
results[layer['name']] = None
results_status[layer['name']] = 'SKIPPED (Unknown)'