Subject: [PATCH] gnu: packages: Update gajim to 1.8.4.

From: Lilah Tascheter <[email-masked]>
Date: Wed, 17 Jan 2024 14:46:16 -0600

* gnu/packages/messaging.scm (python-omemo-dr): New variable.
  (python-nbxmpp,gajim): Update.
  (gajim)[build-system,arguments]: Rework to use pyproject-build-system.
  (gajim-omemo): Deprecate, as it's been merged into gajim.
* gnu/packages/protobuf.scm (python-protobuf-4): New variable.

Change-Id: I38cd63f14376bd177a1638fb608843eab805a6c5
---
 gnu/packages/messaging.scm | 262 ++++++++++++++++---------------------
 gnu/packages/protobuf.scm  |  20 +++
 2 files changed, 133 insertions(+), 149 deletions(-)

diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 491901edf3..d4830c68e2 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -151,6 +151,7 @@ (define-module (gnu packages messaging)
   #:use-module (guix build-system pyproject)
   #:use-module (guix build-system qt)
   #:use-module (guix build-system trivial)
+  #:use-module (guix deprecation)
   #:use-module (guix download)
   #:use-module (guix gexp)
   #:use-module (guix git-download)
@@ -1087,16 +1088,34 @@ (define-public znc
 simultaneously and therefore appear under the same nickname on IRC.")
     (license license:asl2.0)))
 
