summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-09-08 11:12:43 -0500
committerDan McGee <dan@archlinux.org>2010-09-08 11:12:43 -0500
commit04da5f03b254a6000c92eb4e32bdfaa88724f4a4 (patch)
treece7dd0ff708ce92e37b52a2ff4f6f9cad35bed7a
parent5c78ad746942cafa03ed4834eefac98832021558 (diff)
downloadarchweb-04da5f03b254a6000c92eb4e32bdfaa88724f4a4.tar.gz
archweb-04da5f03b254a6000c92eb4e32bdfaa88724f4a4.zip
Use arch.agnostic flag everywhere
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--feeds.py4
-rw-r--r--main/models.py13
-rw-r--r--packages/views.py10
3 files changed, 17 insertions, 10 deletions
diff --git a/feeds.py b/feeds.py
index b149c4a9..c6395f87 100644
--- a/feeds.py
+++ b/feeds.py
@@ -18,7 +18,7 @@ class PackageFeed(Feed):
if arch != '':
# feed for a single arch, also include 'any' packages everywhere
a = Arch.objects.get(name=arch)
- qs = qs.filter(Q(arch=a) | Q(arch__name='any'))
+ qs = qs.filter(Q(arch=a) | Q(arch__agnostic=True))
obj['arch'] = a
if repo != '':
# feed for a single arch AND repo
@@ -40,7 +40,7 @@ class PackageFeed(Feed):
s = 'Recently updated packages in the Arch Linux package repositories'
if 'arch' in obj:
s += ' for the \'%s\' architecture' % obj['arch'].name.lower()
- if obj['arch'].name != 'any':
+ if not obj['arch'].agnostic:
s += ' (including \'any\' packages)'
if 'repo' in obj:
s += ' in the [%s] repository' % obj['repo'].name.lower()
diff --git a/main/models.py b/main/models.py
index 70ab4bd6..0f4ae967 100644
--- a/main/models.py
+++ b/main/models.py
@@ -155,9 +155,11 @@ class Package(models.Model):
"""
Returns a list of package objects.
"""
+ arches = list(Arch.objects.filter(agnostic=True))
+ arches.append(self.arch)
requiredby = Package.objects.select_related('arch', 'repo').filter(
packagedepend__depname=self.pkgname,
- arch__name__in=(self.arch.name, 'any')).distinct()
+ arch__in=arches).distinct()
return requiredby.order_by('pkgname')
@cache_function(300)
@@ -168,12 +170,15 @@ class Package(models.Model):
else pkg will be None if it is a 'virtual' dependency.
"""
deps = []
+ arches = list(Arch.objects.filter(agnostic=True))
+ arches.append(self.arch)
# TODO: we can use list comprehension and an 'in' query to make this more effective
for dep in self.packagedepend_set.order_by('depname'):
- pkgs = Package.objects.select_related('arch', 'repo').filter(pkgname=dep.depname)
- if self.arch.name != 'any':
+ pkgs = Package.objects.select_related('arch', 'repo').filter(
+ pkgname=dep.depname)
+ if not self.arch.agnostic:
# make sure we match architectures if possible
- pkgs = pkgs.filter(arch__name__in=(self.arch.name, 'any'))
+ pkgs = pkgs.filter(arch__in=arches)
if len(pkgs) == 0:
# couldn't find a package in the DB
# it should be a virtual depend (or a removed package)
diff --git a/packages/views.py b/packages/views.py
index 784d2540..4cc4cc2f 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -87,8 +87,10 @@ def groups(request):
def group_details(request, arch, name):
arch = get_object_or_404(Arch, name=arch)
- pkgs = Package.objects.filter(packagegroup__name=name)
- pkgs = pkgs.filter(Q(arch__name=arch) | Q(arch__name='any'))
+ arches = [ arch ]
+ arches.extend(Arch.objects.filter(agnostic=True))
+ pkgs = Package.objects.filter(packagegroup__name=name,
+ arch__in=arches)
pkgs = pkgs.order_by('pkgname')
if len(pkgs) == 0:
raise Http404
@@ -350,9 +352,9 @@ def download(request, name='', repo='', arch=''):
mirror__public=True, mirror__active=True,
protocol__protocol__iexact='HTTP')[0]
arch = pkg.arch.name
- if arch == 'any':
+ if pkg.arch.agnostic:
# grab the first non-any arch to fake the download path
- arch = Arch.objects.exclude(name='any')[0].name
+ arch = Arch.objects.exclude(agnostic=True)[0].name
details = {
'host': mirrorurl.url,
'arch': arch,