Title: [288810] trunk/Tools
Revision
288810
Author
[email protected]
Date
2022-01-31 04:46:42 -0800 (Mon, 31 Jan 2022)

Log Message

[Flatpak SDK] No longer updating due to expired GPG key
https://bugs.webkit.org/show_bug.cgi?id=235869

Patch by Philippe Normand <[email protected]> on 2022-01-31
Reviewed by Adrian Perez de Castro.

Manually synchronize the SDK GPG key in case our local copy is detected as expired.

This patch includes a drive-by fix regarding toolchains updates. Those were always
regenerated when updating the SDK, because the zip path was assumed to be a host path,
whereas it is actually a path in the sandbox.

* flatpak/flatpakutils.py:
(run_sanitized):
(FlatpakObject.flatpak):
(FlatpakObject.flatpak_update):
(FlatpakPackage.install):
(WebkitFlatpak._reset_repository):
(WebkitFlatpak.host_path_to_sandbox_path):
(WebkitFlatpak.sandbox_path_to_host_path):
(WebkitFlatpak.main):
(WebkitFlatpak.check_toolchains_generated):
(FlatpakPackage.update): Deleted.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (288809 => 288810)


--- trunk/Tools/ChangeLog	2022-01-31 12:13:09 UTC (rev 288809)
+++ trunk/Tools/ChangeLog	2022-01-31 12:46:42 UTC (rev 288810)
@@ -1,3 +1,28 @@
+2022-01-31  Philippe Normand  <[email protected]>
+
+        [Flatpak SDK] No longer updating due to expired GPG key
+        https://bugs.webkit.org/show_bug.cgi?id=235869
+
+        Reviewed by Adrian Perez de Castro.
+
+        Manually synchronize the SDK GPG key in case our local copy is detected as expired.
+
+        This patch includes a drive-by fix regarding toolchains updates. Those were always
+        regenerated when updating the SDK, because the zip path was assumed to be a host path,
+        whereas it is actually a path in the sandbox.
+
+        * flatpak/flatpakutils.py:
+        (run_sanitized):
+        (FlatpakObject.flatpak):
+        (FlatpakObject.flatpak_update):
+        (FlatpakPackage.install):
+        (WebkitFlatpak._reset_repository):
+        (WebkitFlatpak.host_path_to_sandbox_path):
+        (WebkitFlatpak.sandbox_path_to_host_path):
+        (WebkitFlatpak.main):
+        (WebkitFlatpak.check_toolchains_generated):
+        (FlatpakPackage.update): Deleted.
+
 2022-01-31  Carlos Garcia Campos  <[email protected]>
 
         [GTK][a11y] Add support for password fields to ATSPI

Modified: trunk/Tools/flatpak/flatpakutils.py (288809 => 288810)


--- trunk/Tools/flatpak/flatpakutils.py	2022-01-31 12:13:09 UTC (rev 288809)
+++ trunk/Tools/flatpak/flatpakutils.py	2022-01-31 12:46:42 UTC (rev 288810)
@@ -69,6 +69,10 @@
 # in our SDK build definitions please don't forget to update the version here as well.
 SDK_BRANCH = "21.08"
 
+WEBKIT_SDK_FLATPAK_REPO_URL = "https://software.igalia.com/flatpak-refs/webkit-sdk.flatpakrepo"
+WEBKIT_SDK_GPG_PUBKEY_URL = "https://software.igalia.com/flatpak-refs/webkit-sdk-pubkey.gpg"
+WEBKIT_SDK_REPO_URL = "https://software.igalia.com/webkit-sdk-repo/"
+
 is_colored_output_supported = False
 try:
     import curses
@@ -128,7 +132,7 @@
         cls.colored_message_if_supported(Colors.WARNING, str_format, *args)
 
 
-def run_sanitized(command, gather_output=False, ignore_stderr=False, env=None):
+def run_sanitized(command, gather_output=False, ignore_stderr=False, env=None, **kwargs):
     """ Runs a command in a santized environment and optionally returns decoded output or raises
         subprocess.CalledProcessError
     """
@@ -144,7 +148,8 @@
         pass
 
     _log.debug("Running %s", " ".join(command))
-    keywords = dict(env=sanitized_env)
+    keywords = kwargs
+    keywords['env'] = sanitized_env
     if gather_output:
         if ignore_stderr:
             with open(os.devnull, 'w') as devnull:
@@ -154,7 +159,12 @@
         return output.strip().decode('utf-8')
     else:
         keywords["stdout"] = sys.stdout
