Title: [261076] trunk/Tools
Revision
261076
Author
[email protected]
Date
2020-05-04 01:23:44 -0700 (Mon, 04 May 2020)

Log Message

[Flatpak SDK] Query the doc portal path with DBus
https://bugs.webkit.org/show_bug.cgi?id=211281

Patch by Philippe Normand <[email protected]> on 2020-05-04
Reviewed by Žan Doberšek.

* flatpak/flatpakutils.py:
(WebkitFlatpak.run_in_sandbox):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (261075 => 261076)


--- trunk/Tools/ChangeLog	2020-05-04 07:28:39 UTC (rev 261075)
+++ trunk/Tools/ChangeLog	2020-05-04 08:23:44 UTC (rev 261076)
@@ -1,3 +1,13 @@
+2020-05-04  Philippe Normand  <[email protected]>
+
+        [Flatpak SDK] Query the doc portal path with DBus
+        https://bugs.webkit.org/show_bug.cgi?id=211281
+
+        Reviewed by Žan Doberšek.
+
+        * flatpak/flatpakutils.py:
+        (WebkitFlatpak.run_in_sandbox):
+
 2020-05-04  Emilio Cobos Álvarez  <[email protected]>
 
         Put lh / rlh units behind a flag until bug 211351 is sorted out.

Modified: trunk/Tools/Scripts/run-bindings-tests (261075 => 261076)


--- trunk/Tools/Scripts/run-bindings-tests	2020-05-04 07:28:39 UTC (rev 261075)
+++ trunk/Tools/Scripts/run-bindings-tests	2020-05-04 08:23:44 UTC (rev 261076)
@@ -33,10 +33,11 @@
 import sys
 from webkitpy.common.system import executive
 
-top_level_directory = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
-sys.path.insert(0, os.path.join(top_level_directory, 'Tools', 'flatpak'))
-import flatpakutils
-flatpakutils.run_in_sandbox_if_available(sys.argv)
+if sys.platform.startswith('linux'):
+    top_level_directory = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
+    sys.path.insert(0, os.path.join(top_level_directory, 'Tools', 'flatpak'))
+    import flatpakutils
+    flatpakutils.run_in_sandbox_if_available(sys.argv)
 
 def main(argv):
     """Runs WebCore bindings code generators on test IDL files and compares

Modified: trunk/Tools/flatpak/flatpakutils.py (261075 => 261076)


--- trunk/Tools/flatpak/flatpakutils.py	2020-05-04 07:28:39 UTC (rev 261075)
+++ trunk/Tools/flatpak/flatpakutils.py	2020-05-04 08:23:44 UTC (rev 261076)
@@ -33,6 +33,8 @@
 import tempfile
 import re
 
+from gi.repository import Gio, GLib
+
 from webkitpy.common.system.systemhost import SystemHost
 from webkitpy.port.factory import PortFactory
 from webkitpy.common.system.logutils import configure_logging
@@ -673,22 +675,19 @@
                 "--talk-name=org.freedesktop.Flatpak"
             ])
 
-            xdg_runtime_dir = os.environ.get('XDG_RUNTIME_DIR', None)
-            if not xdg_runtime_dir:
-                _log.debug('XDG_RUNTIME_DIR not set. Trying default location.')
-                try:
-                    with open(os.devnull, 'w') as devnull:
-                        uid = subprocess.check_output(("id", "-u"), stderr=devnull).decode().strip()
-                        xdg_runtime_dir = '/run/user/{uid}'.format(uid=uid)
-                except subprocess.CalledProcessError:
-                    _log.debug("Could not determine XDG_RUNIME_DIR. This may cause bubblewrap to fail.")
+            bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
+            proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None,
+                                           'org.freedesktop.portal.Documents',
+                                           '/org/freedesktop/portal/documents',
+                                           'org.freedesktop.portal.Documents', None)
+            document_portal_mount_point = proxy.call_sync('GetMountPoint', None, Gio.DBusCallFlags.NONE,
+                                                          GLib.MAXINT, None)
+            uid_doc_path = ''.join([chr(x) for x in document_portal_mount_point.unpack()[0][:-1]])
 
-            if xdg_runtime_dir:
-                uid_doc_path = os.path.join(xdg_runtime_dir, 'doc')
-                if os.path.exists(uid_doc_path):
-                    flatpak_command.append("--bind-mount={uid_doc_path}={uid_doc_path}".format(uid_doc_path=uid_doc_path))
-                else:
-                    _log.debug("Can't find user document path at '{uid_doc_path}'. Not mounting it.".format(uid_doc_path=uid_doc_path))
+            if os.path.exists(uid_doc_path):
+                flatpak_command.append("--bind-mount={uid_doc_path}={uid_doc_path}".format(uid_doc_path=uid_doc_path))
+            else:
+                _log.debug("Can't find user document path at '{uid_doc_path}'. Not mounting it.".format(uid_doc_path=uid_doc_path))
 
             forwarded.update({
                 "TZ": "PST8PDT",
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to