Subject: [PATCH] gnu: flatpak: Update to 1.16.0.

From: aurtzy <[email-masked]>
Date: Mon, 3 Feb 2025 18:18:06 -0500

* gnu/packages/package-management.scm (flatpak): Update to 1.16.0.
[build-system]: Switch to meson-build-system, which is now the recommended
build system upstream.
[arguments]<#:configure-flags>: Use equivalent options for meson.
<#:phases>: Enable running more tests, disabling a select few in new
'disable-failing-tests phase.  Remove 'check phase override.  Add
'pre-check phase.  Add 'wrap-flatpak phase so GIO can still find TLS backend
with the build system change.
[native-inputs]: Add gtk-doc.
[inputs]: Add bash-minimal.

Change-Id: Iacf5c527e7a1cce7f418cecf73bb89018fcec71e
---

Hi!

Meson is now the recommended build system for Flatpak [1], so I have had a go at
making flatpak use meson-build-system in this patch.  Most configure flags had
one-to-one equivalents, but there were two exceptions:
1. The --with-curl option doesn't seem to have an equivalent meson option, but
   there is an http_backend option that already defaults to "curl"; perhaps this
   can be simply dropped?  This patch drops it with no noticeable issues,
   although I'm not sure what I'd test to make sure.
2. The --enable-documentation option also has no equivalent.  I wasn't sure what
   the FIXME comment was specifically referring to (git-blamed commit didn't
   have context), but adding gtk-doc appears to enable generating documentation
   just fine; would this be considered a fix?

According to the issue that led to using glib-or-gtk-build-system [2], there was
a TLS problem that was fixed by including GIO modules from glib-networking.  My
system didn't exhibit any sort of behavior related to this while updating
flatpak though (i.e. still worked without wrapper), so I'm not sure what the
correct course of action is for this or if there'd be breakage on other systems.

I opted for a wrap-program to include glib-networking in GIO_EXTRA_MODULES in
case the issue still applies.  Note that this ignores some other GIO modules and
XDG_DATA_DIRS directories that glib-or-gtk-build-system had additional wrappings
for.

[1] https://github.com/flatpak/flatpak/blob/main/CONTRIBUTING.md

[2] https://issues.guix.gnu.org/34861

Cheers,

aurtzy

 gnu/packages/package-management.scm | 52 +++++++++++++++++------------
 1 file changed, 30 insertions(+), 22 deletions(-)

diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 2beb442451..1b2a3d9309 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -25,6 +25,7 @@
 ;;; Copyright © 2023 Mădălin Ionel Patrașcu <[email-masked]>
 ;;; Copyright © 2024 Arun Isaac <[email-masked]>
 ;;; Copyright © 2024 Zheng Junjie <[email-masked]>
+;;; Copyright © 2025 aurtzy <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2037,40 +2038,42 @@ (define-public libostree
 (define-public flatpak
   (package
     (name "flatpak")
-    (version "1.14.10")
+    (version "1.16.0")
     (source
      (origin
        (method url-fetch)
        (uri (string-append "https://github.com/flatpak/flatpak/releases/download/"
                            version "/flatpak-" version ".tar.xz"))
        (sha256
-        (base32 "1k91v0csghiis8gjpcvpx534qbyaj81dfisabbc0ld97h68cggbb"))
+        (base32 "0ajbz8ms4h5nyjr59hv9z8vaimj4f3p51v8idmy14qnbmmjwa2nb"))
        (patches
         (search-patches "flatpak-fix-fonts-icons.patch"
                         "flatpak-fix-path.patch"
                         "flatpak-fix-icon-validation.patch"
                         "flatpak-unset-gdk-pixbuf-for-sandbox.patch"))))
-
-    ;; Wrap 'flatpak' so that GIO_EXTRA_MODULES is set, thereby allowing GIO to
-    ;; find the TLS backend in glib-networking.
-    (build-system glib-or-gtk-build-system)
-
+    (build-system meson-build-system)
     (arguments
      (list
       #:configure-flags
       #~(list
-         "--with-curl"
-         "--enable-documentation=no" ;; FIXME
-         "--enable-system-helper=no"
-         "--localstatedir=/var"
-         (string-append "--with-system-bubblewrap="
+         "-Dsystem_helper=disabled"
+         "-Dlocalstatedir=/var"
+         (string-append "-Dsystem_bubblewrap="
                         (assoc-ref %build-inputs "bubblewrap")
                         "/bin/bwrap")
-         (string-append "--with-system-dbus-proxy="
+         (string-append "-Dsystem_dbus_proxy="
                         (assoc-ref %build-inputs "xdg-dbus-proxy")
                         "/bin/xdg-dbus-proxy"))
       #:phases
       #~(modify-phases %standard-phases
+          (add-after 'unpack 'disable-failing-tests
+            (lambda _
+              (substitute* "tests/test-matrix/meson.build"
+                ;; The following tests fail with error message related to fusermount3
+                ;; failing an unmount operation ("No such file or directory").
+                (("^.*test-http-utils.*$") "")
+                (("[email-masked].*$") "")
+                (("^.*test-prune.*$") ""))))
           (add-after 'unpack 'fix-tests
             (lambda* (#:key inputs #:allow-other-keys)
               (copy-recursively
@@ -2101,20 +2104,24 @@ (define-public flatpak
                      (store (dirname out)))
                 (substitute* "icon-validator/validate-icon.c"
                   (("@storeDir@") store)))))
-          ;; Many tests fail for unknown reasons, so we just run a few basic
-          ;; tests.
-          (replace 'check
-            (lambda* (#:key tests? #:allow-other-keys)
-              (when tests?
-                (setenv "HOME" "/tmp")
-                (invoke "make" "check"
-                        "TESTS=tests/test-basic.sh tests/test-config.sh
-                        testcommon")))))))
+          (add-before 'check 'pre-check
+            (lambda _
+              ;; Set $HOME to writable location for testcommon tests.
+              (setenv "HOME" "/tmp")))
+          (add-after 'install 'wrap-flatpak
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((flatpak (string-append #$output "/bin/flatpak"))
+                    (glib-networking (assoc-ref inputs "glib-networking")))
+                (wrap-program flatpak
+                  ;; Allow GIO to find TLS backend.
+                  `("GIO_EXTRA_MODULES" prefix
+                    (,(string-append glib-networking "/lib/gio/modules"))))))))))
     (native-inputs
      (list bison
            dbus ; for dbus-daemon
            gettext-minimal
            `(,glib "bin") ; for glib-mkenums + gdbus-codegen
+           gtk-doc
            (libc-utf8-locales-for-target)
            gobject-introspection
            libcap
@@ -2126,6 +2133,7 @@ (define-public flatpak
     (inputs
      (list appstream
            appstream-glib
+           bash-minimal
            bubblewrap
            curl
            dconf

base-commit: 6964f7ad3481461cbb3256dd87e88ebcb3356f21
-- 
2.48.1