Subject: [PATCH gnome-team 3/3] gnu: virt-manager: Update to 5.0.0 and enable tests.

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 17 Feb 2025 23:37:53 +0900

* gnu/packages/virtualization.scm (virt-manager): Update to 5.0.0.
[source]: Update URI.  Delete patches.
[build-system]: Switch to meson-build-system.
[arguments] <#:use-setuptools?, #:tests?, #:imported-modules>: Delete
arguments.
<#:modules>: Add (srfi srfi-1).
<#:phases>: Delete fix-setup phase.  Remove stale Xen comment in
fix-default-uri phase.  Rename and extend wrap-with-GI_TYPELIB_PATH phase to
wrap-more. Delete glib-or-gtk-build-system and glib-or-gtk-wrap phases.  Add
set_SOURCE_DIR phase.  Update check phase.
[native-inputs]: Add cdrtools, cpio, gettext-minimal, pkg-config and
python-pytest.  Remove intltool and perl.
[inputs]: Add python-minimal.
* gnu/packages/patches/virt-manager-fix-gtk-cursor-theme-backtace.patch:
Delete file.
* gnu/local.mk (dist_patch_DATA): De-register it.

Change-Id: Idff7abdcb5b6237e4fcaba40f373866699718cbc
Series-to: [email-masked]
Series-postfix: gnome-team
Cover-letter:
 Update virt-manager to 5.0.0.
 This small series updates virt-manager to 5.0.0, along libvirt and
 python-libvirt.
 END
---
 gnu/local.mk                                  |   1 -
 ...anager-fix-gtk-cursor-theme-backtace.patch |  40 -----
 gnu/packages/virtualization.scm               | 151 ++++++++----------
 3 files changed, 71 insertions(+), 121 deletions(-)
 delete mode 100644 gnu/packages/patches/virt-manager-fix-gtk-cursor-theme-backtace.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 4a6e39c968..8f7efa6d9b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2369,7 +2369,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/vinagre-newer-freerdp.patch             \
   %D%/packages/patches/vinagre-newer-rdp-parameters.patch      \
   %D%/packages/patches/virtuoso-ose-remove-pre-built-jar-files.patch	\
-  %D%/packages/patches/virt-manager-fix-gtk-cursor-theme-backtace.patch	\
   %D%/packages/patches/vsearch-unbundle-cityhash.patch		\
   %D%/packages/patches/vte-CVE-2012-2738-pt1.patch			\
   %D%/packages/patches/vte-CVE-2012-2738-pt2.patch			\
diff --git a/gnu/packages/patches/virt-manager-fix-gtk-cursor-theme-backtace.patch b/gnu/packages/patches/virt-manager-fix-gtk-cursor-theme-backtace.patch
deleted file mode 100644
index 3f7a5e6873..0000000000
--- a/gnu/packages/patches/virt-manager-fix-gtk-cursor-theme-backtace.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-This patch fixes an issue in virt-manager 4.1.0 where it errors and returns a
-stack trace. Namely, Gdk.Cursor.new_from_name yields a "constructor returned
-NULL" error, which causes a "'NoneType' object has no attribute 'conn'" error
-later.
-
-See the upstream bug report for more information:
-
-https://github.com/virt-manager/virt-manager/issues/479
-
-Patch copied from upstream source repository:
-
-https://github.com/virt-manager/virt-manager/commit/cc4a39ea94f42bc92765eb3bb56e2b7f9198be67
-
-From cc4a39ea94f42bc92765eb3bb56e2b7f9198be67 Mon Sep 17 00:00:00 2001
-From: Cole Robinson <[email-masked]>
-Date: Thu, 19 Jan 2023 11:13:56 -0500
-Subject: [PATCH] asyncjob: Fix backtrace when no cursor theme installed
-
-Fixes: https://github.com/virt-manager/virt-manager/issues/479
-
-Signed-off-by: Cole Robinson <[email-masked]>
----
- virtManager/asyncjob.py | 4 +---
- 1 file changed, 1 insertion(+), 3 deletions(-)
-
-diff --git a/virtManager/asyncjob.py b/virtManager/asyncjob.py
-index 32d9c0a16..46692acea 100644
---- a/virtManager/asyncjob.py
-+++ b/virtManager/asyncjob.py
-@@ -265,9 +265,7 @@ def run(self):
-             self.topwin.present()
- 
-         if not self.cancel_cb and self.show_progress:
--            gdk_window = self.topwin.get_window()
--            gdk_window.set_cursor(
--                Gdk.Cursor.new_from_name(gdk_window.get_display(), "progress"))
-+            self._set_cursor("progress")
-         self._bg_thread.start()
- 
- 
diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 5837abb651..64ad06213e 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -15,7 +15,7 @@
 ;;; Copyright © 2020, 2021 Brice Waegeneire <[email-masked]>
 ;;; Copyright © 2020 Mathieu Othacehe <[email-masked]>
 ;;; Copyright © 2020, 2021, 2022 Marius Bakke <[email-masked]>
