@lazy_property
def country_code(self):
- network = self.location.lookup(self.address)
+ network = self.backend.mirrors.location.lookup(self.address)
if network:
return network.country_code
def mirrorlist(self):
return "/".join((
self.settings.get("baseurl", "https://pakfire.ipfire.org"),
- "distro", self.distro.slug,
- "repo", self.slug,
+ "distros",
+ self.distro.slug,
+ "repos",
+ self.slug,
"mirrorlist?arch=%{arch}"
))
(r"/distros/([A-Za-z0-9\-\.]+)/repos/([A-Za-z0-9\-]+)", repos.ShowHandler),
(r"/distros/([A-Za-z0-9\-\.]+)/repos/([A-Za-z0-9\-]+)\.repo", repos.ConfigHandler),
(r"/distros/([A-Za-z0-9\-\.]+)/repos/([A-Za-z0-9\-]+)/builds", repos.BuildsHandler),
+ (r"/distros/([A-Za-z0-9\-\.]+)/repos/([A-Za-z0-9\-]+)/mirrorlist", repos.MirrorlistHandler),
- (r"/distro/([A-Za-z0-9\-\.]+)/repo/([A-Za-z0-9\-]+)/mirrorlist",
- RepositoryMirrorlistHandler),
(r"/distro/([A-Za-z0-9\-\.]+)/repo/([A-Za-z0-9\-]+)/edit",
RepositoryEditHandler),
self.render("repository-edit.html", distro=distro, repo=repo)
-class RepositoryMirrorlistHandler(base.BaseHandler):
- def get(self, distro, repo):
- distro = self.backend.distros.get_by_slug(distro)
- if not distro:
- raise tornado.web.HTTPError(404)
-
- repo = distro.get_repo(repo)
- if not repo:
- raise tornado.web.HTTPError(404)
-
- # Send nothing if repository isn't supposed to be mirrored
- if not repo.mirrored:
- raise tornado.web.HTTPError(404)
-
- # This is a plaintext file.
- self.set_header("Content-Type", "text/plain")
-
- # Fetch architecture
- arch = self.get_argument("arch")
-
- ret = {
- "type" : "mirrorlist",
- "version" : 1,
- }
-
- mirrors = []
- for mirror in self.backend.mirrors.make_mirrorlist(self.current_address):
- mirrors.append({
- "url" : "/".join((mirror.url, repo.basepath, arch)),
- "location" : mirror.country_code,
- })
-
- # Always use the buildservice itself as last resort
- mirrors.append({
- "url" : "/".join((repo.url, arch)),
- })
-
- ret["mirrors"] = mirrors
- self.finish(ret)
-
-
class RepoActionHandler(base.BaseHandler):
@tornado.web.authenticated
def post(self, type):
self.finish(config)
+class MirrorlistHandler(base.BaseHandler):
+ def get(self, distro_slug, repo_slug):
+ # Find the distribution
+ distro = self.backend.distros.get_by_slug(distro_slug)
+ if not distro:
+ raise tornado.web.HTTPError(404, "Could not find distro: %s" % distro_slug)
+
+ # Find the repository
+ repo = distro.get_repo(repo_slug)
+ if not repo:
+ raise tornado.web.HTTPError(404, "Could not find repo: %s" % repo_slug)
+
+ # Send nothing if repository isn't supposed to be mirrored
+ if not repo.mirrored:
+ raise tornado.web.HTTPError(404)
+
+ # Fetch architecture
+ arch = self.get_argument("arch")
+
+ mirrors = []
+
+ # Fetch mirrors
+ for mirror in self.backend.mirrors.make_mirrorlist(self.current_address):
+ mirrors.append({
+ "url" : "/".join((mirror.url, repo.path, arch)),
+ "location" : mirror.country_code,
+ })
+
+ # Always use the buildservice itself as last resort
+ mirrors.append({
+ "url" : "/".join((repo.url, arch)),
+ })
+
+ self.finish({
+ "type" : "mirrorlist",
+ "version" : 1,
+ "mirrors" : mirrors,
+ })
+
+
class ListModule(ui_modules.UIModule):
def render(self, repos):
return self.render_string("repos/modules/list.html", repos=repos)