-        return subprocess.check_call(command, **keywords)
+        if ignore_stderr:
+            with open(os.devnull, 'w') as devnull:
+                keywords["stderr"] = devnull
+                return subprocess.check_call(command, **keywords)
+        else:
+            return subprocess.check_call(command, **keywords)
 
 
 def check_flatpak(verbose=True):
@@ -196,7 +206,6 @@
     def flatpak(self, command, *args, **kwargs):
         comment = kwargs.pop("comment", None)
         gather_output = kwargs.get("gather_output", False)
-        ignore_stderr = kwargs.get("ignore_stderr", False)
         if comment:
             Console.message(comment)
 
@@ -211,8 +220,7 @@
 
         command.extend(args)
 
-        _log.debug("Executing %s" % ' '.join(command))
-        return run_sanitized(command, gather_output=gather_output, ignore_stderr=ignore_stderr)
+        return run_sanitized(command, **kwargs)
 
     def version(self, ref_id):
         try:
@@ -228,6 +236,21 @@
                 return tokens[1].strip()
         return ""
 
+    def flatpak_update(self):
+        remote = "webkit-sdk"
+        try:
+            self.flatpak("remote-ls", remote, gather_output=True)
+        except subprocess.CalledProcessError as error:
+            if error.output.lower().find("key expired"):
+                Console.message("WebKit SDK GPG key expired, synchronizing with remote")
+                with tempfile.NamedTemporaryFile() as tmpfile:
+                    fd = urlopen(WEBKIT_SDK_GPG_PUBKEY_URL)
+                    tmpfile.write(fd.read())
+                    tmpfile.flush()
+                    self.flatpak("remote-modify", "--gpg-import=" + tmpfile.name, remote)
+
+        self.flatpak("update", comment="Updating Flatpak environment")
+
 class FlatpakPackages(FlatpakObject):
 
     def __init__(self, repos, user=True):
@@ -393,14 +416,6 @@
         self.flatpak(*args, comment=comment)
         self.repo.repos.packages.update()
 
-    def update(self):
-        if not self.is_installed(self.branch):
-            return self.install()
-
-        comment = "Updating %s" % self.name
-        self.flatpak("update", self.name, self.branch, comment=comment)
-
-
 @contextmanager
 def disable_signals(signals=[signal.SIGINT, signal.SIGTERM, signal.SIGHUP]):
     old_signal_handlers = []
@@ -604,8 +619,8 @@
         return True
 
     def _reset_repository(self):
-        url = ""
-        repo_file = "https://software.igalia.com/flatpak-refs/webkit-sdk.flatpakrepo"
+        url = ""
+        repo_file = WEBKIT_SDK_FLATPAK_REPO_URL
         if self.user_repo:
             url = "" % self.user_repo
             repo_file = None
@@ -702,9 +717,13 @@
         return command and "build-jsc" in os.path.basename(command)
 
     def host_path_to_sandbox_path(self, host_path):
-        # For now this supports only files in the WebKit path
+        # For now this supports only files in the /app/webkit path
         return host_path.replace(self.source_root, self.sandbox_source_root)
 
+    def sandbox_path_to_host_path(self, sandbox_path):
+        # For now this supports only files in the /app/webkit path
+        return sandbox_path.replace(self.sandbox_source_root, self.source_root)
+
     @staticmethod
     def get_user_runtime_dir():
         return os.environ.get('XDG_RUNTIME_DIR', os.path.join('/run/user', str(os.getuid())))
@@ -1008,10 +1027,10 @@
             return 0
 
         if self.update:
-            repo = self.sdk_repo
-            version_before_update = repo.version("org.webkit.Sdk")
-            repo.flatpak("update", comment="Updating Flatpak %s environment" % self.build_type)
-            regenerate_toolchains = (repo.version("org.webkit.Sdk") != version_before_update) or not self.check_toolchains_generated()
+            flatpak_wrapper = FlatpakObject(True)
+            version_before_update = flatpak_wrapper.version("org.webkit.Sdk")
+            flatpak_wrapper.flatpak_update()
+            regenerate_toolchains = (flatpak_wrapper.version("org.webkit.Sdk") != version_before_update) or not self.check_toolchains_generated()
 
             # If we have an out-of-date package, simply remove the entire flatpak directory and start over.
             for package in self._get_dependency_packages():
@@ -1125,7 +1144,7 @@
                 config = json.load(config_fd)
                 if 'icecc_version' in config:
                     for compiler in config['icecc_version']:
-                        if os.path.isfile(config['icecc_version'][compiler]):
+                        if os.path.isfile(self.sandbox_path_to_host_path(config['icecc_version'][compiler])):
                             found_toolchains += 1
         return found_toolchains > 1
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to