-;;; Copyright © 2020, 2021, 2022, 2023, 2024 Maxim Cournoyer <[email-masked]>
+;;; Copyright © 2020-2025 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2020 Brett Gilio <[email-masked]>
 ;;; Copyright © 2021 Leo Famulari <[email-masked]>
 ;;; Copyright © 2021, 2022 Pierre Langlois <[email-masked]>
@@ -1717,74 +1717,79 @@ (define-public python-libvirt
 (define-public virt-manager
   (package
     (name "virt-manager")
-    (version "4.1.0")
+    (version "5.0.0")
     (source (origin
               (method url-fetch)
-              (uri (string-append "https://virt-manager.org/download/sources"
-                                  "/virt-manager/virt-manager-"
-                                  version ".tar.gz"))
+              (uri (string-append "https://releases.pagure.org/" name
+                                  "/" name "-" version ".tar.xz"))
               (sha256
                (base32
-                "18lhlnd3gmyzhbnjc16gdyzhjcd33prlxnca4xlidiidngbq21lm"))
-              (patches (search-patches "virt-manager-fix-gtk-cursor-theme-backtace.patch"))))
-    (build-system python-build-system)
+                "0jpqhc02ya55rr8bin734znasslwlff42ann9rsvv5y9w13ax2dw"))))
+    (build-system meson-build-system)
     (arguments
-     (list #:use-setuptools? #f      ; uses custom distutils 'install' command
-           #:tests? #f               ; TODO: The tests currently fail
-                                     ; RuntimeError: Loop condition wasn't met
-           #:imported-modules
-           `((guix build glib-or-gtk-build-system)
-             ,@%python-build-system-modules)
-           #:modules
-           '((ice-9 match)
-             (srfi srfi-26)
-             (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 'fix-setup
-                 (lambda _
-                   (substitute* "virtinst/buildconfig.py"
-                     (("/usr") #$output))))
-               (add-after 'unpack 'fix-default-uri
-                 (lambda* (#:key inputs #:allow-other-keys)
-                   ;; Xen is not available for now - so only patch qemu.
-                   (substitute* "virtManager/createconn.py"
-                     (("/usr(/bin/qemu-system-\\*)" _ suffix)
-                      (string-append #$(this-package-input "qemu") suffix)))))
-               (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
-                 (lambda* (#:key inputs #:allow-other-keys)
-                   (let* ((bin       (string-append #$output "/bin"))
-                          (bin-files (find-files bin ".*"))
-                          (paths     (map (match-lambda
-                                            ((output . directory)
-                                             (let* ((girepodir (string-append
-                                                                directory
-                                                                "/lib/girepository-1.0")))
-                                               (if (file-exists? girepodir)
-                                                   girepodir #f))))
-                                          inputs)))
-                     (for-each (lambda (file)
-                                 (format #t "wrapping ~a\n" file)
-                                 (wrap-program file
-                                   `("GI_TYPELIB_PATH" ":" prefix
-                                     ,(filter identity paths))))
-                               bin-files))))
-               (replace 'check
-                 (lambda* (#:key tests? #:allow-other-keys)
-                   (when tests?
-                     (setenv "HOME" "/tmp")
-                     (setenv "XDG_CACHE_HOME" "/tmp")
-                     (system "Xvfb :1 &")
-                     (setenv "DISPLAY" ":1")
-                     ;; Dogtail requires that Assistive Technology support be enabled
-                     (setenv "GTK_MODULES" "gail:atk-bridge")
-                     (invoke "dbus-run-session" "--" "pytest" "--uitests"))))
-               (add-after 'install 'glib-or-gtk-compile-schemas
-                 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
-               (add-after 'wrap 'glib-or-gtk-wrap
-                 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
+     (list
+      #:modules
+      '((ice-9 match)
+        (srfi srfi-1)
+        (srfi srfi-26)
+        (guix build meson-build-system)
+        (guix build utils))
+      #:glib-or-gtk? #t
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'set-SOURCE_DIR
+            (lambda _
+              (setenv "SOURCE_DIR" (getcwd))))
+          (add-after 'unpack 'fix-default-uri
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "virtManager/createconn.py"
+                (("/usr(/bin/qemu-system-\\*)" _ suffix)
+                 (string-append #$(this-package-input "qemu") suffix)))))
+          (add-before 'glib-or-gtk-wrap 'wrap-more
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let* ((paths (filter-map
+                             (match-lambda
+                               ((output . directory)
+                                (let* ((girepodir (string-append
+                                                   directory
+                                                   "/lib/girepository-1.0")))
+                                  (and (file-exists? girepodir)
+                                       girepodir))))
+                             inputs)))
+                (for-each (lambda (file)
+                            (format #t "wrapping ~a~%" file)
+                            (wrap-program file
+                              `("GI_TYPELIB_PATH" prefix ,paths)
+                              `("GUIX_PYTHONPATH" prefix
+                                ;; FIXME: This wraps too much (see: bug#25235).
+                                (,(getenv "GUIX_PYTHONPATH")))))
+                          (find-files (string-append #$output "/bin"))))))
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (with-directory-excursion (getenv "SOURCE_DIR")
+                (invoke "pytest" "-vvv"
+                        "-k" (string-append
+                              ;; The cdrom_url and CLI0062 tests cause
+                              ;; some crash, also outside the build container.
+                              "not install_cdrom_url and "
+                              "not testCLI0062virt_install and "
+                              ;; These tests fail only inside the
+                              ;; build container, perhaps due to
+                              ;; missing /dev nodes.
+                              "not install_s390x_cdrom and "
+                              "not install_many_devices and "
+                              "not test_disk and "
+                              "not virt_clone"))))))))
+    (native-inputs
+     (list cdrtools
+           cpio
+           gettext-minimal
+           `(,glib "bin")               ;glib-compile-schemas
+           gobject-introspection
+           `(,gtk+ "bin")               ;gtk-update-icon-cache
+           pkg-config
+           python-docutils              ;rst2ma
+           python-pytest))
     (inputs
      (list bash-minimal
            dconf
@@ -1794,29 +1799,15 @@ (define-public virt-manager
            libosinfo
            libvirt
            libvirt-glib
-           python-libvirt
+           python-minimal
            python-libxml2
+           python-libvirt
            python-pycairo
            python-pygobject
            python-requests
            qemu
            spice-gtk
            vte/gtk+-3))
-    (native-inputs
-     (list `(,glib "bin")               ; glib-compile-schemas
-           gobject-introspection
-           `(,gtk+ "bin")               ; gtk-update-icon-cache
-           intltool
-           perl                         ; pod2man
-           python-docutils              ; rst2man
-           ;; The following are required for running the tests
-           ;; at-spi2-core
-           ;; dbus
-           ;; gsettings-desktop-schemas
-           ;; python-dogtail
-           ;; python-pytest
-           ;; xorg-server-for-tests        ; xvfb
-           ))
     (home-page "https://virt-manager.org/")
     (synopsis "Manage virtual machines")
     (description
-- 
2.48.1