]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
mirror list: Use new arch concept
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Oct 2017 12:47:25 +0000 (13:47 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Oct 2017 12:47:25 +0000 (13:47 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/arches.py
src/web/handlers.py

index f8d2849e3eaff28b18483facb1da06fdb7c3dd56..e9c2fc76ccf6c0c35215521660b1e439b683ad8b 100644 (file)
@@ -26,7 +26,20 @@ class Arches(base.Object):
                res = self.db.query("SELECT name FROM arches \
                        WHERE NOT name = ANY(%s)", ("noarch", "src"))
 
-               return sorted((a.name for a in res), key=priority)
+               return iter(sorted((a.name for a in res), key=priority))
+
+       def exists(self, name):
+               # noarch doesn't really exist
+               if name == "noarch":
+                       return False
+
+               res = self.db.get("SELECT 1 FROM arches \
+                       WHERE name = %s", name)
+
+               if res:
+                       return True
+
+               return False
 
        def get_all(self, really=False):
                query = "SELECT * FROM arches"
index 2d88d55a4459b391cfd55b81b4e4f5584520ab43..b1b3eca858a3c94aee8187eea65cdc9a5dec66e7 100644 (file)
@@ -209,10 +209,8 @@ class RepositoryMirrorlistHandler(BaseHandler):
                self.set_header("Content-Type", "text/plain")
 
                arch = self.get_argument("arch", None)
-               arch = self.pakfire.arches.get_by_name(arch)
-
-               if not arch:
-                       raise tornado.web.HTTPError(400, "You must specify the architecture.")
+               if not arch or not self.backend.arches.exists(arch):
+                       raise tornado.web.HTTPError(400, "You must specify a valid architecture")
 
                ret = {
                        "type"    : "mirrorlist",
@@ -229,7 +227,7 @@ class RepositoryMirrorlistHandler(BaseHandler):
                        # Select a list of preferred mirrors
                        for mirror in self.mirrors.get_for_location(self.current_address):
                                mirrors.append({
-                                       "url"       : "/".join((mirror.url, distro.identifier, repo.identifier, arch.name)),
+                                       "url"       : "/".join((mirror.url, distro.identifier, repo.identifier, arch)),
                                        "location"  : mirror.country_code,
                                        "preferred" : 1,
                                })
@@ -240,7 +238,7 @@ class RepositoryMirrorlistHandler(BaseHandler):
 
                        for mirror in remaining_mirrors:
                                mirrors.append({
-                                       "url"       : "/".join((mirror.url, distro.identifier, repo.identifier, arch.name)),
+                                       "url"       : "/".join((mirror.url, distro.identifier, repo.identifier, arch)),
                                        "location"  : mirror.country_code,
                                        "preferred" : 0,
                                })
@@ -256,7 +254,7 @@ class RepositoryMirrorlistHandler(BaseHandler):
                                        continue
 
                                mirror = {
-                                       "url"       : "/".join((mirror.url, distro.identifier, repo.identifier, arch.name)),
+                                       "url"       : "/".join((mirror.url, distro.identifier, repo.identifier, arch)),
                                        "location"  : mirror.country_code,
                                        "preferred" : 0,
                                }