Fixed: - set LAYERDEPENDS_openembedded-layer = "core" - $ "update.py -l meta-oe -b master" Check from web, its dependency is "openembedded-core" - Change LAYERDEPENDS_openembedded-layer = "foo" - Run "update.py -l meta-oe -b master" Check from web, its dependency is "openembedded-core and foo", this might be incorrect, now if set REMOVE_LAYER_DEPENDENCIES to true, the old dependency openembedded-core will be removed, the default is False which prints warnings to notify users.
And also the existing checking should filter(required=required), otherwise it can't work well when a layer is in both depends and recommends, this can't happen in a normal case, but it would surprise the user when this happens. Signed-off-by: Robert Yang <liezhi.y...@windriver.com> --- layerindex/utils.py | 19 ++++++++++++++++++- settings.py | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/layerindex/utils.py b/layerindex/utils.py index 186d342..5acf35f 100644 --- a/layerindex/utils.py +++ b/layerindex/utils.py @@ -88,6 +88,7 @@ def _add_dependency(var, name, layerbranch, config_data, logger=None, required=T logger.debug('Error parsing %s_%s for %s\n%s' % (var, var_name, layer_name, str(vse))) return + need_remove = None for dep, ver_list in list(dep_dict.items()): ver_str = None if ver_list: @@ -106,8 +107,14 @@ def _add_dependency(var, name, layerbranch, config_data, logger=None, required=T logger.error('Cannot resolve %s %s (version %s) for %s' % (name, dep, ver_str, layer_name)) continue + # Preparing to remove obsolete ones + if not need_remove: + need_remove = LayerDependency.objects.filter(layerbranch=layerbranch).filter(required=required).exclude(dependency=dep_layer) + else: + need_remove = need_remove.exclude(dependency=dep_layer) + # Skip existing entries. - existing = list(LayerDependency.objects.filter(layerbranch=layerbranch).filter(dependency=dep_layer)) + existing = list(LayerDependency.objects.filter(layerbranch=layerbranch).filter(required=required).filter(dependency=dep_layer)) if existing: logger.debug('Skipping %s - already a dependency for %s' % (dep, layer_name)) continue @@ -121,6 +128,16 @@ def _add_dependency(var, name, layerbranch, config_data, logger=None, required=T layerdep.required = required layerdep.save() + if need_remove: + import settings + remove_layer_dependencies = getattr(settings, 'REMOVE_LAYER_DEPENDENCIES', False) + if remove_layer_dependencies: + logger.info('Removing obsolete dependencies "%s" for layer %s' % (need_remove, layer_name)) + need_remove.delete() + else: + logger.warn('Dependencies "%s" is not in %s\'s conf/layer.conf' % (need_remove, layer_name)) + logger.warn('Either set REMOVE_LAYER_DEPENDENCIES to remove it from database or fix conf/layer.conf') + def set_layerbranch_collection_version(layerbranch, config_data, logger=None): layerbranch.collection = config_data.getVar('BBFILE_COLLECTIONS', True) ver_str = "LAYERVERSION_" diff --git a/settings.py b/settings.py index 0ecf90b..3498e7a 100644 --- a/settings.py +++ b/settings.py @@ -214,6 +214,9 @@ CORE_LAYER_NAME = "openembedded-core" # Update records older than this number of days will be deleted every update UPDATE_PURGE_DAYS = 30 +# Remove layer dependencies if it is not in conf/layer.conf +REMOVE_LAYER_DEPENDENCIES = False + # Settings for layer submission feature SUBMIT_EMAIL_FROM = 'nore...@example.com' SUBMIT_EMAIL_SUBJECT = 'OE Layerindex layer submission' -- 2.10.2 -- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto