[pitivi/1.0] flatpak: Update to 3.28



commit c01df16504976f8376511dbcfd87d60be64a72f4
Author: Thibault Saunier <tsaunier igalia com>
Date:   Sat Jul 7 23:57:02 2018 -0400

    flatpak: Update to 3.28
    
    Update the flatpak version check as we now require 0.10. Also cleanup
    the way we check Sdk version.

 .gitlab-ci.yml                       |   4 +-
 build/flatpak/org.pitivi.Pitivi.json |   2 +-
 build/flatpak/pitivi-flatpak         | 102 ++++++++++++++++++++++-------------
 pitivi/titleeditor.py                |   4 +-
 pitivi/undo/timeline.py              |   5 +-
 5 files changed, 75 insertions(+), 42 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 009f9021..59f550c1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,10 @@
-image: thiblahute/pitivi-ci
+image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:3.28
 
 build:
   stage: build
   cache:
     paths:
-      - .flatpak-builder/
+      - .flatpak-builder
   script:
     - ls -a
     - export
diff --git a/build/flatpak/org.pitivi.Pitivi.json b/build/flatpak/org.pitivi.Pitivi.json
index 8b744231..794013db 100644
--- a/build/flatpak/org.pitivi.Pitivi.json
+++ b/build/flatpak/org.pitivi.Pitivi.json
@@ -2,7 +2,7 @@
     "app-id": "org.pitivi.Pitivi",
     "branch": "1.0",
     "runtime": "org.gnome.Platform",
-    "runtime-version": "3.24",
+    "runtime-version": "3.28",
     "command": "pitivi",
     "finish-args": [
         "--socket=x11",
diff --git a/build/flatpak/pitivi-flatpak b/build/flatpak/pitivi-flatpak
index ecaaefad..6a595ff6 100755
--- a/build/flatpak/pitivi-flatpak
+++ b/build/flatpak/pitivi-flatpak
@@ -37,12 +37,10 @@ PITIVI_BRANCH = "master"
 MANIFEST_NAME = "org.pitivi.Pitivi.json"
 # To see the existing branches, run:
 # flatpak remote-ls pitivi --user -d
-SDK_BRANCH = {"0.96": "3.20",
-              "0.97.1": "3.20",
-              "0.98": "3.22",
-              "stable": "3.24",
-              "master": "3.24"}
-FLATPAK_REQ = "0.6.4"
+FLATPAK_REQ = [
+    ("flatpak", "0.10.0"),
+    ("flatpak-builder", "0.10.0"),
+]
 DEFAULT_GST_BRANCH = "1.14"
 
 
@@ -74,17 +72,39 @@ class Console:  # pylint: disable=too-few-public-methods
         sys.stdout.flush()
 
 
-def expand_json_file(json_template, outfile, basedir, gst_version, branchname):
+def remove_comments(string):
+    pattern = r"(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*$)"
+    # first group captures quoted strings (double or single)
+    # second group captures comments (//single-line or /* multi-line */)
+    regex = re.compile(pattern, re.MULTILINE | re.DOTALL)
+
+    def _replacer(match):
+        # if the 2nd group (capturing comments) is not None,
+        # it means we have captured a non-quoted (real) comment string.
+        if match.group(2) is not None:
+            return ""  # so we will return empty to remove the comment
+
+        return match.group(1)  # captured quoted-string
+    return regex.sub(_replacer, string)
+
+
+def load_manifest(manifest_path):
+    with open(manifest_path, "r") as mr:
+        contents = mr.read()
+        contents = remove_comments(contents)
+        manifest = json.loads(contents)
+
+    return manifest
+
+
+def expand_manifest(manifest_path, outfile, basedir, gst_version, branchname):
     """Creates the manifest file."""
     try:
         os.remove(outfile)
     except FileNotFoundError:
         pass
 
-    with open(json_template, "r") as tf:
-        txt = re.sub(r"/\*[^*]*\*+(?:[^/*][^*]*\*+)*/", "", tf.read())
-
-    template = json.loads(txt)
+    template = load_manifest(manifest_path)
     if branchname == "stable":
         try:
             del template["desktop-file-name-prefix"]
@@ -385,38 +405,48 @@ class PitiviFlatpak:  # pylint: disable=too-many-instance-attributes
         self.coredumpctl_matches = ""
 
     @staticmethod
-    def check_flatpak():
-        try:
-            output = subprocess.check_output(["flatpak", "--version"])
-        except FileNotFoundError:
-            Console.message("\n%sYou need to install flatpak >= %s"
-                            " to be able to use the '%s' script.\n\n"
-                            "You can find some information about"
-                            " how to install it for your distribution at:\n"
-                            "    * http://flatpak.org/%s\n";, Colors.FAIL,
-                            FLATPAK_REQ, sys.argv[0], Colors.ENDC)
-            exit(1)
+    def check_flatpak(verbose=True):
+        for app, required_version in FLATPAK_REQ:
+            try:
+                output = subprocess.check_output([app, "--version"])
+            except (subprocess.CalledProcessError, OSError):
+                if verbose:
+                    Console.message("\n%sYou need to install %s >= %s"
+                                    " to be able to use the '%s' script.\n\n"
+                                    "You can find some informations about"
+                                    " how to install it for your distribution at:\n"
+                                    "    * http://flatpak.org/%s\n";, Colors.FAIL,
+                                    app, required_version, sys.argv[0], Colors.ENDC)
+                return False
 
-        def comparable_version(version):
-            return [int(number) for number in version.split(".")]
+            def comparable_version(version):
+                return tuple(map(int, (version.split("."))))
 
-        version = output.decode("utf-8").split(" ")[1].strip("\n")
-        if comparable_version(version) < comparable_version(FLATPAK_REQ):
-            Console.message("\n%sFlatpak %s required but %s found."
-                            " Please update and try again%s\n", Colors.FAIL,
-                            FLATPAK_REQ, version, Colors.ENDC)
-            exit(1)
+            version = output.decode("utf-8").split(" ")[1].strip("\n")
+            if comparable_version(version) < 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)
+                return False
+
+        return True
 
     def clean_args(self):
         Console.quiet = self.quiet
 
