summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-10-02 11:05:12 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-10-12 14:38:54 +0100
commitbd2ec775106cb3122a144ac74c2bafd95345bd24 (patch)
tree390c65f66de248c25adb4611e8044dd96ed80ffc /bitbake/lib
parent05594f86366d97975501ffd84886d37f0c72e238 (diff)
downloadpoky-bd2ec775106cb3122a144ac74c2bafd95345bd24.tar.gz
bitbake: toaster: implement API to get full list of deps
Implemented Layer_Version.get_alldeps API to recursively get full list of dependencies for the layer. Dependencies that are already in the project are filtered out from the result. Result list of Layer_Version objects is sorted by layer name for UI to look consistent. This API is going to be used to show amount and list of dependencies for the layer in the list of compatible layers for the project. (Bitbake rev: 7d853a3054a9ae3d18eb6f5bc13ba27d2795c31a) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/orm/models.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 9851c92b71..9a5942b75e 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1177,6 +1177,25 @@ class Layer_Version(models.Model):
1177 def get_detailspage_url(self, project_id): 1177 def get_detailspage_url(self, project_id):
1178 return reverse('layerdetails', args=(project_id, self.pk)) 1178 return reverse('layerdetails', args=(project_id, self.pk))
1179 1179
1180 def get_alldeps(self, project_id):
1181 """Get full list of unique layer dependencies."""
1182 def gen_layerdeps(lver, project):
1183 for ldep in lver.dependencies.all():
1184 yield ldep.depends_on
1185 # get next level of deps recursively calling gen_layerdeps
1186 for subdep in gen_layerdeps(ldep.depends_on, project):
1187 yield subdep
1188
1189 project = Project.objects.get(pk=project_id)
1190 result = []
1191 projectlvers = [player.layercommit for player in project.projectlayer_set.all()]
1192 for dep in gen_layerdeps(self, project):
1193 # filter out duplicates and layers already belonging to the project
1194 if dep not in result + projectlvers:
1195 result.append(dep)
1196
1197 return sorted(result, key=lambda x: x.layer.name)
1198
1180 def __unicode__(self): 1199 def __unicode__(self):
1181 return "%d %s (VCS %s, Project %s)" % (self.pk, str(self.layer), self.get_vcs_reference(), self.build.project if self.build is not None else "No project") 1200 return "%d %s (VCS %s, Project %s)" % (self.pk, str(self.layer), self.get_vcs_reference(), self.build.project if self.build is not None else "No project")
1182 1201