euscanwww: Fixing metadata and ebuild urls

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-11-26 15:38:27 +01:00
parent a8f69e8128
commit 7380daf7e9
6 changed files with 41 additions and 42 deletions

9
TODO
View File

@ -24,8 +24,8 @@ euscan
### metadata.xml ### metadata.xml
- Create a page to list handlers users, and average confidence - Use handler's statistics page to generate metadata for some packages
- Use this page to generate metadata for some packages (handled by deb or brute force for example) (handled by deb or brute force for example)
- Create a subtree of metadata using custom rules - Create a subtree of metadata using custom rules
- Finalize format - Finalize format
- Write a GLEP - Write a GLEP
@ -40,7 +40,7 @@ euscan
### handlers ### handlers
- remote-id type deb repository: - 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 ### remote-id
- Propose new remote-id: deb - Propose new remote-id: deb
@ -56,15 +56,12 @@ euscanwww
### misc ### 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 - 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. - 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 ### packages
- show additional informations in the web interface (remote-id, etc...) - 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 ? - Ignore alpha/beta if current is not alpha/beta: per-package setting using metadata.xml ?
- ~arch / stable support: see "models: keywords" - ~arch / stable support: see "models: keywords"
- stabilisation candidates: check stabilizations rules, and see how this can be automated - stabilisation candidates: check stabilizations rules, and see how this can be automated

View File

@ -98,12 +98,3 @@ def get_layman_repos():
lay = Layman(config=settings.LAYMAN_CONFIG) lay = Layman(config=settings.LAYMAN_CONFIG)
installed_overlays = lay.get_installed() installed_overlays = lay.get_installed()
return lay.get_all_info(installed_overlays) 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

View File

@ -171,13 +171,13 @@ class Version(models.Model):
def cpv(self): def cpv(self):
return '%s/%s-%s%s' % ( return '%s/%s-%s%s' % (
self.package.category, self.package.name, self.version, 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): def __unicode__(self):
return '%s/%s-%s%s%s [%s]' % ( return '%s/%s-%s%s%s [%s]' % (
self.package.category, self.package.name, self.version, 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.slot if self.slot and self.slot != '0' else '',
self.overlay or "<upstream>" self.overlay or "<upstream>"
) )
@ -221,7 +221,7 @@ class VersionLog(models.Model):
txt = '+ ' if self.action == self.VERSION_ADDED else '- ' txt = '+ ' if self.action == self.VERSION_ADDED else '- '
txt += '%s/%s-%s%s%s [%s]' % ( txt += '%s/%s-%s%s%s [%s]' % (
self.package.category, self.package.name, self.version, 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.slot if self.slot and self.slot != '0' else '',
self.overlay or "<upstream>" self.overlay or "<upstream>"
) )

View File

@ -63,12 +63,12 @@
{% endif %} {% endif %}
{% if version.ebuild_path %} {% 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 %} {{ version.version }}{% if version.revision != "r0" %}-{{ version.revision }}{% endif %}{% if version.slot != "0" %}:{{ version.slot }}{% endif %}
</a> </a>
{% endif %} {% endif %}
{% if version.metadata_path %} {% if version.metadata_path %}
<a href="{% url "package_version_metadata" package.category package.name version.tag %}"> <a href="{% url "package_metadata" version.overlay package.category package.name %}">
<img src="{{ STATIC_URL }}img/metadata.png" alt="Metadata" /> <img src="{{ STATIC_URL }}img/metadata.png" alt="Metadata" />
</a> </a>
{% endif %} {% endif %}

View File

@ -23,10 +23,16 @@ package_patterns = patterns('djeuscan.views',
url(r'^unfavourite/$', unfavourite_package, name="unfavourite_package"), url(r'^unfavourite/$', unfavourite_package, name="unfavourite_package"),
url(r'^refresh$', "refresh_package", name="refresh_package"), url(r'^refresh$', "refresh_package", name="refresh_package"),
url(r'^problem$', 'problem', name="problem"), 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"), name="package_version_ebuild"),
url(r'^(?P<version_tag>.*)/metadata$', "package_version_metadata", url(r'^(?P<overlay>[\w+][\w+.-]*)/(?P<category>[\w+][\w+.-]*)/'
name="package_version_metadata"), r'(?P<package>[\w+][\w+.-]*)/metadata.xml$',
"package_metadata",
name="package_metadata"),
) )
categories_patterns = patterns('djeuscan.views', categories_patterns = patterns('djeuscan.views',
@ -112,5 +118,7 @@ urlpatterns = patterns('djeuscan.views',
url(r'^package/(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/', url(r'^package/(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/',
include(package_patterns)), include(package_patterns)),
url(r'^files/', include(files_patterns)),
url(r'^tasks/', include(tasks_patterns)), url(r'^tasks/', include(tasks_patterns)),
) )

View File

@ -3,6 +3,8 @@
import inspect import inspect
from annoying.decorators import render_to, ajax_request from annoying.decorators import render_to, ajax_request
from portage.versions import catpkgsplit
from django.http import HttpResponse, HttpResponseNotFound from django.http import HttpResponse, HttpResponseNotFound
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404, redirect 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 django.db import models
from djeuscan.helpers import version_key, packages_from_names, \ 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, \ from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \
VersionLog, RefreshPackageQuery, ProblemReport, Category, Overlay VersionLog, RefreshPackageQuery, ProblemReport, Category, Overlay
from djeuscan.forms import WorldForm, PackagesForm, ProblemReportForm 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) package = get_object_or_404(Package, category=category, name=package)
try:
ver, rev, over = versiontag_to_attrs(version_tag) versions = Version.objects.filter(package=package, overlay=overlay)
except TypeError: if len(versions) == 0:
return HttpResponseNotFound() 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 = "" content = ""
if version.metadata_path: if version.metadata_path:
try: try:
@ -245,17 +250,15 @@ def package_version_metadata(request, category, package, version_tag):
return HttpResponse(content, content_type="text/plain") return HttpResponse(content, content_type="text/plain")
def package_version_ebuild(request, category, package, version_tag): def package_version_ebuild(request, overlay, cpv):
package = get_object_or_404(Package, category=category, name=package) 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: try:
ver, rev, over = versiontag_to_attrs(version_tag) with open(obj.ebuild_path) as ebuild_file:
except TypeError:
return HttpResponseNotFound()
version = get_object_or_404(Version, package=package, version=ver,
revision=rev, overlay=over)
if version.ebuild_path:
try:
with open(version.ebuild_path) as ebuild_file:
content = ebuild_file.read() content = ebuild_file.read()
except IOError: except IOError:
return HttpResponseNotFound() return HttpResponseNotFound()