summaryrefslogtreecommitdiff
path: root/main/models.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-11-11 16:28:34 -0600
committerDan McGee <dan@archlinux.org>2013-11-11 16:28:34 -0600
commit833798f4fb7f629fdb8d7e57b5f25b31d395fa5e (patch)
treef6fe8b58ba6c8478a8dba3fadd45f5c3c90f5853 /main/models.py
parent7ac017e1e7884320bd00f67134dd1ae7e06ceaaf (diff)
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>
Diffstat (limited to 'main/models.py')
-rw-r--r--main/models.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/main/models.py b/main/models.py
index 2ace0109..b3c3e409 100644
--- a/main/models.py
+++ b/main/models.py
@@ -9,7 +9,7 @@ from django.contrib.auth.models import User
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 @@ class Package(models.Model):
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 @@ class Package(models.Model):
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 @@ class Package(models.Model):
if len(dep_pkgs) > 0:
dep = dep_pkgs[0]
trimmed.append(dep)
+
return trimmed
def get_depends(self):