Subject: [bug#42958] [PATCH core-updates 19/29] gnu: gtk+-2: Update package definition.

From: Danny Milosavljevic <[email-masked]>
Date: Thu, 20 Aug 2020 17:10:40 +0200

From: Raghav Gururajan <[email-masked]>

* gnu/packages/gtk.scm (gtk+-2): Update package definition.
[arguments]<#:phases>['disable-tests]: Remove phase.
['disable-failing-tests]: New phase.
['pre-check]: New phase.
[native-inputs]: Add intltool and xorg-server-for-tests.
[inputs]: Add libx11, libxext, libxkbcommon, libxrender and
libxshmfence.
[propagated-inputs]: Add cairo and glib.
[search-paths]: New field.

Signed-off-by: Danny Milosavljevic <[email-masked]>
---
 gnu/packages/gtk.scm | 155 +++++++++++++++++++++++++------------------
 1 file changed, 92 insertions(+), 63 deletions(-)

diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index bc450a33f6..e8ba76694c 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -70,6 +70,7 @@
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
+  #:use-module (gnu packages graphics)
   #:use-module (gnu packages icu4c)
   #:use-module (gnu packages image)
   #:use-module (gnu packages libffi)
@@ -718,72 +719,100 @@ is part of the GNOME accessibility project.")
 
 (define-public gtk+-2
   (package
-   (name "gtk+")
-   (version "2.24.32")
-   (source (origin
-            (method url-fetch)
-            (uri (string-append "mirror://gnome/sources/" name "/"
-                                (version-major+minor version)  "/"
-                                name "-" version ".tar.xz"))
-            (sha256
-             (base32
-              "0bjq7ja9gwcv6n5q4qkvdjjx40wsdiikksz1zqxvxsm5vlyskj5n"))
-            (patches (search-patches "gtk2-respect-GUIX_GTK2_PATH.patch"
-                                     "gtk2-respect-GUIX_GTK2_IM_MODULE_FILE.patch"
-                                     "gtk2-theme-paths.patch"))))
-   (build-system gnu-build-system)
-   (outputs '("out" "bin" "doc"))
-   (propagated-inputs
-    `(("atk" ,atk)
-      ("gdk-pixbuf" ,gdk-pixbuf+svg)
-      ("pango" ,pango)))
-   (inputs
-    `(("cups" ,cups)
-      ("libxcomposite" ,libxcomposite)
-      ("libxcursor" ,libxcursor)
-      ("libxdamage" ,libxdamage)
-      ("libxi" ,libxi)
-      ("libxinerama" ,libxinerama)
-      ("libxrandr" ,libxrandr)))
-   (native-inputs
-    `(("perl" ,perl)
-      ("gettext" ,gettext-minimal)
-      ("glib" ,glib "bin")
-      ("gobject-introspection" ,gobject-introspection)
-      ("pkg-config" ,pkg-config)
-      ("python-wrapper" ,python-wrapper)))
-   (arguments
-    `(#:configure-flags
-      (list "--with-xinput=yes"
-            (string-append "--with-html-dir="
-                           (assoc-ref %outputs "doc")
-                           "/share/gtk-doc/html"))
-      #:phases
-      (modify-phases %standard-phases
-        (add-before 'configure 'disable-tests
-          (lambda _
-            ;; FIXME: re-enable tests requiring an X server
-            (substitute* "gtk/Makefile.in"
-              (("SUBDIRS = theme-bits . tests") "SUBDIRS = theme-bits ."))
-            #t))
-        (add-after 'install 'remove-cache
-          (lambda* (#:key outputs #:allow-other-keys)
-	    (for-each
-	      delete-file
-	      (find-files (assoc-ref outputs "out") "immodules.cache"))
-            #t)))))
-   (native-search-paths
-    (list (search-path-specification
-           (variable "GUIX_GTK2_PATH")
-           (files '("lib/gtk-2.0")))))
-   (synopsis "Cross-platform toolkit for creating graphical user interfaces")
-   (description
-    "GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating
+    (name "gtk+")
+    (version "2.24.32")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append "mirror://gnome/sources/" name "/"
+                       (version-major+minor version)  "/"
+                       name "-" version ".tar.xz"))
+       (sha256
+        (base32 "0bjq7ja9gwcv6n5q4qkvdjjx40wsdiikksz1zqxvxsm5vlyskj5n"))
+       (patches
+        (search-patches
+         "gtk2-respect-GUIX_GTK2_PATH.patch"
+         "gtk2-respect-GUIX_GTK2_IM_MODULE_FILE.patch"
+         "gtk2-theme-paths.patch"))))
+    (build-system gnu-build-system)
+    (outputs '("out" "bin" "doc"))
+    (arguments
+     `(#:configure-flags
+       (list
+        "--with-xinput=yes"
+        (string-append "--with-html-dir=" (assoc-ref %outputs "doc")
+                       "/share/gtk-doc/html"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'disable-failing-tests
+           (lambda _
+             (substitute* "gtk/tests/recentmanager.c"
+               (("g_test_add_func \\(\"/recent-manager/add-many\", recent_manager_add_many\\);")
+                ""))
+             (substitute* "gtk/tests/defaultvalue.c"
+               (("return g_test_run\\(\\);")
+                ""))
+             #t))
+         (add-before 'check 'pre-check
+           (lambda _
+             ;; Tests require a running X server.
+             (system "Xvfb :1 +extension GLX &")
+             (setenv "DISPLAY" ":1")
+             ;; Tests write to $HOME.
+             (setenv "HOME" (getcwd))
+             ;; Tests look for $XDG_RUNTIME_DIR.
+             (setenv "XDG_RUNTIME_DIR" (getcwd))
+             ;; For missing '/etc/machine-id'.
+             (setenv "DBUS_FATAL_WARNINGS" "0")
+             #t))
+         (add-after 'install 'remove-cache
+           (lambda* (#:key outputs #:allow-other-keys)
+             (for-each
+              delete-file
+              (find-files (assoc-ref outputs "out") "immodules.cache"))
+             #t)))))
+    (native-inputs
+     `(("gettext" ,gettext-minimal)
+       ("glib" ,glib "bin")
+       ("gobject-introspection" ,gobject-introspection)
+       ("intltool" ,intltool)
+       ("perl" ,perl)
+       ("pkg-config" ,pkg-config)
+       ("python-wrapper" ,python-wrapper)
+       ("xorg-server" ,xorg-server-for-tests)))
+    (inputs
+     `(("cups" ,cups)
+       ("libx11" ,libx11)
+       ("libxcomposite" ,libxcomposite)
+       ("libxcursor" ,libxcursor)
+       ("libxext" ,libxext)
+       ("libxdamage" ,libxdamage)
+       ("libxi" ,libxi)
+       ("libxinerama" ,libxinerama)
+       ("libxkbcommon" ,libxkbcommon)
+       ("libxrandr" ,libxrandr)
+       ("libxrender" ,libxrender)
+       ("libxshmfence" ,libxshmfence)))
+    (propagated-inputs
+     `(("atk" ,atk)
+       ("cairo" ,cairo)
+       ("gdk-pixbuf" ,gdk-pixbuf+svg)
+       ("glib" ,glib)
+       ("pango" ,pango)))
+    (native-search-paths
+     (list
+      (search-path-specification
+       (variable "GUIX_GTK2_PATH")
+       (files '("lib/gtk-2.0")))))
+    (search-paths native-search-paths)
+    (synopsis "Cross-platform toolkit for creating graphical user interfaces")
+    (description "GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating
 graphical user interfaces.  Offering a complete set of widgets, GTK+ is
 suitable for projects ranging from small one-off tools to complete
 application suites.")
-   (license license:lgpl2.0+)
-   (home-page "https://www.gtk.org/")))
+    (home-page "https://www.gtk.org/")
+    (license license:lgpl2.0+)))
 
 (define-public gtk+
   (package (inherit gtk+-2)