[bug#75688,v2,2/4] gnu: gdk-pixbuf: Respect GUIX_GDK_PIXBUF_MODULE_FILES search path.

Message ID 96be080084ef425fb5d5a8ab920d30667dc68c99.1737613671.git.iyzsong@member.fsf.org
State New
Headers
Series [bug#75688,v2,1/4] gnu: glib: Support load search paths from etc/search-paths.d files. |

Commit Message

Alexis Praga via Guix-patches via Jan. 23, 2025, 6:28 a.m. UTC
  From: 宋文武 <iyzsong@member.fsf.org>

This fixes <https://issues.guix.gnu.org/75523>.

* gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch:
New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/gtk.scm (gdk-pixbuf)[source]: Add patch.
[native-search-paths]: Replace GDK_PIXBUF_MODULE_FILE with GUIX_GDK_PIXBUF_MODULE_FILES.

Change-Id: I63ce8fa14799e04551522e6d27e89bf47b08043e
---
 gnu/local.mk                                   |  1 +
 gnu/packages/gtk.scm                           |  8 +++++---
 ...-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch | 18 ++++++++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch
  

Comments

Maxim Cournoyer Jan. 27, 2025, 3:03 a.m. UTC | #1
Hi,

iyzsong@envs.net writes:

> From: 宋文武 <iyzsong@member.fsf.org>
>
> This fixes <https://issues.guix.gnu.org/75523>.
>
> * gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch:

nitpick: I'd name this patch
gdk-pixbuf-honor-GUIX_GDK_PIXBUF_MODULE_FILES.patch (s/respect/honor/).

[...]

> +              (patches
> +               (search-patches
> +                "gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch"))))
>      (build-system meson-build-system)
>      (outputs '("out" "debug"))
>      (arguments
> @@ -777,9 +780,8 @@ (define-public gdk-pixbuf
>       ;; This file is produced by the gdk-pixbuf-loaders-cache-file
>       ;; profile hook.
>       (list (search-path-specification
> -            (variable "GDK_PIXBUF_MODULE_FILE")
> +            (variable "GUIX_GDK_PIXBUF_MODULE_FILES")
>              (files (list %gdk-pixbuf-loaders-cache-file))
> -            (separator #f)              ;single valued
>              (file-type 'regular))))
>      (synopsis "Image loading library")
>      (description "GdkPixbuf is a library that loads image data in various
> diff --git a/gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch b/gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch
> new file mode 100644
> index 0000000000..eb22761403
> --- /dev/null
> +++ b/gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch
> @@ -0,0 +1,18 @@
> +diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
> +index e1df590..ba24cf6 100644
> +--- a/gdk-pixbuf/gdk-pixbuf-io.c
> ++++ b/gdk-pixbuf/gdk-pixbuf-io.c
> +@@ -670,6 +670,13 @@ gdk_pixbuf_io_init (void)
> + 	gboolean ret;
> + 
> + 	gdk_pixbuf_io_init_builtin ();
> ++
> ++	/* Load loaders from GUIX_GDK_PIXBUF_MODULE_FILES. */

nitpick: "Load loaders" reads a bit loaded ;-).  I'd write "Load modules
[...]" instead.

> ++	gchar **guix_module_files = g_build_guix_search_path_dirs ("GUIX_GDK_PIXBUF_MODULE_FILES");
> ++	for (int i = 0; guix_module_files[i] != NULL; i++)

nitpick: I read a long time ago that ++i achieves the same and is more
efficient, though I forgot the reasons.  Probably doesn't matter here,
but could be neater (here and elsewhere).

Otherwise, for this commit alone,

Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail>

(You'll want to give this series plenty of time for others to chime in).
  
宋文武 Jan. 27, 2025, 4:24 a.m. UTC | #2
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

>> * gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch:
>
> nitpick: I'd name this patch
> gdk-pixbuf-honor-GUIX_GDK_PIXBUF_MODULE_FILES.patch (s/respect/honor/).
>
> [...]
>
> nitpick: "Load loaders" reads a bit loaded ;-).  I'd write "Load modules
> [...]" instead.
>
>> ++	gchar **guix_module_files = g_build_guix_search_path_dirs ("GUIX_GDK_PIXBUF_MODULE_FILES");
>> ++	for (int i = 0; guix_module_files[i] != NULL; i++)
>
> nitpick: I read a long time ago that ++i achieves the same and is more
> efficient, though I forgot the reasons.  Probably doesn't matter here,
> but could be neater (here and elsewhere).

Since it's not a big/hot loop, it doesn't matter here, and existed code use
"i++", so I'd leave it.

>
> Otherwise, for this commit alone,
>
> Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail>
>
> (You'll want to give this series plenty of time for others to chime in).

I had update gdk-pixbuf patch for https://issues.guix.gnu.org/75795

The "search-paths.d" part of this series surely need more work, I'll
work on that later.

Thank you!
  

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 6bb3a35770..4249476dfa 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1400,6 +1400,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/gd-fix-tests-on-i686.patch		\
   %D%/packages/patches/gd-brect-bounds.patch			\
   %D%/packages/patches/gdb-hurd64.patch				\
+  %D%/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch	\
   %D%/packages/patches/gdm-default-session.patch		\
   %D%/packages/patches/gdm-elogind-support.patch		\
   %D%/packages/patches/gdm-remove-hardcoded-xwayland-path.patch	\
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 7ed7d7b7df..392734a33c 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -726,7 +726,10 @@  (define-public gdk-pixbuf
                                   name "-" version ".tar.xz"))
               (sha256
                (base32
-                "0jz4kziz5lirnjjvbspbqzsigk8vnqknng1fga89d81vs5snr6zf"))))
+                "0jz4kziz5lirnjjvbspbqzsigk8vnqknng1fga89d81vs5snr6zf"))
+              (patches
+               (search-patches
+                "gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch"))))
     (build-system meson-build-system)
     (outputs '("out" "debug"))
     (arguments
@@ -777,9 +780,8 @@  (define-public gdk-pixbuf
      ;; This file is produced by the gdk-pixbuf-loaders-cache-file
      ;; profile hook.
      (list (search-path-specification
-            (variable "GDK_PIXBUF_MODULE_FILE")
+            (variable "GUIX_GDK_PIXBUF_MODULE_FILES")
             (files (list %gdk-pixbuf-loaders-cache-file))
-            (separator #f)              ;single valued
             (file-type 'regular))))
     (synopsis "Image loading library")
     (description "GdkPixbuf is a library that loads image data in various
diff --git a/gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch b/gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch
new file mode 100644
index 0000000000..eb22761403
--- /dev/null
+++ b/gnu/packages/patches/gdk-pixbuf-respect-GUIX_GDK_PIXBUF_MODULE_FILES.patch
@@ -0,0 +1,18 @@ 
+diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
+index e1df590..ba24cf6 100644
+--- a/gdk-pixbuf/gdk-pixbuf-io.c
++++ b/gdk-pixbuf/gdk-pixbuf-io.c
+@@ -670,6 +670,13 @@ gdk_pixbuf_io_init (void)
+ 	gboolean ret;
+ 
+ 	gdk_pixbuf_io_init_builtin ();
++
++	/* Load loaders from GUIX_GDK_PIXBUF_MODULE_FILES. */
++	gchar **guix_module_files = g_build_guix_search_path_dirs ("GUIX_GDK_PIXBUF_MODULE_FILES");
++	for (int i = 0; guix_module_files[i] != NULL; i++)
++	    gdk_pixbuf_io_init_modules (guix_module_files[i], NULL);
++        g_strfreev (guix_module_files);
++
+ #ifdef USE_GMODULE
+ 	module_file = gdk_pixbuf_get_module_file ();
+ #endif