summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-04-06 17:15:52 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:53 +1200
commit009adcb8df8dabf5b459a98f35f3d1a829449a36 (patch)
tree5c1bbf872879373772f490cac5d91082f09f28e7
parenta6aaa5c8efef3009086032c7e54a519714940a1b (diff)
downloadopenembedded-core-contrib-009adcb8df8dabf5b459a98f35f3d1a829449a36.tar.gz
openembedded-core-contrib-009adcb8df8dabf5b459a98f35f3d1a829449a36.tar.bz2
openembedded-core-contrib-009adcb8df8dabf5b459a98f35f3d1a829449a36.zip
models: implement layerindex method to get recursive dependencies
It would be useful in some scenarios to get the complete list of recursive dependencies for a layer, so add a function to do that. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--layerindex/models.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/layerindex/models.py b/layerindex/models.py
index ac2967bb2c..af6db374c6 100644
--- a/layerindex/models.py
+++ b/layerindex/models.py
@@ -280,6 +280,24 @@ class LayerBranch(models.Model):
def get_recommends(self):
return self.dependencies_set.filter(required=False)
+ def get_recursive_dependencies(self, required=True, include_self=False):
+ deplist = []
+ def recurse_deps(layerbranch):
+ deplist.append(layerbranch)
+ if required:
+ dep_set = layerbranch.dependencies_set.filter(required=True)
+ else:
+ dep_set = layerbranch.dependencies_set.all()
+ for dep in dep_set:
+ deplayerbranch = dep.dependency.get_layerbranch(layerbranch.branch.name)
+ if deplayerbranch and deplayerbranch not in deplist:
+ recurse_deps(deplayerbranch)
+ recurse_deps(self)
+ if include_self:
+ return deplist
+ else:
+ return deplist[1:]
+
class LayerMaintainer(models.Model):
MAINTAINER_STATUS_CHOICES = (
('A', 'Active'),