Filtered requiredby list for non-primary depends
For something like gambas3 which has a makedepend on postgresql, we end up getting every single split package listed in the required by list for postgresql. This is a bit crazy and unnecessary, so slim it down a bit when possible by using a slightly crazy groupby function and some smarts in our get_requiredby function. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
7ac017e1e7
commit
833798f4fb
@ -9,7 +9,7 @@
|
||||
from django.contrib.sites.models import Site
|
||||
|
||||
from .fields import PositiveBigIntegerField
|
||||
from .utils import set_created_field
|
||||
from .utils import set_created_field, DependStandin
|
||||
from devel.models import DeveloperKey
|
||||
from packages.alpm import AlpmAPI
|
||||
|
||||
@ -247,6 +247,20 @@ def get_requiredby(self):
|
||||
if len(requiredby) == 0:
|
||||
return requiredby
|
||||
|
||||
# do we have duplicate pkgbase values for non-primary depends?
|
||||
# if so, filter it down to base packages only
|
||||
def grouper(depend):
|
||||
p = depend.pkg
|
||||
return (depend.deptype, p.pkgbase, p.repo.testing, p.repo.staging)
|
||||
|
||||
filtered = []
|
||||
for (typ, pkgbase, _, _), dep_pkgs in groupby(requiredby, grouper):
|
||||
dep_pkgs = list(dep_pkgs)
|
||||
if typ == 'D' or len(dep_pkgs) == 1:
|
||||
filtered.extend(dep_pkgs)
|
||||
else:
|
||||
filtered.append(DependStandin(dep_pkgs))
|
||||
|
||||
# find another package by this name in a different testing or staging
|
||||
# repo; if we can't, we can short-circuit some checks
|
||||
repo_q = (Q(repo__testing=(not self.repo.testing)) |
|
||||
@ -255,13 +269,13 @@ def get_requiredby(self):
|
||||
repo_q, pkgname=self.pkgname, arch=self.arch
|
||||
).exclude(id=self.id).exists():
|
||||
# there isn't one? short circuit, all required by entries are fine
|
||||
return requiredby
|
||||
return filtered
|
||||
|
||||
trimmed = []
|
||||
# for each unique package name, try to screen our package list down to
|
||||
# those packages in the same testing and staging category (yes or no)
|
||||
# iff there is a package in the same testing and staging category.
|
||||
for _, dep_pkgs in groupby(requiredby, lambda x: x.pkg.pkgname):
|
||||
for _, dep_pkgs in groupby(filtered, lambda x: x.pkg.pkgname):
|
||||
dep_pkgs = list(dep_pkgs)
|
||||
dep = dep_pkgs[0]
|
||||
if len(dep_pkgs) > 1:
|
||||
@ -271,6 +285,7 @@ def get_requiredby(self):
|
||||
if len(dep_pkgs) > 0:
|
||||
dep = dep_pkgs[0]
|
||||
trimmed.append(dep)
|
||||
|
||||
return trimmed
|
||||
|
||||
def get_depends(self):
|
||||
|
@ -187,4 +187,18 @@ def get_absolute_url(self):
|
||||
return '/packages/%s/%s/%s/' % (
|
||||
self.repo.name.lower(), self.arch.name, self.pkgbase)
|
||||
|
||||
|
||||
class DependStandin(object):
|
||||
'''Resembles a Depend object, and has a few of the same fields, but is
|
||||
really a link to a base package rather than a single package.'''
|
||||
def __init__(self, depends):
|
||||
self._depends = depends
|
||||
first = depends[0]
|
||||
self.name = first.name
|
||||
self.version = first.version
|
||||
self.comparison = first.comparison
|
||||
self.description = first.description
|
||||
self.deptype = first.deptype
|
||||
self.pkg = first.pkg.base_package() or PackageStandin(first.pkg)
|
||||
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
Loading…
Reference in New Issue
Block a user