summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/models.py
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-05-26 16:12:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-15 08:35:04 +0100
commitdd764003ea2cb9449f838146183f17873a902e48 (patch)
treea0824c31ae2049a1784d91a8e1d7fe8735e3c6b7 /bitbake/lib/toaster/orm/models.py
parent89433a35e6e21a978cef3e41e24d87024ed9a6ed (diff)
downloadpoky-dd764003ea2cb9449f838146183f17873a902e48.tar.gz
bitbake: toaster: Rework displaying package dependencies across Toaster
After porting the build table to a unified mechanism for showing dependencies in tables it highlighted that the dependencies selected to be shown were un-filtered. i.e. all dependencies from all contexts were shown. The context for a package's dependencies is based on the target that they were installed onto, or if not installed then a "None" target. Depending on where the template for the dependencies are show we need to switch this target which is why a filter and utility function on the model is added. Additionally to use the same templates in the build analysis we also need to optionally add links to the build data for the packages being displayed as dependencies. Customising a Custom image recipes may or may not have a target depending on whether they have been built or not, if not we do a best effort at getting the dependencies by using the last known target on that package to get the dependency information. [YOCTO #9676] (Bitbake rev: 31e7c26cc31a7c8c78c1464fa01581683bfd2965) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r--bitbake/lib/toaster/orm/models.py61
1 files changed, 50 insertions, 11 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 25bc1dbe15..caad2afe81 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -862,31 +862,70 @@ class CustomImagePackage(Package):
862 related_name='appends_set') 862 related_name='appends_set')
863 863
864 864
865
866class Package_DependencyManager(models.Manager): 865class Package_DependencyManager(models.Manager):
867 use_for_related_fields = True 866 use_for_related_fields = True
867 TARGET_LATEST = "use-latest-target-for-target"
868 868
869 def get_queryset(self): 869 def get_queryset(self):
870 return super(Package_DependencyManager, self).get_queryset().exclude(package_id = F('depends_on__id')) 870 return super(Package_DependencyManager, self).get_queryset().exclude(package_id = F('depends_on__id'))
871 871
872 def get_total_source_deps_size(self): 872 def for_target_or_none(self, target):
873 """ Returns the total file size of all the packages that depend on 873 """ filter the dependencies to be displayed by the supplied target
874 thispackage. 874 if no dependences are found for the target then try None as the target
875 """ 875 which will return the dependences calculated without the context of a
876 return self.all().aggregate(Sum('depends_on__size')) 876 target e.g. non image recipes.
877 877
878 def get_total_revdeps_size(self): 878 returns: { size, packages }
879 """ Returns the total file size of all the packages that depend on
880 this package.
881 """ 879 """
882 return self.all().aggregate(Sum('package_id__size')) 880 package_dependencies = self.all_depends().order_by('depends_on__name')
883 881
882 if target is self.TARGET_LATEST:
883 installed_deps =\
884 package_dependencies.filter(~Q(target__target=None))
885 else:
886 installed_deps =\
887 package_dependencies.filter(Q(target__target=target))
888
889 packages_list = None
890 total_size = 0
891
892 # If we have installed depdencies for this package and target then use
893 # these to display
894 if installed_deps.count() > 0:
895 packages_list = installed_deps
896 total_size = installed_deps.aggregate(
897 Sum('depends_on__size'))['depends_on__size__sum']
898 else:
899 new_list = []
900 package_names = []
901
902 # Find dependencies for the package that we know about even if
903 # it's not installed on a target e.g. from a non-image recipe
904 for p in package_dependencies.filter(Q(target=None)):
905 if p.depends_on.name in package_names:
906 continue
907 else:
908 package_names.append(p.depends_on.name)
909 new_list.append(p.pk)
910 # while we're here we may as well total up the size to
911 # avoid iterating again
912 total_size += p.depends_on.size
913
914 # We want to return a queryset here for consistency so pick the
915 # deps from the new_list
916 packages_list = package_dependencies.filter(Q(pk__in=new_list))
917
918 return {'packages': packages_list,
919 'size': total_size}
884 920
885 def all_depends(self): 921 def all_depends(self):
886 """ Returns just the depends packages and not any other dep_type """ 922 """ Returns just the depends packages and not any other dep_type
923 Note that this is for any target
924 """
887 return self.filter(Q(dep_type=Package_Dependency.TYPE_RDEPENDS) | 925 return self.filter(Q(dep_type=Package_Dependency.TYPE_RDEPENDS) |
888 Q(dep_type=Package_Dependency.TYPE_TRDEPENDS)) 926 Q(dep_type=Package_Dependency.TYPE_TRDEPENDS))
889 927
928
890class Package_Dependency(models.Model): 929class Package_Dependency(models.Model):
891 TYPE_RDEPENDS = 0 930 TYPE_RDEPENDS = 0
892 TYPE_TRDEPENDS = 1 931 TYPE_TRDEPENDS = 1