]> git.ipfire.org Git - ipfire.org.git/blobdiff - webapp/backend/releases.py
webapp: Prepare for x86_64
[ipfire.org.git] / webapp / backend / releases.py
index 5da6c62b652eaf474b62cc2488a6ef2c9f089d47..6c556114187d5a91ff9a0fdb01d8a9331b3c02aa 100644 (file)
@@ -168,7 +168,7 @@ class File(Object):
 
        @property
        def arch(self):
-               known_arches = ("i586", "arm")
+               known_arches = ("x86_64", "i586", "arm")
 
                for arch in known_arches:
                        if arch in self.basename:
@@ -201,14 +201,14 @@ class File(Object):
                if not self.torrent_hash:
                        return
 
-               return self.tracker.get_seeds(self.torrent_hash)
+               return self.backend.tracker.complete(self.torrent_hash)
 
        @property
        def peers(self):
                if not self.torrent_hash:
                        return
 
-               return self.tracker.get_peers(self.torrent_hash)
+               return self.backend.tracker.incomplete(self.torrent_hash)
 
 
 class Release(Object):
@@ -365,20 +365,50 @@ class Release(Object):
                        if f:
                                f.close()
 
+       def supports_arch(self, arch):
+               return arch in ("x86_64", "i586")
+
+       def supports_platform(self, platform):
+               # Currently there is nothing else than pcbios supported
+               if platform == "pcbios":
+                       return True
+
+               return False
+
        def is_netboot_capable(self):
                return self.path and "ipfire-2.x" in self.path
 
-       @property
-       def netboot_kernel(self):
+       def netboot_kernel_url(self, arch, platform):
+               assert self.supports_arch(arch)
+               assert self.supports_platform(platform)
+
+               if self.sname >= "ipfire-2.19-core100":
+                       return "http://downloads.ipfire.org/%s/images/%s/vmlinuz" % (self.path, arch)
+
                return "http://downloads.ipfire.org/%s/images/vmlinuz" % self.path
 
-       @property
-       def netboot_initrd(self):
+       def netboot_initrd_url(self, arch, platform):
+               assert self.supports_arch(arch)
+               assert self.supports_platform(platform)
+
+               if self.sname >= "ipfire-2.19-core100":
+                       return "http://downloads.ipfire.org/%s/images/%s/instroot" % (self.path, arch)
+
                return "http://downloads.ipfire.org/%s/images/instroot" % self.path
 
+       def netboot_args(self, arch, platform):
+               return ""
+
+       @property
+       def news_id(self):
+               return self.__data.news_id
+
        @property
-       def netboot_append(self):
-               return "ro"
+       def news(self):
+               if not hasattr(self, "_news"):
+                       self._news = self.backend.news.get(self.news_id)
+
+               return self._news
 
 
 class Releases(Object):
@@ -394,6 +424,12 @@ class Releases(Object):
                if ret:
                        return Release(self.backend, ret.id, data=ret)
 
+       def get_by_news_id(self, news_id):
+               ret = self.db.get("SELECT * FROM releases WHERE news_id = %s", news_id)
+
+               if ret:
+                       return Release(self.backend, ret.id, data=ret)
+
        def get_latest(self, stable=True):
                ret = self.db.get("SELECT * FROM releases WHERE published IS NOT NULL AND published <= NOW() \
                        AND stable = %s ORDER BY published DESC LIMIT 1", stable)