5c6f194
diff -up gutenprint-5.3.3/src/main/gutenprint-internal.h.postscriptdriver gutenprint-5.3.3/src/main/gutenprint-internal.h
5c6f194
--- gutenprint-5.3.3/src/main/gutenprint-internal.h.postscriptdriver	2018-01-28 03:32:45.000000000 +0100
5c6f194
+++ gutenprint-5.3.3/src/main/gutenprint-internal.h	2019-11-06 12:13:29.936061606 +0100
5c6f194
@@ -54,6 +54,8 @@ extern void stpi_init_printer(void);
4fe887e
 #define BUFFER_FLAG_FLIP_X	0x1
4fe887e
 #define BUFFER_FLAG_FLIP_Y	0x2
4fe887e
 extern stp_image_t* stpi_buffer_image(stp_image_t* image, unsigned int flags);
4fe887e
+extern stp_list_t *stp_paths_copy_with_prefix(stp_list_t* list,
4fe887e
+					      const char *prefix);
4fe887e
 
4fe887e
 #define STPI_ASSERT(x,v)						\
4fe887e
 do									\
5c6f194
diff -up gutenprint-5.3.3/src/main/module.c.postscriptdriver gutenprint-5.3.3/src/main/module.c
5c6f194
--- gutenprint-5.3.3/src/main/module.c.postscriptdriver	2019-05-25 16:34:21.000000000 +0200
5c6f194
+++ gutenprint-5.3.3/src/main/module.c	2019-11-06 12:13:29.936061606 +0100
5c6f194
@@ -159,12 +159,20 @@ int stp_module_load(void)
1bd8b5c
     }
1bd8b5c
   else
1bd8b5c
     {
1bd8b5c
+      const char *prefix = getenv("DESTDIR");
1bd8b5c
 #ifdef USE_LTDL
1bd8b5c
       stp_path_split(dir_list, getenv("LTDL_LIBRARY_PATH"));
1bd8b5c
       stp_path_split(dir_list, lt_dlgetsearchpath());
1bd8b5c
 #else
1bd8b5c
       stp_path_split(dir_list, PKGMODULEDIR);
1bd8b5c
 #endif
1bd8b5c
+      if (prefix)
1bd8b5c
+	{
1bd8b5c
+	  stp_list_t *prefix_list;
1bd8b5c
+	  prefix_list = stp_paths_copy_with_prefix(dir_list, prefix);
1bd8b5c
+	  stp_list_destroy(dir_list);
1bd8b5c
+	  dir_list = prefix_list;
1bd8b5c
+	}
1bd8b5c
     }
1bd8b5c
 #ifdef USE_LTDL
1bd8b5c
   file_list = stp_path_search(dir_list, ".la");
5c6f194
diff -up gutenprint-5.3.3/src/main/path.c.postscriptdriver gutenprint-5.3.3/src/main/path.c
5c6f194
--- gutenprint-5.3.3/src/main/path.c.postscriptdriver	2019-05-25 16:34:21.000000000 +0200
5c6f194
+++ gutenprint-5.3.3/src/main/path.c	2019-11-06 12:29:30.709190171 +0100
5c6f194
@@ -154,6 +154,17 @@ stp_generate_path(const char *path)
5c6f194
     return NULL;
5c6f194
   stp_list_set_freefunc(dir_list, stp_list_node_free_data);
5c6f194
   stp_path_split(dir_list, path);
5c6f194
+  if (!strncmp(PKGXMLDATADIR, path, strlen(path)))
5c6f194
+  {
5c6f194
+    const char *prefix = getenv("DESTDIR");
5c6f194
+    if (prefix)
1bd8b5c
+    {
5c6f194
+      stp_list_t *prefix_list;
5c6f194
+      prefix_list = stp_paths_copy_with_prefix(dir_list, prefix);
5c6f194
+      stp_list_destroy(dir_list);
5c6f194
+      dir_list = prefix_list;
1bd8b5c
+    }
5c6f194
+  }
1bd8b5c
   return dir_list;
1bd8b5c
 }
1bd8b5c
 
5c6f194
@@ -262,6 +273,40 @@ stp_path_split(stp_list_t *list, /* List
1bd8b5c
     }
1bd8b5c
 }
1bd8b5c
 
1bd8b5c
+/*
1bd8b5c
+ * Split a PATH-type string (colon-delimited) into separate
1bd8b5c
+ * directories.
1bd8b5c
+ */
1bd8b5c
+stp_list_t *
1bd8b5c
+stp_paths_copy_with_prefix(stp_list_t *list,   /* List to add prefix to */
1bd8b5c
+			   const char *prefix) /* Prefix to add */
1bd8b5c
+{
1bd8b5c
+  stp_list_t *new_list;
1bd8b5c
+  stp_list_item_t *item;
1bd8b5c
+  int prefixlen = strlen (prefix);
1bd8b5c
+  if (!(new_list = stp_list_create()))
66add65
+    return NULL;
1bd8b5c
+
1bd8b5c
+  item = stp_list_get_start (list);
1bd8b5c
+  while (item)
1bd8b5c
+    {
1bd8b5c
+      const char *data;
1bd8b5c
+      char *new_data;
1bd8b5c
+      int len;
1bd8b5c
+      data = stp_list_item_get_data (item);
1bd8b5c
+      len = strlen (data);
1bd8b5c
+      new_data = (char *) stp_malloc(prefixlen + 1 + len + 1);
1bd8b5c
+      strncpy(new_data, prefix, prefixlen);
1bd8b5c
+      new_data[prefixlen] = '/';
1bd8b5c
+      strcpy(new_data + prefixlen + 1, data);
1bd8b5c
+      stp_list_item_create(new_list, NULL, new_data);
1bd8b5c
+
1bd8b5c
+      item = stp_list_item_next (item);
1bd8b5c
+    }
1bd8b5c
+
1bd8b5c
+  return new_list;
1bd8b5c
+}
1bd8b5c
+
1bd8b5c
 /* Adapted from GNU libc <dirent.h>
1bd8b5c
    These macros extract size information from a `struct dirent *'.
1bd8b5c
    They may evaluate their argument multiple times, so it must not