summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devel/management/commands/reporead.py36
-rw-r--r--main/models.py6
-rw-r--r--media/archweb.css4
-rw-r--r--templates/packages/details.html25
4 files changed, 44 insertions, 27 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 9b99e0f7..f3ec50e8 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -29,7 +29,7 @@ from optparse import make_option
from logging import ERROR, WARNING, INFO, DEBUG
-from main.models import Arch, Package, Repo
+from main.models import Arch, Package, PackageDepend, Repo
logging.basicConfig(
level=WARNING,
@@ -155,6 +155,20 @@ def find_user(userstring):
# lookup more than strictly necessary.
find_user.cache = {}
+def create_depend(package, dep_str, optional=False):
+ depend = PackageDepend(pkg=package, optional=optional)
+ # lop off any description first
+ parts = dep_str.split(':', 1)
+ if len(parts) > 1:
+ depend.description = parts[1].strip()
+ match = re.match(r"^(.+?)((>=|<=|=|>|<)(.*))?$", parts[0].strip())
+ if match:
+ depend.depname = match.group(1)
+ if match.group(2):
+ depend.depvcmp = match.group(2)
+ depend.save(force_insert=True)
+ return depend
+
def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
if repopkg.base:
dbpkg.pkgbase = repopkg.base
@@ -188,24 +202,20 @@ def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
populate_files(dbpkg, repopkg, force=force)
dbpkg.packagedepend_set.all().delete()
- if 'depends' in repopkg.__dict__:
+ if hasattr(repopkg, 'depends'):
for y in repopkg.depends:
- # make sure we aren't adding self depends..
- # yes *sigh* i have seen them in pkgbuilds
- dpname, dpvcmp = re.match(r"([a-z0-9._+-]+)(.*)", y).groups()
- if dpname == repopkg.name:
- logger.warning('Package %s has a depend on itself', repopkg.name)
- continue
- dbpkg.packagedepend_set.create(depname=dpname, depvcmp=dpvcmp)
- logger.debug('Added %s as dep for pkg %s', dpname, repopkg.name)
+ dep = create_depend(dbpkg, y)
+ if hasattr(repopkg, 'optdepends'):
+ for y in repopkg.optdepends:
+ dep = create_depend(dbpkg, y, True)
dbpkg.groups.all().delete()
- if 'groups' in repopkg.__dict__:
+ if hasattr(repopkg, 'groups'):
for y in repopkg.groups:
dbpkg.groups.create(name=y)
dbpkg.licenses.all().delete()
- if 'license' in repopkg.__dict__:
+ if hasattr(repopkg, 'license'):
for y in repopkg.license:
dbpkg.licenses.create(name=y)
@@ -223,7 +233,7 @@ def populate_files(dbpkg, repopkg, force=False):
elif dbpkg.files_last_update > dbpkg.last_update:
return
# only delete files if we are reading a DB that contains them
- if 'files' in repopkg.__dict__:
+ if hasattr(repopkg, 'files'):
dbpkg.packagefile_set.all().delete()
logger.info("adding %d files for package %s",
len(repopkg.files), dbpkg.pkgname)
diff --git a/main/models.py b/main/models.py
index b1813c3c..dafbb1eb 100644
--- a/main/models.py
+++ b/main/models.py
@@ -209,7 +209,7 @@ class Package(models.Model):
"""
deps = []
# TODO: we can use list comprehension and an 'in' query to make this more effective
- for dep in self.packagedepend_set.order_by('depname'):
+ for dep in self.packagedepend_set.order_by('optional', 'depname'):
pkgs = Package.objects.select_related('arch', 'repo').filter(
pkgname=dep.depname)
if not self.arch.agnostic:
@@ -320,12 +320,12 @@ class PackageFile(models.Model):
class PackageDepend(models.Model):
pkg = models.ForeignKey(Package)
depname = models.CharField(max_length=255, db_index=True)
- depvcmp = models.CharField(max_length=255)
+ depvcmp = models.CharField(max_length=255, default='')
optional = models.BooleanField(default=False)
description = models.TextField(null=True, blank=True)
def __unicode__(self):
- return "%s%s" % (depname, depvcmp)
+ return "%s%s" % (self.depname, self.depvcmp)
class Meta:
db_table = 'package_depends'
diff --git a/media/archweb.css b/media/archweb.css
index d45ea10b..47abba7b 100644
--- a/media/archweb.css
+++ b/media/archweb.css
@@ -216,6 +216,10 @@ form#flag-pkg-form textarea, form#flag-pkg-form input[type=text] { width: 45%; }
#pkgdetails #metadata .message { font-style: italic; }
#pkgdetails #metadata br { clear: both; }
#pkgdetails #pkgdeps { float: left; width: 48%; margin-right: 2%; }
+#pkgdetails #metadata .virtual-dep { font-style: italic; }
+#pkgdetails #metadata .testing-dep { font-style: italic; }
+#pkgdetails #metadata .opt-dep { font-style: italic; }
+#pkgdetails #metadata .dep-desc { font-style: italic; }
#pkgdetails #pkgreqs { float: left; width: 50%; }
#pkgdetails #pkgfiles { clear: left; padding-top: 1em; }
diff --git a/templates/packages/details.html b/templates/packages/details.html
index 14b657e3..ac997184 100644
--- a/templates/packages/details.html
+++ b/templates/packages/details.html
@@ -159,16 +159,18 @@
{% if deps %}
<ul>
- {% for depend in deps %}
- {% ifequal depend.pkg None %}
- <li>{{ depend.dep.depname }} (virtual)</li>
- {% else %}
+ {% for depend in deps %}
+ {% ifequal depend.pkg None %}
+ <li>{{ depend.dep.depname }} <span class="virtual-dep">(virtual)</span></li>
+ {% else %}
<li><a href="{{ depend.pkg.get_absolute_url }}"
- title="View package details for {{ depend.dep.depname }}">{{ depend.dep.depname }}</a>
- {{ depend.dep.depvcmp }}{% if depend.pkg.repo.testing %}
- <span class="testing-dep">(testing)</span>{% endif %}</li>
- {% endifequal %}
- {% endfor %}
+ title="View package details for {{ depend.dep.depname }}">{{ depend.dep.depname }}</a>{{ depend.dep.depvcmp|default:"" }}
+ {% if depend.pkg.repo.testing %}<span class="testing-dep">(testing)</span>{% endif %}
+ {% if depend.dep.optional %}<span class="opt-dep">(optional)</span>{% endif %}
+ {% if depend.dep.description %}<span class="dep-desc">{{ depend.dep.description }}</span>{% endif %}
+ </li>
+ {% endifequal %}
+ {% endfor %}
</ul>
{% endif %}
@@ -184,9 +186,10 @@
{% if rqdby %}
<ul>
{% for req in rqdby %}
- <li><a href="{{req.get_absolute_url}}"
+ <li><a href="{{ req.get_absolute_url }}"
title="View package details for {{ req.pkgname }}">{{ req.pkgname }}</a>
- {% if req.repo.testing %} (testing){% endif %}</li>
+ {% if req.repo.testing %}<span class="testing-dep">(testing)</span>{% endif %}
+ </li>
{% endfor %}
</ul>
{% endif %}