]> git.ipfire.org Git - people/shoehn/ipfire.org.git/commitdiff
mirrors: Automatically generate mirror lists for pakfire 2.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Jun 2013 11:24:12 +0000 (13:24 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Jun 2013 11:24:12 +0000 (13:24 +0200)
webapp/__init__.py
webapp/backend/mirrors.py
webapp/handlers_mirrors.py

index 3788e5f6fcb574ed1ca04b33dfe2e757b0a49535..86a695046359979a86e5338a1537870756de6046 100644 (file)
@@ -118,6 +118,7 @@ class Application(tornado.web.Application):
                self.add_handlers(r"mirrors\.ipfire\.org", [
                        (r"/", MirrorIndexHandler),
                        (r"/mirror/([0-9]+)", MirrorItemHandler),
+                       (r"/lists/pakfire2", MirrorListPakfire2Handler),
                ] + static_handlers)
 
                # planet.ipfire.org
index 38040464e699d3149363eba81908b6a0bcf83bf6..4f6fc665d305988a4bf45fc4fa03ed1336a53793 100644 (file)
@@ -535,3 +535,5 @@ class Mirror(object):
        def priority(self):
                return self._info.get("priority", 10)
 
+       def is_pakfire2(self):
+               return self.type in ("full", "pakfire2")
index d1a8a640fa90d6f153877148b283dd813d37a670..8278ee0d7fa5ab62aa51cbf388f5e1bf178c35ed 100644 (file)
@@ -51,3 +51,43 @@ class MirrorAllHandler(BaseHandler):
 class MirrorDetailHandler(BaseHandler):
        def get(self, id):
                self.render("download-mirror-detail.html", mirror=self.mirrors.get(id))
+
+
+class MirrorListPakfire2Handler(BaseHandler):
+       def get(self):
+               suffix = self.get_argument("suffix", "")
+
+               self.set_header("Content-Type", "text/plain")
+
+               mirrors = self.mirrors.get_all()
+
+               lines = []
+               for m in mirrors:
+                       if not m.is_pakfire2():
+                               continue
+
+                       path = [m.path,]
+
+                       if m.type == "full":
+                               path.append("pakfire2")
+
+                       if suffix:
+                               path.append(suffix)
+
+                       path = "/".join(path)
+
+                       # Remove double slashes.
+                       path = path.replace("//", "/")
+
+                       # Remove leading slash.
+                       if path.startswith("/"):
+                               path = path[1:]
+
+                       # Remove trailing slash.
+                       if path.endswith("/"):
+                               path = path[:-1]
+
+                       line = ("HTTP", m.hostname, path, "")
+                       lines.append(";".join(line))
+
+               self.finish("\r\n".join(lines))