Subject: bug#25414: [PATCH] gnu: gdk-pixbuf: Make it reproducible.

From: Danny Milosavljevic <[email-masked]>
Date: Sun, 15 Jan 2017 02:22:07 +0100

* gnu/packages/gtk.scm (gdk-pixbuf): Make it reproducible.
---
 gnu/local.mk                                   |  1 +
 gnu/packages/gtk.scm                           |  3 ++-
 gnu/packages/patches/gdk-pixbuf-list-dir.patch | 29 ++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/gdk-pixbuf-list-dir.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d37887237..05e6d653f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -567,6 +567,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gcc-6-arm-none-eabi-multilib.patch	\
   %D%/packages/patches/gcc-6-cross-environment-variables.patch	\
   %D%/packages/patches/gcj-arm-mode.patch			\
+  %D%/packages/patches/gdk-pixbuf-list-dir.patch		\
   %D%/packages/patches/gd-CVE-2016-7568.patch			\
   %D%/packages/patches/gd-CVE-2016-8670.patch			\
   %D%/packages/patches/gd-fix-chunk-size-on-boundaries.patch	\
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index b2882b5e9..c4c441f4c 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -434,7 +434,8 @@ highlighting and other features typical of a source code editor.")
                                 name "-" version ".tar.xz"))
             (sha256
              (base32
-              "0yc8indbl3hf18z6x6kjg59xp9sngm1d8vmz4c7bs6g27qw5npnm"))))
+              "0yc8indbl3hf18z6x6kjg59xp9sngm1d8vmz4c7bs6g27qw5npnm"))
+            (patches (search-patches "gdk-pixbuf-list-dir.patch"))))
    (build-system gnu-build-system)
    (arguments
     '(#:configure-flags '("--with-x11")
diff --git a/gnu/packages/patches/gdk-pixbuf-list-dir.patch b/gnu/packages/patches/gdk-pixbuf-list-dir.patch
new file mode 100644
index 000000000..d1427cc38
--- /dev/null
+++ b/gnu/packages/patches/gdk-pixbuf-list-dir.patch
@@ -0,0 +1,29 @@
+--- gdk-pixbuf-2.34.0/gdk-pixbuf/queryloaders.c.orig      2017-01-11 00:17:32.865843062 +0100
++++ gdk-pixbuf-2.34.0/gdk-pixbuf/queryloaders.c   2017-01-11 00:31:29.428372177 +0100
+@@ -354,16 +354,25 @@
+ 
+                 dir = g_dir_open (path, 0, NULL);
+                 if (dir) {
++                        GList *entries = NULL;
+                         const char *dent;
+ 
+                         while ((dent = g_dir_read_name (dir))) {
+                                 gint len = strlen (dent);
+                                 if (len > SOEXT_LEN &&
+                                     strcmp (dent + len - SOEXT_LEN, SOEXT) == 0) {
+-                                        query_module (contents, path, dent);
++                                        entries = g_list_append (entries, g_strdup (dent));
+                                 }
+                         }
+                         g_dir_close (dir);
++                        entries = g_list_sort (entries, strcmp);
++                        GList *xentries;
++                        for (xentries = entries; xentries; xentries = g_list_next (xentries)) {
++                                dent = xentries->data;
++                                query_module (contents, path, dent);
++                                g_free (xentries->data);
++                        }
++                        g_list_free (entries);
+                 }
+ #else
+                 g_string_append_printf (contents, "# dynamic loading of modules not supported\n");