After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 737523 - Extend relocation support to OS X and Linux
Extend relocation support to OS X and Linux
Status: RESOLVED FIXED
Product: gdk-pixbuf
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: gdk-pixbuf-maint
gdk-pixbuf-maint
Depends on:
Blocks:
 
 
Reported: 2014-09-28 11:57 UTC by Andoni Morales
Modified: 2014-10-22 19:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
io: extend support for relocations to OS X and Linux (4.41 KB, patch)
2014-09-28 11:57 UTC, Andoni Morales
none Details | Review
io: extend support for relocations to OS X and Linux (5.43 KB, patch)
2014-09-29 16:47 UTC, Andoni Morales
none Details | Review
io: Extend relocation support to OS X and Linux (5.58 KB, patch)
2014-10-07 09:43 UTC, Andoni Morales
needs-work Details | Review
lib: add gdk_pixbuf_win32_get_toplevel to the private API (2.45 KB, patch)
2014-10-22 18:00 UTC, Andoni Morales
committed Details | Review
io: extend support for relotations to OS X and Linux (6.09 KB, patch)
2014-10-22 18:02 UTC, Andoni Morales
none Details | Review
io: extend support for relotations to OS X and Linux (6.16 KB, patch)
2014-10-22 18:08 UTC, Andoni Morales
committed Details | Review

Description Andoni Morales 2014-09-28 11:57:28 UTC
Created attachment 287288 [details] [review]
io: extend support for relocations to OS X and Linux

For Windows platforms, gdk-pixbuf has support to replace the build-time directory of modules in loaders.cache to the runtime prefix considering these directories are almost always different.

But the same happens with OS X applications, which are bundles that can be installed anywhere and Linux bundles. This patch extends the relocation support to these platforms too.

With this patch the relocation is enabled for OS X and Windows by default, and disabled on Linux.

Ideally, I would like to have a configure option --enable-relocations, but I don't know how to change the default value depending on the target platform in the m4 world.
Comment 1 Andoni Morales 2014-09-29 16:47:33 UTC
Created attachment 287375 [details] [review]
io: extend support for relocations to OS X and Linux

Apply changes to get_localedir() in gdk-pixbuf-utils.c too
Comment 2 Andoni Morales 2014-10-07 09:43:57 UTC
Created attachment 287938 [details] [review]
io: Extend relocation support to OS X and Linux 

Add missing include
Comment 3 Bastien Nocera 2014-10-21 16:36:48 UTC
Review of attachment 287938 [details] [review]:

::: configure.ac
@@ +1073,3 @@
+# cache with the installation prefix on this machine
+# for relocatable packages such as Windows and OS X
+# applicationsapplications and linux bundles

That doesn't seem to enable it for Linux platform, does it?

::: gdk-pixbuf/gdk-pixbuf-io.c
@@ +211,3 @@
+    toplevel = g_build_path (G_DIR_SEPARATOR_S, bin_dir, "..", NULL);
+    g_free (bin_dir);
+#elif defined (G_OS_UNIX)

You need to check for Linux specifically here, I doubt this works on, say, FreeBSD.

@@ +220,3 @@
+    g_free (bin_dir);
+#else
+#error "Relocations not supported for this platform"

This needs not to fail on other platforms, so you probably want to wrap _gdk_pixbuf_get_toplevel() in #ifdef GDK_PIXBUF_RELOCATABLE.

::: gdk-pixbuf/gdk-pixbuf-util.c
@@ +360,2 @@
     /* In gdk-pixbuf-io.c */
+    extern char *_gdk_pixbuf_get_toplevel (void);

That's pretty ugly and should be fixed in a preliminary patch. Move the definition to "gkd-pixbuf-private.h", which isn't installed.

@@ +370,3 @@
     g_free (temp);
+#else
+    retval = temp;

I'd do:
#ifdef G_OS_WIN32
 {
    char *retval;
     retval = g_win32_locale_filename_from_utf8 (temp);
     g_free (temp);
     return retval;
  }
#else
  return temp;
#endif
Comment 4 Andoni Morales 2014-10-21 17:39:34 UTC
(In reply to comment #3)
> Review of attachment 287938 [details] [review]:
> 
> ::: configure.ac
> @@ +1073,3 @@
> +# cache with the installation prefix on this machine
> +# for relocatable packages such as Windows and OS X
> +# applicationsapplications and linux bundles
> 
> That doesn't seem to enable it for Linux platform, does it?

I don't think it should be enabled for Linux platforms by default as it wouldn't work for applications installed in /usr/local but linking against libgdkpixbuf from /usr/lib
If one is building an AppKit bundle, the build system can enable it adding -DGDK_PIXBUF_RELOCATABLE to the CFLAGS.
Comment 5 Bastien Nocera 2014-10-22 17:14:11 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Review of attachment 287938 [details] [review] [details]:
> > 
> > ::: configure.ac
> > @@ +1073,3 @@
> > +# cache with the installation prefix on this machine
> > +# for relocatable packages such as Windows and OS X
> > +# applicationsapplications and linux bundles
> > 
> > That doesn't seem to enable it for Linux platform, does it?
> 
> I don't think it should be enabled for Linux platforms by default as it
> wouldn't work for applications installed in /usr/local but linking against
> libgdkpixbuf from /usr/lib
> If one is building an AppKit bundle, the build system can enable it adding
> -DGDK_PIXBUF_RELOCATABLE to the CFLAGS.

Right, I misunderstood that. Can you update the patch though?
Comment 6 Andoni Morales 2014-10-22 18:00:14 UTC
Created attachment 289160 [details] [review]
lib: add gdk_pixbuf_win32_get_toplevel to the private API
Comment 7 Andoni Morales 2014-10-22 18:02:21 UTC
Created attachment 289161 [details] [review]
io: extend support for relotations to OS X and Linux
Comment 8 Andoni Morales 2014-10-22 18:05:25 UTC
G_OS_LINUX does not exists though...
Comment 9 Andoni Morales 2014-10-22 18:08:18 UTC
Created attachment 289163 [details] [review]
io: extend support for relotations to OS X and Linux
Comment 10 Bastien Nocera 2014-10-22 18:56:40 UTC
Review of attachment 289160 [details] [review]:

Looks good.
Comment 11 Bastien Nocera 2014-10-22 18:58:33 UTC
Review of attachment 289163 [details] [review]:

Looks good as well.
Comment 12 Bastien Nocera 2014-10-22 19:00:21 UTC
Attachment 289160 [details] pushed as ae7716c - lib: add gdk_pixbuf_win32_get_toplevel to the private API
Attachment 289163 [details] pushed as a55aa6e - io: extend support for relotations to OS X and Linux