diff options
author | 2012-11-26 15:38:27 +0100 | |
---|---|---|
committer | 2012-11-26 15:38:27 +0100 | |
commit | 7380daf7e9c3fdd6f20442706fc1f5eb832584ec (patch) | |
tree | 29acad6194b8e8d271e092e3584de466ed0881c1 | |
parent | euscanwww: per handler package list (diff) | |
download | euscan-7380daf7e9c3fdd6f20442706fc1f5eb832584ec.tar.gz euscan-7380daf7e9c3fdd6f20442706fc1f5eb832584ec.tar.bz2 euscan-7380daf7e9c3fdd6f20442706fc1f5eb832584ec.zip |
euscanwww: Fixing metadata and ebuild urls
Signed-off-by: volpino <fox91@anche.no>
-rw-r--r-- | TODO | 9 | ||||
-rw-r--r-- | euscanwww/djeuscan/helpers.py | 9 | ||||
-rw-r--r-- | euscanwww/djeuscan/models.py | 6 | ||||
-rw-r--r-- | euscanwww/djeuscan/templates/euscan/_package_details.html | 8 | ||||
-rw-r--r-- | euscanwww/djeuscan/urls.py | 14 | ||||
-rw-r--r-- | euscanwww/djeuscan/views.py | 37 |
6 files changed, 41 insertions, 42 deletions
@@ -24,8 +24,8 @@ euscan ### metadata.xml -- Create a page to list handlers users, and average confidence -- Use this page to generate metadata for some packages (handled by deb or brute force for example) +- Use handler's statistics page to generate metadata for some packages + (handled by deb or brute force for example) - Create a subtree of metadata using custom rules - Finalize format - Write a GLEP @@ -40,7 +40,7 @@ euscan ### handlers - remote-id type deb repository: - - find out how to get download url (not sure it's possible) +-- find out how to get download url (not sure it's possible) ### remote-id - Propose new remote-id: deb @@ -56,15 +56,12 @@ euscanwww ### misc -- change ebuild/metadata urls. Use <overlay>/<category>/<package>-<version>(-<revision>?).ebuild instead. Use portage code to parse that. Same thing for metadata.xml, without - version-revision. - Really fix mails: better formating - Always keep in db all found versions (when using an API only?). But don't display them if older than current packaged version, except maybe in the "upstream_version" column. ### packages - show additional informations in the web interface (remote-id, etc...) -- show the content of the ebuild for a particular version - Ignore alpha/beta if current is not alpha/beta: per-package setting using metadata.xml ? - ~arch / stable support: see "models: keywords" - stabilisation candidates: check stabilizations rules, and see how this can be automated diff --git a/euscanwww/djeuscan/helpers.py b/euscanwww/djeuscan/helpers.py index 177b91c..171ba5e 100644 --- a/euscanwww/djeuscan/helpers.py +++ b/euscanwww/djeuscan/helpers.py @@ -98,12 +98,3 @@ def get_layman_repos(): lay = Layman(config=settings.LAYMAN_CONFIG) installed_overlays = lay.get_installed() return lay.get_all_info(installed_overlays) - - -def versiontag_to_attrs(tag): - import re - match = re.match(r"(.+)-(.+)-(.+)", tag) - if match: - return match.groups() - else: - None diff --git a/euscanwww/djeuscan/models.py b/euscanwww/djeuscan/models.py index 2dbe85c..2c7f6c2 100644 --- a/euscanwww/djeuscan/models.py +++ b/euscanwww/djeuscan/models.py @@ -171,13 +171,13 @@ class Version(models.Model): def cpv(self): return '%s/%s-%s%s' % ( self.package.category, self.package.name, self.version, - '-' + self.revision if self.revision != '-r0' else '' + '-' + self.revision if self.revision != 'r0' else '' ) def __unicode__(self): return '%s/%s-%s%s%s [%s]' % ( self.package.category, self.package.name, self.version, - '-' + self.revision if self.revision != '-r0' else '', + '-' + self.revision if self.revision != 'r0' else '', ':' + self.slot if self.slot and self.slot != '0' else '', self.overlay or "<upstream>" ) @@ -221,7 +221,7 @@ class VersionLog(models.Model): txt = '+ ' if self.action == self.VERSION_ADDED else '- ' txt += '%s/%s-%s%s%s [%s]' % ( self.package.category, self.package.name, self.version, - '-' + self.revision if self.revision != '-r0' else '', + '-' + self.revision if self.revision != 'r0' else '', ':' + self.slot if self.slot and self.slot != '0' else '', self.overlay or "<upstream>" ) diff --git a/euscanwww/djeuscan/templates/euscan/_package_details.html b/euscanwww/djeuscan/templates/euscan/_package_details.html index 8953345..3110606 100644 --- a/euscanwww/djeuscan/templates/euscan/_package_details.html +++ b/euscanwww/djeuscan/templates/euscan/_package_details.html @@ -63,14 +63,14 @@ {% endif %} {% if version.ebuild_path %} - <a href="{% url "package_version_ebuild" package.category package.name version.tag %}"> + <a href="{% url "package_version_ebuild" version.overlay version.cpv %}"> {{ version.version }}{% if version.revision != "r0" %}-{{ version.revision }}{% endif %}{% if version.slot != "0" %}:{{ version.slot }}{% endif %} </a> {% endif %} {% if version.metadata_path %} - <a href="{% url "package_version_metadata" package.category package.name version.tag %}"> - <img src="{{ STATIC_URL }}img/metadata.png" alt="Metadata" /> - </a> + <a href="{% url "package_metadata" version.overlay package.category package.name %}"> + <img src="{{ STATIC_URL }}img/metadata.png" alt="Metadata" /> + </a> {% endif %} </li> {% endfor %} diff --git a/euscanwww/djeuscan/urls.py b/euscanwww/djeuscan/urls.py index 83a07de..57cc08e 100644 --- a/euscanwww/djeuscan/urls.py +++ b/euscanwww/djeuscan/urls.py @@ -23,10 +23,16 @@ package_patterns = patterns('djeuscan.views', url(r'^unfavourite/$', unfavourite_package, name="unfavourite_package"), url(r'^refresh$', "refresh_package", name="refresh_package"), url(r'^problem$', 'problem', name="problem"), - url(r'^(?P<version_tag>.*)/ebuild$', "package_version_ebuild", +) + +files_patterns = patterns('djeuscan.views', + url(r'^(?P<overlay>[\w+][\w+.-]*)/(?P<cpv>.+).ebuild$', + "package_version_ebuild", name="package_version_ebuild"), - url(r'^(?P<version_tag>.*)/metadata$', "package_version_metadata", - name="package_version_metadata"), + url(r'^(?P<overlay>[\w+][\w+.-]*)/(?P<category>[\w+][\w+.-]*)/' + r'(?P<package>[\w+][\w+.-]*)/metadata.xml$', + "package_metadata", + name="package_metadata"), ) categories_patterns = patterns('djeuscan.views', @@ -112,5 +118,7 @@ urlpatterns = patterns('djeuscan.views', url(r'^package/(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/', include(package_patterns)), + url(r'^files/', include(files_patterns)), + url(r'^tasks/', include(tasks_patterns)), ) diff --git a/euscanwww/djeuscan/views.py b/euscanwww/djeuscan/views.py index 8456640..e09b82f 100644 --- a/euscanwww/djeuscan/views.py +++ b/euscanwww/djeuscan/views.py @@ -3,6 +3,8 @@ import inspect from annoying.decorators import render_to, ajax_request +from portage.versions import catpkgsplit + from django.http import HttpResponse, HttpResponseNotFound from django.core.urlresolvers import reverse from django.shortcuts import get_object_or_404, redirect @@ -11,7 +13,7 @@ from django.views.decorators.http import require_POST from django.db import models from djeuscan.helpers import version_key, packages_from_names, \ - get_maintainer_or_404, get_make_conf, get_layman_repos, versiontag_to_attrs + get_maintainer_or_404, get_make_conf, get_layman_repos from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \ VersionLog, RefreshPackageQuery, ProblemReport, Category, Overlay from djeuscan.forms import WorldForm, PackagesForm, ProblemReportForm @@ -225,14 +227,17 @@ def package(request, category, package): } -def package_version_metadata(request, category, package, version_tag): +def package_metadata(request, overlay, category, package): package = get_object_or_404(Package, category=category, name=package) - try: - ver, rev, over = versiontag_to_attrs(version_tag) - except TypeError: + + versions = Version.objects.filter(package=package, overlay=overlay) + if len(versions) == 0: return HttpResponseNotFound() - version = get_object_or_404(Version, package=package, version=ver, - revision=rev, overlay=over) + + # XXX: Kinda ugly, it assumes that every version with the same overlay + # has the same metadata path + version = versions[0] + content = "" if version.metadata_path: try: @@ -245,17 +250,15 @@ def package_version_metadata(request, category, package, version_tag): return HttpResponse(content, content_type="text/plain") -def package_version_ebuild(request, category, package, version_tag): - package = get_object_or_404(Package, category=category, name=package) - try: - ver, rev, over = versiontag_to_attrs(version_tag) - except TypeError: - return HttpResponseNotFound() - version = get_object_or_404(Version, package=package, version=ver, - revision=rev, overlay=over) - if version.ebuild_path: +def package_version_ebuild(request, overlay, cpv): + category, package, version, revision = catpkgsplit(cpv) + pkg = get_object_or_404(Package, category=category, name=package) + obj = get_object_or_404(Version, package=pkg, version=version, + revision=revision, overlay=overlay) + + if obj.ebuild_path: try: - with open(version.ebuild_path) as ebuild_file: + with open(obj.ebuild_path) as ebuild_file: content = ebuild_file.read() except IOError: return HttpResponseNotFound() |