euscanwww: Fixing metadata and ebuild urls
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
parent
a8f69e8128
commit
7380daf7e9
9
TODO
9
TODO
@ -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
|
||||
|
@ -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
|
||||
|
@ -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>"
|
||||
)
|
||||
|
@ -63,12 +63,12 @@
|
||||
{% 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 %}">
|
||||
<a href="{% url "package_metadata" version.overlay package.category package.name %}">
|
||||
<img src="{{ STATIC_URL }}img/metadata.png" alt="Metadata" />
|
||||
</a>
|
||||
{% endif %}
|
||||
|
@ -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)),
|
||||
)
|
||||
|
@ -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)
|
||||
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:
|
||||
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:
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user