Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id C1CE6E00DCA; Thu, 26 May 2016 08:13:25 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.220.52 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 55F04E00DDE for ; Thu, 26 May 2016 08:12:50 -0700 (PDT) Received: by mail-pa0-f52.google.com with SMTP id bz2so1011994pad.1 for ; Thu, 26 May 2016 08:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=POpk0wovY9RIhrmoXBfunEaggmo/cxGcwLBBkUwE4Qk=; b=CG5NIiL5bJYzuN54n0smPvuRtdaxXL4ZZz6ycSururS3HyLo5DH2/lDh633mqV0Kmc npej6xqAJOpmZ7ufbssSuXbn0Zkwg62Zvvn0+Pg/5opIbgKn8jOnt9l67JzJCVNJTJjH J7VbNRNxWFJcWvMkS9jg+q0FICYzoOFYESGs2hU0SgoH2+iSLHxOAetDA+inyAJQIOuS RRe5ZEtIW4ipYamEsg1SdonWgL5WUc289EOuaKr584tbbQrrBXc+eXndZGk1A7eNXFbI hVnAdCN0HsmQn22ZI2M1ZiFY9mQQbprNZs9yQ+yRnOmQykOhp77jivnaaOD1/kalCH4J rUeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=POpk0wovY9RIhrmoXBfunEaggmo/cxGcwLBBkUwE4Qk=; b=dCriex8KA16gLXjGe0jPKIPGNQYOWJ2VI2cRopcQ2sn2xEbE8ENFz7bRGZL0IuuB9r Rv2IfPdpEznKQxnlF059ACkmTe3t0B7dT0MTWnvBt+qy7eOxwM0W+MdTxWzt9kj1h5K3 wWbfykQ9piASqejp7FYDrlbb8T5lug0Ry0cvcASC11Fc2TBBtMIBf3ADDu5lJF+oGZmu ChiBivpmhdjBFWs4/lCObysBAX/BrJHFs0se+NaNNHWS1Ku5Llv+Lt+CIJwTviZdpYGL 2a1uwGkXect4FxbJCr9KMkvH0knBB6dHTjmy4gM/TtgJ9L54jMWD2wndaxg9LPxF3Kdg kUvw== X-Gm-Message-State: ALyK8tKK9jlzSC88/2VCzNA1/zOIlFHZMcEqzPN5wc2uVlAsFLeYwLPE3eSHsPaYWy7cTE2X X-Received: by 10.66.121.197 with SMTP id lm5mr14955015pab.143.1464275570394; Thu, 26 May 2016 08:12:50 -0700 (PDT) Received: from orion.ger.corp.intel.com ([192.55.54.45]) by smtp.gmail.com with ESMTPSA id l67sm6888008pfi.10.2016.05.26.08.12.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 May 2016 08:12:49 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Thu, 26 May 2016 16:12:27 +0100 Message-Id: <1464275547-30446-10-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1464275547-30446-1-git-send-email-michael.g.wood@intel.com> References: <1464275547-30446-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH v2 9/9] toaster: Rework displaying package dependencies across Toaster X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 15:13:25 -0000 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] Signed-off-by: Michael Wood --- bitbake/lib/toaster/orm/models.py | 61 ++++++++++++++++++---- bitbake/lib/toaster/toastergui/buildtables.py | 15 +++++- bitbake/lib/toaster/toastergui/tables.py | 15 +++++- .../snippets/pkg_dependencies_popover.html | 44 ++++++++++++---- .../snippets/pkg_revdependencies_popover.html | 46 ++++++++++++---- .../toaster/toastergui/templatetags/projecttags.py | 8 +++ bitbake/lib/toaster/toastergui/views.py | 4 +- 7 files changed, 157 insertions(+), 36 deletions(-) diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 88967a2..7c26fcf 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -862,31 +862,70 @@ class CustomImagePackage(Package): related_name='appends_set') - class Package_DependencyManager(models.Manager): use_for_related_fields = True + TARGET_LATEST = "use-latest-target-for-target" def get_queryset(self): return super(Package_DependencyManager, self).get_queryset().exclude(package_id = F('depends_on__id')) - def get_total_source_deps_size(self): - """ Returns the total file size of all the packages that depend on - thispackage. - """ - return self.all().aggregate(Sum('depends_on__size')) + def for_target_or_none(self, target): + """ filter the dependencies to be displayed by the supplied target + if no dependences are found for the target then try None as the target + which will return the dependences calculated without the context of a + target e.g. non image recipes. - def get_total_revdeps_size(self): - """ Returns the total file size of all the packages that depend on - this package. + returns: { size, packages } """ - return self.all().aggregate(Sum('package_id__size')) + package_dependencies = self.all_depends().order_by('depends_on__name') + if target is self.TARGET_LATEST: + installed_deps =\ + package_dependencies.filter(~Q(target__target=None)) + else: + installed_deps =\ + package_dependencies.filter(Q(target__target=target)) + + packages_list = None + total_size = 0 + + # If we have installed depdencies for this package and target then use + # these to display + if installed_deps.count() > 0: + packages_list = installed_deps + total_size = installed_deps.aggregate( + Sum('depends_on__size'))['depends_on__size__sum'] + else: + new_list = [] + package_names = [] + + # Find dependencies for the package that we know about even if + # it's not installed on a target e.g. from a non-image recipe + for p in package_dependencies.filter(Q(target=None)): + if p.depends_on.name in package_names: + continue + else: + package_names.append(p.depends_on.name) + new_list.append(p.pk) + # while we're here we may as well total up the size to + # avoid iterating again + total_size += p.depends_on.size + + # We want to return a queryset here for consistency so pick the + # deps from the new_list + packages_list = package_dependencies.filter(Q(pk__in=new_list)) + + return {'packages': packages_list, + 'size': total_size} def all_depends(self): - """ Returns just the depends packages and not any other dep_type """ + """ Returns just the depends packages and not any other dep_type + Note that this is for any target + """ return self.filter(Q(dep_type=Package_Dependency.TYPE_RDEPENDS) | Q(dep_type=Package_Dependency.TYPE_TRDEPENDS)) + class Package_Dependency(models.Model): TYPE_RDEPENDS = 0 TYPE_TRDEPENDS = 1 diff --git a/bitbake/lib/toaster/toastergui/buildtables.py b/bitbake/lib/toaster/toastergui/buildtables.py index 17de369..e237e4e 100644 --- a/bitbake/lib/toaster/toastergui/buildtables.py +++ b/bitbake/lib/toaster/toastergui/buildtables.py @@ -47,6 +47,7 @@ class BuiltPackagesTableBase(tables.PackagesTable): def setup_queryset(self, *args, **kwargs): build = Build.objects.get(pk=kwargs['build_id']) self.static_context_extra['build'] = build + self.static_context_extra['target_name'] = None self.queryset = build.package_set.all().exclude(recipe=None) self.queryset = self.queryset.order_by(self.default_orderby) @@ -187,7 +188,15 @@ class InstalledPackagesTable(BuildTablesMixin, BuiltPackagesTableBase): self.static_context_extra['build'] = build target = Target.objects.get(pk=kwargs['target_id']) + # We send these separately because in the case of image details table + # we don't have a target just the recipe name as the target + self.static_context_extra['target_name'] = target.target + self.static_context_extra['target_id'] = target.pk + + self.static_context_extra['add_links'] = True + self.queryset = self.make_package_list(target) + self.queryset = self.queryset.order_by(self.default_orderby) def setup_columns(self, *args, **kwargs): super(InstalledPackagesTable, self).setup_columns(**kwargs) @@ -195,11 +204,13 @@ class InstalledPackagesTable(BuildTablesMixin, BuiltPackagesTableBase): static_data_name="installed_size", static_data_template="{% load projecttags %}" "{{data.size|filtered_filesizeformat}}", - orderable=True) + orderable=True, + hidden=True) # Add the template to show installed name for installed packages install_name_tmpl =\ - ('{{data.name}} ' + ('{{data.name}}' '{% if data.installed_name and data.installed_name !=' ' data.name %}' ' as {{data.installed_name}}' diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index 39d3f93..1add5b6 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py @@ -22,7 +22,7 @@ from toastergui.widgets import ToasterTable from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project from orm.models import CustomImageRecipe, Package, Target, Build, LogMessage, Task -from orm.models import CustomImagePackage +from orm.models import CustomImagePackage, Package_DependencyManager from django.db.models import Q, Max, Sum, Count, When, Case, Value, IntegerField from django.conf.urls import url from django.core.urlresolvers import reverse, resolve @@ -676,6 +676,7 @@ class PackagesTable(ToasterTable): def setup_queryset(self, *args, **kwargs): recipe = Recipe.objects.get(pk=kwargs['recipe_id']) + self.static_context_extra['target_name'] = recipe.name self.queryset = self.create_package_list(recipe, kwargs['pid']) self.queryset = self.queryset.order_by('name') @@ -746,7 +747,19 @@ class SelectPackagesTable(PackagesTable): self.queryset = self.queryset.order_by('name') + # This target is the target used to work out which group of dependences + # to display, if we've built the custom image we use it otherwise we + # can use the based recipe instead + if prj.build_set.filter(target__target=self.cust_recipe.name).count()\ + > 0: + self.static_context_extra['target_name'] = self.cust_recipe.name + else: + self.static_context_extra['target_name'] =\ + Package_DependencyManager.TARGET_LATEST + self.static_context_extra['recipe_id'] = kwargs['custrecipeid'] + + self.static_context_extra['current_packages'] = \ current_packages.values_list('pk', flat=True) diff --git a/bitbake/lib/toaster/toastergui/templates/snippets/pkg_dependencies_popover.html b/bitbake/lib/toaster/toastergui/templates/snippets/pkg_dependencies_popover.html index a3fcdb0..04d5f2b 100644 --- a/bitbake/lib/toaster/toastergui/templates/snippets/pkg_dependencies_popover.html +++ b/bitbake/lib/toaster/toastergui/templates/snippets/pkg_dependencies_popover.html @@ -1,14 +1,38 @@ {# Popover that displays the dependences and sizes of a package 'data' used in the Packages table #} -{% with data.package_dependencies_source.all_depends.count as dep_count %} {% load projecttags %} -{% if dep_count %} - - {{dep_count}} - + +{% with package_deps=data.package_dependencies_source|for_target:extra.target_name %} +{% with count_package=package_deps.packages|length %} + +{% if count_package > 0 %} + + {{dep.depends_on.name}} + {% else %} + {{dep.depends_on.name}} + {% endif %} + {% if dep.depends_on.size > 0 %} + ({{dep.depends_on.size|filtered_filesizeformat}}) + {% endif %} + + {% endfor %} + ' title="" class="btn" data-original-title=' + + {% if extra.add_links %} + + {{data.name}} + {% else %} + {{data.name}} + {% endif %} + + dependencies - + {{package_deps.size|filtered_filesizeformat}}'> + {{count_package}} + {% endif %} + +{% endwith %} {% endwith %} diff --git a/bitbake/lib/toaster/toastergui/templates/snippets/pkg_revdependencies_popover.html b/bitbake/lib/toaster/toastergui/templates/snippets/pkg_revdependencies_popover.html index 453a9d0..21c2b9f 100644 --- a/bitbake/lib/toaster/toastergui/templates/snippets/pkg_revdependencies_popover.html +++ b/bitbake/lib/toaster/toastergui/templates/snippets/pkg_revdependencies_popover.html @@ -1,14 +1,38 @@ -{# Popover that displays the reverse dependencies and sizes of a package 'data' used in the Packages table #} -{% with data.package_dependencies_target.all_depends.count as dep_count %} +{# Popover that displays the reverse dependences and sizes of a package 'data' used in the Packages table #} {% load projecttags %} -{% if dep_count %} - - {{dep_count}} - + +{% with package_deps=data.package_dependencies_target|for_target:extra.target_name %} +{% with count_package=package_deps.packages|length %} + +{% if count_package > 0 %} + + {{dep.package.name}} + {% else %} + {{dep.package.name}} + {% endif %} + {% if dep.package.size > 0 %} + ({{dep.package.size|filtered_filesizeformat}}) + {% endif %} + + {% endfor %} + ' title="" class="btn" data-original-title=' + + {% if extra.add_links %} + + {{data.name}} + {% else %} + {{data.name}} + {% endif %} + + dependencies - + {{package_deps.size|filtered_filesizeformat}}'> + {{count_package}} + {% endif %} + +{% endwith %} {% endwith %} diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py index 75f2261..9ee7a59 100644 --- a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py +++ b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py @@ -297,3 +297,11 @@ def cut_path_prefix(fullpath, prefixes): if fullpath.startswith(prefix): return relpath(fullpath, prefix) return fullpath + + +@register.filter +def for_target(package_dependencies, target): + """ filter the dependencies to be displayed by the supplied target + if no dependences are found for the target then return the predicted + dependences""" + return package_dependencies.for_target_or_none(target) diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index ed29c93..bba956a 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -2042,7 +2042,9 @@ if True: # Dependencies for package which aren't satisfied by the # current packages in the custom image recipe - deps = package.package_dependencies_source.annotate( + deps =\ + package.package_dependencies_source.for_target_or_none( + recipe.name)['packages'].annotate( name=F('depends_on__name'), pk=F('depends_on__pk'), size=F('depends_on__size'), -- 2.7.4