-        self.check_flatpak()
+        if not self.check_flatpak():
+            exit(1)
 
         repos = FlatpakRepos()
         self.sdk_repo = repos.add("flathub",
                                   "https://dl.flathub.org/repo/flathub.flatpakrepo";)
 
-        sdk_branch = SDK_BRANCH[self.branch]
+        manifest_path = os.path.join(self.scriptdir, MANIFEST_NAME)
+        manifest = load_manifest(manifest_path)
+        if not manifest:
+            return
+
+        sdk_branch = manifest["runtime-version"]
         self.runtime = FlatpakPackage(
             "org.gnome.Platform", sdk_branch, self.sdk_repo, "x86_64")
         self.locale = FlatpakPackage(
@@ -515,10 +545,10 @@ class PitiviFlatpak:  # pylint: disable=too-many-instance-attributes
         Console.message("Building Pitivi %s and dependencies in %s",
                         self.branch, self.prefix)
 
-        json_template = os.path.join(self.scriptdir, MANIFEST_NAME)
-        expand_json_file(json_template, self.json,
-                         self.local_repos_path, self.gst_version,
-                         self.branch)
+        manifest_path = os.path.join(self.scriptdir, MANIFEST_NAME)
+        expand_manifest(manifest_path, self.json,
+                        self.local_repos_path, self.gst_version,
+                        self.branch)
 
         builder_args = ["flatpak-builder", "--force-clean",
                         "--ccache", self.prefix, self.json]
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index 1c899642..67a58048 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -49,8 +49,8 @@ PreferencesDialog.addNumericPreference('titleClipLength',
 FOREGROUND_DEFAULT_COLOR = 0xFFFFFFFF  # White
 BACKGROUND_DEFAULT_COLOR = 0x00000000  # Transparent
 DEFAULT_FONT_DESCRIPTION = "Sans 36"
-DEFAULT_VALIGNMENT = GES.TextVAlign.ABSOLUTE
-DEFAULT_HALIGNMENT = GES.TextHAlign.ABSOLUTE
+DEFAULT_VALIGNMENT = GES.TextVAlign.ABSOLUTE.real
+DEFAULT_HALIGNMENT = GES.TextHAlign.ABSOLUTE.real
 
 
 class TitleEditor(Loggable):
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 12d46a6e..b21ded42 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -77,7 +77,9 @@ class TrackElementPropertyChanged(UndoableAction):
         if isinstance(self.new_value, GObject.GFlags) or\
                 isinstance(self.new_value, GObject.GEnum):
             value = int(self.new_value)
-        st['value'] = value
+
+        _, _, pspec = self.track_element.lookup_child(self.property_name)
+        st['value'] = GObject.Value(pspec.value_type, value)
         return st
 
 
@@ -633,6 +635,7 @@ class ControlSourceRemoveAction(UndoableAction):
         st.set_value("property-name", self.property_name)
         return st
 
+
 class LayerObserver(MetaContainerObserver, Loggable):
     """Monitors a Layer and reports UndoableActions.
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]