+(define-public python-omemo-dr
+  (package
+    (name "python-omemo-dr")
+    (version "1.0.1")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "omemo-dr" version))
+              (sha256
+                (base32
+                  "0qfk0b153cmc85icnlpfv8mjaqd2spa7hlipvndr8wqx4dvqr2ia"))))
+    (build-system pyproject-build-system)
+    (inputs (list python-cryptography python-protobuf-4))
+    (synopsis "Python OMEMO library")
+    (description "A library to handle the cryptography part of OMEMO (does not
+handle the XMPP protocol). A rewrite of python-axolotl by Gajim devs.")
+    (home-page "https://dev.gajim.org/gajim/omemo-dr")
+    (license license:gpl3)))
+
 (define-public python-nbxmpp
   (package
     (name "python-nbxmpp")
-    (version "4.2.2")
+    (version "4.5.3")
     (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "nbxmpp" version))
        (sha256
-         (base32 "095nyy6vjildhrqigxk6vsh49in6mx17bvb3z5zpjmzhv9b8ix46"))))
+         (base32 "17hbw01sqn22rs9hbsp8zsgaxhv7hkzzgcflzb29p7zcm1nhwqkf"))))
     (build-system pyproject-build-system)
     (arguments
      (list
@@ -1125,110 +1144,69 @@ (define-public python-nbxmpp
 (define-public gajim
   (package
     (name "gajim")
-    (version "1.7.3")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (string-append "https://gajim.org/downloads/"
-                           (version-major+minor version)
-                           "/gajim-" version ".tar.gz"))
-       (sha256
-         (base32 "066kvkjw3qcdanr3nczy0wgcwihk9jc9zhzfr5bwlqvcyxcv7k5p"))
-       (patches
-         (search-patches "gajim-honour-GAJIM_PLUGIN_PATH.patch"))))
-    (build-system python-build-system)
+    (version "1.8.4")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://gajim.org/downloads/"
+                                  (version-major+minor version)
+                                  "/gajim-" version ".tar.gz"))
+              (sha256
+                (base32 "1ia99vwhrqdi3rqdj2203fq36r94k4sg7kcv4vav60ffn63yvz2q"))
+              (patches
+                (search-patches "gajim-honour-GAJIM_PLUGIN_PATH.patch"))))
+    (build-system pyproject-build-system)
     (arguments
-     (list
-      #:imported-modules
-      `(,@%python-build-system-modules
-        (guix build glib-or-gtk-build-system))
-      #:modules
-      '((guix build python-build-system)
-        ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
-        (guix build utils))
-      #:phases
-      #~(modify-phases %standard-phases
-          (add-after 'unpack 'generate-gdk-pixbuf-loaders-cache-file
-            (assoc-ref glib-or-gtk:%standard-phases
-                       'generate-gdk-pixbuf-loaders-cache-file))
-          (add-before 'build 'build-metadata
-            (lambda _
-              (invoke "./pep517build/build_metadata.py"
-                      "-o" "dist/metadata")))
-          ;; TODO: Change to pyproject-build-system once it supports
-          ;; in-tree build backends.
-          (replace 'build
-            (lambda _
-              (invoke "python" "-m" "build" "--wheel" "--no-isolation"
-                      ".")))
-          (replace 'install
-            (lambda _
-              (apply invoke "pip" "--no-cache-dir" "--no-input"
-                     "install" "--no-deps" "--prefix" #$output
-                     (find-files "dist" "\\.whl$"))))
-          (add-after 'install 'install-metadata
-            (lambda _
-              (invoke "./pep517build/install_metadata.py" "dist/metadata"
-                      (string-append "--prefix=" #$output))))
-          (replace 'check
-            (lambda _
-              ;; Tests require a running X server.
-              (system "Xvfb :1 +extension GLX &")
-              (setenv "DISPLAY" ":1")
-              ;; For missing '/etc/machine-id'.
-              (setenv "DBUS_FATAL_WARNINGS" "0")
-              (invoke "dbus-launch" "python" "-m" "unittest"
-                      "discover" "-s" "test")))
-          (add-after 'install 'glib-or-gtk-compile-schemas
-            (assoc-ref glib-or-gtk:%standard-phases
-                       'glib-or-gtk-compile-schemas))
-          (add-after 'install 'glib-or-gtk-wrap
-            (assoc-ref glib-or-gtk:%standard-phases
-                       'glib-or-gtk-wrap))
-          (add-after 'install 'wrap-env
-            (lambda _
-              (for-each
-               (lambda (name)
-                 (let ((file (string-append #$output "/bin/" name))
-                       (gst-plugin-path (getenv "GST_PLUGIN_SYSTEM_PATH"))
-                       (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
-                       (pixbuf-module-file (getenv "GDK_PIXBUF_MODULE_FILE")))
-                   (wrap-program file
-                     `("GST_PLUGIN_SYSTEM_PATH" ":" prefix (,gst-plugin-path))
-                     `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
-                     `("GDK_PIXBUF_MODULE_FILE" = (,pixbuf-module-file)))))
-               '("gajim" "gajim-remote")))))))
-    (native-search-paths
-     (list
-      (search-path-specification
-       (variable "GAJIM_PLUGIN_PATH")
-       (separator #f) ; single entry
-       (files (list "share/gajim/plugins")))
-      ;; Gajim needs to use the propagated inputs of its plugins.
-      (search-path-specification
-       (variable "GUIX_PYTHONPATH")
-       (files
-        (list
-         (string-append
-          "lib/python"
-          ;; FIXME: Cannot use this expression as it would
-          ;; introduce a circular dependency at the top level.
-          ;; (version-major+minor (package-version python))
-          "3.10"
-          "/site-packages"))))))
-    (native-inputs
-     (list gettext-minimal
-           `(,glib "bin")
-           gobject-introspection
-           `(,gtk+ "bin")
-           python-distutils-extra
-           python-pypa-build
-           python-setuptools
-           xorg-server-for-tests))
-    (inputs
-     (list avahi
-           dbus
-           farstream
+     (list #:build-backend "pep517build.backend"
+           #:configure-flags ''(@) ; in order to convert to a json dict
+           #:imported-modules `((guix build glib-or-gtk-build-system)
+                                ,@%pyproject-build-system-modules)
+           #:modules '((guix build pyproject-build-system)
+                       ((guix build glib-or-gtk-build-system)
+                        #:prefix glib-or-gtk:)
+                       (guix build utils))
+           #:phases
+           (let ((glib-phases #~glib-or-gtk:%standard-phases)
+                 (cache-file #~'generate-gdk-pixbuf-loaders-cache-file)
+                 (compile-schemas #~'glib-or-gtk-compile-schemas)
+                 (wrap #~'glib-or-gtk-wrap))
+             #~(modify-phases %standard-phases
+                 (add-after 'unpack #$cache-file
+                   (assoc-ref #$glib-phases #$cache-file))
+                 (add-before 'build 'build-metadata
+                   (lambda _
+                     (invoke "python" "pep517build/build_metadata.py")))
+
+                 (add-before 'install 'install-metadata
+                   (lambda _
+                     (invoke "python" "pep517build/install_metadata.py"
+                             "--prefix" #$output "dist/metadata")))
+                 (add-after 'install #$compile-schemas
+                   (assoc-ref #$glib-phases #$compile-schemas))
+                 (add-after #$compile-schemas #$wrap
+                   (assoc-ref #$glib-phases #$wrap))
+                 (add-after 'wrap 'wrap-env
+                   (lambda _
+                     (for-each
+                       (lambda (name)
+                         (let ((gi-var "GI_TYPELIB_PATH")
+                               (gst-var "GST_PLUGIN_SYSTEM_PATH")
+                               (gdk-var "GDK_PIXBUF_MODULE_FILE"))
+                           (wrap-program (string-append #$output "/bin/" name)
+                             `(,gi-var ":" prefix (,(getenv gi-var)))
+                             `(,gst-var ":" prefix (,(getenv gst-var)))
+                             `(,gdk-var = (,(getenv gdk-var))))))
+                       '("gajim" "gajim-remote"))))
+
+                 (replace 'check
+                   (lambda _ ; tests require a running X server
+                     (system "Xvfb :1 +extension GLX &")
+                     (setenv "DISPLAY" ":1")
+                     ;; /etc/machine-id doesn't exist in build container
+                     (setenv "DBUS_FATAL_WARNINGS" "0")
+                     (invoke "dbus-launch" "python" "-m" "unittest" "discover"
+                             "-s" "test")))))))
+    (inputs ; gupnp-idg support disabled in gajim due to libsoup incompat
+     (list farstream
            geoclue
            glib
            glib-networking
@@ -1237,29 +1215,49 @@ (define-public gajim
            gspell
            gstreamer
            gst-plugins-base
+           gst-plugins-ugly
            gtk+
            gtksourceview-4
-           gupnp-igd
            libappindicator
-           libnice
            libsecret
-           libsoup
-           libxscrnsaver
+           libsoup-minimal
            network-manager
            python-css-parser
            python-dbus
-           python-gssapi
            python-idna
            python-keyring
            python-nbxmpp
-           python-packaging
+           python-omemo-dr
            python-pillow
            python-precis-i18n
+           python-protobuf-4
            python-pycairo
            python-pygobject
-           python-pyopenssl))
-    (propagated-inputs
-     (list dconf))
+           python-qrcode
+           sqlite))
+    (native-inputs
+     (list dbus
+           gettext-minimal
+           `(,glib "bin")
+           `(,gtk+ "bin")
+           xorg-server-for-tests))
+    (propagated-inputs (list dconf))
+    (search-paths
+      (list (search-path-specification
+              (variable "GAJIM_PLUGIN_PATH")
+              (files '("share/gajim/plugins"))
+              (separator #f)) ; single entry
+            ;; Gajim needs to use the propagated inputs of its plugins.
+            (search-path-specification
+              (variable "GUIX_PYTHONPATH")
+              (files
+                (list (string-append
+                        "/lib/python"
+                        ;; FIXME: Cannot use this expression as it would
+                        ;; introduce a circular dependency at the top level.
+                        ;; (version-major+minor (package-version python))
+                        "3.10"
+                        "/site-packages"))))))
     (synopsis "Fully-featured XMPP client")
     (description "Gajim aims to be an easy to use and fully-featured XMPP chat
 client.  It is extensible via plugins, supports end-to-end encryption (OMEMO
@@ -1267,41 +1265,7 @@ (define-public gajim
     (home-page "https://gajim.org/")
     (license license:gpl3)))
 
-(define-public gajim-omemo
-  (package
-    (name "gajim-omemo")
-    (version "2.9.0")
-    (source
-     (origin
-       (method url-fetch/zipbomb)
-       (uri
-        (string-append
-         "https://ftp.gajim.org/plugins/master/omemo/omemo_"
-         version ".zip"))
-       (sha256
-        (base32 "0yy9r9fsrlgdywiln8bskhi8faj9hnz7b19jcap5nkhv8jn9cqq7"))))
-    (build-system trivial-build-system)
-    (arguments
-     `(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-         (let* ((out (assoc-ref %outputs "out"))
-                (share (in-vicinity out "share/gajim/plugins/omemo"))
-                (source (assoc-ref %build-inputs "source")))
-           (mkdir-p share)
-           (copy-recursively source share)
-           #t))))
-    (propagated-inputs
-     (list python-axolotl python-axolotl-curve25519 python-cryptography
-           python-qrcode))
-    (synopsis "Gajim OMEMO plugin")
-    (description "Gajim-OMEMO is a plugin that adds support for the OMEMO
-Encryption to Gajim.  OMEMO is an XMPP Extension Protocol (XEP) for secure
-multi-client end-to-end encryption.")
-    (home-page
-     "https://dev.gajim.org/gajim/gajim-plugins/-/wikis/OmemoGajimPlugin")
-    (license license:gpl3+)))
+(define-deprecated gajim-omemo gajim)
 
 (define-public gajim-openpgp
   (package
diff --git a/gnu/packages/protobuf.scm b/gnu/packages/protobuf.scm
index d47b67fa61..bcd2bdfc98 100644
--- a/gnu/packages/protobuf.scm
+++ b/gnu/packages/protobuf.scm
@@ -514,6 +514,26 @@ (define-public python-protobuf-3.6
     (native-inputs
      (list python-setuptools-for-tensorflow))))
 
+;; for gajim
+(define-public python-protobuf-4
+  (let ((base python-protobuf)) ; cpp impl used by base is deprecated
+    (package
+      (name "python-protobuf")
+      (version "4.25.2")
+      (source (origin
+                (method url-fetch)
+                (uri (pypi-uri "protobuf" version))
+                (sha256
+                  (base32
+                    "0phabz0rb6dqrk79wmhf5hkgf49dj15wsjsjxv4fyixkbhbrwngy"))))
+      (build-system python-build-system)
+      ;; setuptools breaks when testing
+      (arguments '(#:tests? #f))
+      (synopsis (package-synopsis base))
+      (description (package-description base))
+      (home-page (package-home-page base))
+      (license (package-license base)))))
+
 (define-public python-proto-plus
   (package
     (name "python-proto-plus")

base-commit: 21f5d20d68e0359f8111ccb936905649c70db9c1
-- 
2.41.0