diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2017-06-27 17:33:38 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-06 14:38:14 +0100 |
commit | 158575af9d0ab08a45eb307254bacc147e1e28ab (patch) | |
tree | 1c26db86495b40a656189de536dad8180b7b73e0 /scripts/lib/compatlayer | |
parent | 4c75c1e832609314d4323980792110675f707cf9 (diff) | |
download | poky-158575af9d0ab08a45eb307254bacc147e1e28ab.tar.gz |
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: 4afb7c3c505a4d21906f07f88c966b794a968cbc)
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/compatlayer')
-rw-r--r-- | scripts/lib/compatlayer/__init__.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/lib/compatlayer/__init__.py b/scripts/lib/compatlayer/__init__.py index e35f8c0d32..eaae4e534f 100644 --- a/scripts/lib/compatlayer/__init__.py +++ b/scripts/lib/compatlayer/__init__.py | |||
@@ -4,6 +4,7 @@ | |||
4 | # Released under the MIT license (see COPYING.MIT) | 4 | # Released under the MIT license (see COPYING.MIT) |
5 | 5 | ||
6 | import os | 6 | import os |
7 | import re | ||
7 | import subprocess | 8 | import subprocess |
8 | from enum import Enum | 9 | from enum import Enum |
9 | 10 | ||
@@ -189,10 +190,22 @@ def add_layer_dependencies(bblayersconf, layer, layers, logger): | |||
189 | if layer_depends is None: | 190 | if layer_depends is None: |
190 | return False | 191 | return False |
191 | else: | 192 | else: |
193 | # Don't add a layer that is already present. | ||
194 | added = set() | ||
195 | output = check_command('Getting existing layers failed.', 'bitbake-layers show-layers').decode('utf-8') | ||
196 | for layer, path, pri in re.findall(r'^(\S+) +([^\n]*?) +(\d+)$', output, re.MULTILINE): | ||
197 | added.add(path) | ||
198 | |||
192 | for layer_depend in layer_depends: | 199 | for layer_depend in layer_depends: |
193 | logger.info('Adding layer dependency %s' % layer_depend['name']) | 200 | name = layer_depend['name'] |
201 | path = layer_depend['path'] | ||
202 | if path in added: | ||
203 | continue | ||
204 | else: | ||
205 | added.add(path) | ||
206 | logger.info('Adding layer dependency %s' % name) | ||
194 | with open(bblayersconf, 'a+') as f: | 207 | with open(bblayersconf, 'a+') as f: |
195 | f.write("\nBBLAYERS += \"%s\"\n" % layer_depend['path']) | 208 | f.write("\nBBLAYERS += \"%s\"\n" % path) |
196 | return True | 209 | return True |
197 | 210 | ||
198 | def add_layer(bblayersconf, layer, layers, logger): | 211 | def add_layer(bblayersconf, layer, layers, logger): |