Title: [242040] trunk/Tools
Revision
242040
Author
[email protected]
Date
2019-02-25 07:46:24 -0800 (Mon, 25 Feb 2019)

Log Message

[Flatpak] Add support for flatpak > 1.1.2
https://bugs.webkit.org/show_bug.cgi?id=194088

Flatpak 1.2 is now out so we need to support that
version now.

Patch by Thibault Saunier <[email protected]> on 2019-02-25
Reviewed by Michael Catanzaro.

* flatpak/flatpakutils.py:
(check_flatpak):
(FlatpakPackages.__init__):
(FlatpakPackages.__detect_packages):
(FlatpakPackages.__detect_packages.in):
(FlatpakRepos.update):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (242039 => 242040)


--- trunk/Tools/ChangeLog	2019-02-25 15:07:35 UTC (rev 242039)
+++ trunk/Tools/ChangeLog	2019-02-25 15:46:24 UTC (rev 242040)
@@ -1,3 +1,20 @@
+2019-02-25  Thibault Saunier  <[email protected]>
+
+        [Flatpak] Add support for flatpak > 1.1.2
+        https://bugs.webkit.org/show_bug.cgi?id=194088
+
+        Flatpak 1.2 is now out so we need to support that
+        version now.
+
+        Reviewed by Michael Catanzaro.
+
+        * flatpak/flatpakutils.py:
+        (check_flatpak):
+        (FlatpakPackages.__init__):
+        (FlatpakPackages.__detect_packages):
+        (FlatpakPackages.__detect_packages.in):
+        (FlatpakRepos.update):
+
 2019-02-25  Zan Dobersek  <[email protected]>
 
         [WPE] Bump WPEBackend-fdo Jhbuild package to latest changes

Modified: trunk/Tools/flatpak/flatpakutils.py (242039 => 242040)


--- trunk/Tools/flatpak/flatpakutils.py	2019-02-25 15:07:35 UTC (rev 242039)
+++ trunk/Tools/flatpak/flatpakutils.py	2019-02-25 15:46:24 UTC (rev 242040)
@@ -52,6 +52,8 @@
     ("flatpak-builder", "0.10.0"),
 ]
 
+FLATPAK_VERSION = {}
+
 WPE_MANIFEST_MAP = {
     "qt": "org.webkit.WPEQT.yaml",
 }
@@ -110,7 +112,9 @@
             return tuple(map(int, (version.split("."))))
 
         version = output.decode("utf-8").split(" ")[1].strip("\n")
-        if comparable_version(version) < comparable_version(required_version):
+        current = comparable_version(version)
+        FLATPAK_VERSION[app] = current
+        if current < comparable_version(required_version):
             Console.message("\n%s%s %s required but %s found."
                             " Please update and try again%s\n", Colors.FAIL,
                             app, required_version, version, Colors.ENDC)
@@ -260,23 +264,35 @@
         self.apps = self.__detect_apps()
         self.packages = self.runtimes + self.apps
 
+
     def __detect_packages(self, *args):
         packs = []
-        package_defs = [rd
-                        for rd in self.flatpak("list", "-d", "--all", *args).split("\n")
-                        if rd]
-        for package_def in package_defs:
-            splited_packaged_def = package_def.split()
-            name, arch, branch = splited_packaged_def[0].split("/")
+        if FLATPAK_VERSION["flatpak"] < (1, 1, 2):
+            out = self.flatpak("list", "-d", *args)
+            package_defs = [line for line in out.split("\n") if line]
+            for package_def in package_defs:
+                splited_packaged_def = package_def.split()
+                name, arch, branch = splited_packaged_def[0].split("/")
 
-            # If installed from a file, the package is in no repo
-            repo_name = splited_packaged_def[1]
-            repo = self.repos.repos.get(repo_name)
+                # If installed from a file, the package is in no repo
+                repo_name = splited_packaged_def[1]
+                repo = self.repos.repos.get(repo_name)
 
-            packs.append(FlatpakPackage(name, branch, repo, arch))
+                packs.append(FlatpakPackage(name, branch, repo, arch))
+        else:
+            out = self.flatpak("list", "--columns=application,arch,branch,origin", *args)
+            package_defs = [line for line in out.split("\n") if line]
+            for package_def in package_defs:
+                name, arch, branch, origin = package_def.split("\t")
 
+                # If installed from a file, the package is in no repo
+                repo = self.repos.repos.get(origin)
+
+                packs.append(FlatpakPackage(name, branch, repo, arch))
+
         return packs
 
+
     def __detect_runtimes(self):
         return self.__detect_packages("--runtime")
 
@@ -297,37 +313,48 @@
 
     def update(self):
         self.repos = {}
-        remotes = [row
-                   for row in self.flatpak("remote-list", "-d").split("\n")
-                   if row]
-        for repo in remotes:
-            for components in [repo.split(" "), repo.split("\t")]:
-                if len(components) == 1:
-                    components = repo.split("\t")
-                name = components[0]
-                desc = ""
-                url = ""
-                for elem in components[1:]:
-                    if not elem:
-                        continue
-                    parsed_url = urlparse(elem)
-                    if parsed_url.scheme:
-                        url = ""
+        if FLATPAK_VERSION["flatpak"] < (1, 1, 2):
+            out = self.flatpak("remote-list", "-d")
+            remotes = [line for line in out.split("\n") if line]
+            for repo in remotes:
+                for components in [repo.split(" "), repo.split("\t")]:
+                    if len(components) == 1:
+                        components = repo.split("\t")
+                    name = components[0]
+                    desc = ""
+                    url = ""
+                    for elem in components[1:]:
+                        if not elem:
+                            continue
+                        parsed_url = urlparse(elem)
+                        if parsed_url.scheme:
+                            url = ""
+                            break
+
+                        if desc:
+                            desc += " "
+                        desc += elem
+
+                    if url:
                         break
 
-                    if desc:
-                        desc += " "
-                    desc += elem
+                if not url:
+                    Console.message("No valid URI found for: %s", repo)
+                    continue
 
-                if url:
-                    break
+                self.repos[name] = FlatpakRepo(name, url, desc, repos=self)
+        else:
+            out = self.flatpak("remote-list", "--columns=name,title,url")
+            remotes = [line for line in out.split("\n") if line]
+            for remote in remotes:
+                name, title, url = ""
+                parsed_url = urlparse(url)
+                if not parsed_url.scheme:
+                    Console.message("No valid URI found for: %s", remote)
+                    continue
 
-            if not url:
-                Console.message("No valid URI found for: %s", repo)
-                continue
+                self.repos[name] = FlatpakRepo(name, url, title, repos=self)
 
-            self.repos[name] = FlatpakRepo(name, url, desc, repos=self)
-
         self.packages = FlatpakPackages(self)
 
     def add(self, repo, override=True):
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to