On 06/21/2017 05:06 PM, Paul Eggleton wrote:
On Tuesday, 13 June 2017 4:36:44 AM CEST Robert Yang wrote:
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 is
    wrong, it should be "foo" only, this patch can fix the problem.

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 | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/layerindex/utils.py b/layerindex/utils.py
index 442b121..b7165d0 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_delete = 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_delete:
+            need_delete =
LayerDependency.objects.filter(layerbranch=layerbranch).filter(required=required).exclude(dependency=dep_layer)
+        else:
+            need_delete = need_delete.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,10 @@ def _add_dependency(var, name, layerbranch,
config_data, logger=None, required=T
         layerdep.required = required
         layerdep.save()

+    if need_delete:
+        logger.debug("Removing obsolete dependencies: %s" % need_delete)
+        need_delete.delete()
+
 def set_layerbranch_collection_version(layerbranch, config_data,
logger=None):
     layerbranch.collection = config_data.getVar('BBFILE_COLLECTIONS', True)
     ver_str = "LAYERVERSION_"

So I do see the need to clear out old dependency values when your list of
dependencies is coming entirely from LAYERDEPENDS, however if you have only
manually added dependencies and LAYERDEPENDS is not complete (as is often the
case in the OE layer index), will this automatically remove those? If so I

The dependencies will be removed if it is not in conf/layer.conf.

think we're going to have to come up with some mechanism to avoid that.
Probably the easiest one would be to avoid touching the dependencies unless
LAYERDEPENDS actually changes. Of course if that means we're going to store
the previous LAYERDEPENDS value somewhere to compare to, we'd need to avoid it
triggering initially when none of those values are set.

Why not fix conf/layer.conf rather than fix it from database ? If
conf/layer.conf is wrong, we would meet problems elsewhere. The database
should obey local.conf when mismatches, otherwise, this would confuse
users a lot when they want to update LAYERDEPENDS.

I'm glad to fix oe-classic's LAYERDEPENDS issues if they are wrong.

// Robert


Cheers,
Paul

--
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to