#45354 closed defect (fixed)
gdk-pixbuf2 @2.31.1 Hidden dependency on shared-mime-info
Reported by: | bgilbert (Benjamin Gilbert) | Owned by: | dbevans (David B. Evans) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | ryandesign (Ryan Carsten Schmidt), cooljeanius (Eric Gallager) | |
Port: | gdk-pixbuf2 |
Description
When reading an image file, gdk-pixbuf has two ways to select an appropriate loader: via GIO format sniffing, or via magic numbers provided by the individual loaders. Any particular build of gdk-pixbuf uses only one of these methods. By default, gdk-pixbuf uses GIO format sniffing if the shared-mime-info
database is available at compile time, and built-in sniffing otherwise.
The gdk-pixbuf2
package does not declare shared-mime-info
as a build dependency, but apparently it is installed on the build servers, as GIO sniffing ends up enabled:
$ nm -u /opt/local/lib/libgdk_pixbuf-2.0.dylib | grep g_content_type_guess _g_content_type_guess
Since shared-mime-info
is also not declared as a runtime dependency, port install gdk-pixbuf2
on a pristine system will install a gdk-pixbuf that refuses to open any image files.
Possible fixes:
- Add a
shared-mime-info
dependency toglib2
, since GIO is really the component that uses theshared-mime-info
database.
- Add a
shared-mime-info
dependency togdk-pixbuf2
, and either build-depend onshared-mime-info
or configure with--enable-gio-sniffing
.
- Configure
gdk-pixbuf2
with--disable-gio-sniffing
.
Change History (9)
comment:1 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)
Owner: | changed from macports-tickets@… to devans@… |
---|
comment:2 Changed 10 years ago by dbevans (David B. Evans)
Status: | new → assigned |
---|
comment:3 Changed 10 years ago by dbevans (David B. Evans)
Cc: | ryandesign@… added |
---|---|
Version: | 2.3.1 |
comment:4 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)
Replying to bgilbert@…:
The
gdk-pixbuf2
package does not declareshared-mime-info
as a build dependency, but apparently it is installed on the build servers,
The build servers have all ports deactivated before every build, so that only the ports that are in the dependency tree get used.
comment:5 follow-up: 7 Changed 10 years ago by bgilbert (Benjamin Gilbert)
It turns out that shared-mime-info
doesn't delete its cache files when it is uninstalled (filed as #45396), so removing it is not enough to get your system back to a pristine state. That explains why GIO content sniffing is enabled during gdk-pixbuf builds: the builders have had shared-mime-info
installed at some point in the past.
Here's a session demonstrating the problem:
$ port installed gdk-pixbuf2 shared-mime-info The following ports are currently installed: gdk-pixbuf2 @2.31.1_0+x11 (active) shared-mime-info @1.3_0 (active) $ wget -q https://www.macports.org/img/macports-logo-top.png $ cat gdk-pixbuf-open.c #include <stdio.h> #include <gdk-pixbuf/gdk-pixbuf.h> int main(int argc, char **argv) { GError *err = NULL; GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(argv[1], &err); if (pixbuf == NULL) { fprintf(stderr, "Failed: %s\n", err->message); } else { printf("OK\n"); } return 0; } $ gcc -o gdk-pixbuf-open $(pkg-config --cflags --libs glib-2.0 gdk-pixbuf-2.0) gdk-pixbuf-open.c $ ./gdk-pixbuf-open macports-logo-top.png OK $ sudo port uninstall shared-mime-info ---> Deactivating shared-mime-info @1.3_0 ---> Cleaning shared-mime-info ---> Uninstalling shared-mime-info @1.3_0 ---> Cleaning shared-mime-info $ ./gdk-pixbuf-open macports-logo-top.png OK $ ls -d /opt/local/share/mime/* | grep -v packages | sudo xargs rm -r $ ./gdk-pixbuf-open macports-logo-top.png Failed: Couldn't recognize the image file format for file 'macports-logo-top.png' $ sudo port install shared-mime-info ---> Computing dependencies for shared-mime-info ---> Fetching archive for shared-mime-info ---> Attempting to fetch shared-mime-info-1.3_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/shared-mime-info ---> Attempting to fetch shared-mime-info-1.3_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/shared-mime-info ---> Installing shared-mime-info @1.3_0 ---> Activating shared-mime-info @1.3_0 ---> Cleaning shared-mime-info ---> Updating database of binaries ---> Scanning binaries for linking errors ---> No broken files found. $ ./gdk-pixbuf-open macports-logo-top.png OK
To summarize: GIO content sniffing is implicitly enabled in gdk-pixbuf2
builds due to #45396, but doesn't actually return a useful result unless shared-mime-info
(or its leftover cache files) is installed. Neither the gdk-pixbuf2
nor glib2
packages depend on shared-mime-info
. As a result, a minimal install of gdk-pixbuf2
refuses to load any images.
comment:6 Changed 10 years ago by dbevans (David B. Evans)
Thanks for this additional clarification. Further testing in progress.
comment:7 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)
Replying to bgilbert@…:
It turns out that
shared-mime-info
doesn't delete its cache files when it is uninstalled (filed as #45396), so removing it is not enough to get your system back to a pristine state. That explains why GIO content sniffing is enabled during gdk-pixbuf builds: the builders have hadshared-mime-info
installed at some point in the past.
Good catch!
Replying to bgilbert@…:
Possible fixes:
- Add a
shared-mime-info
dependency toglib2
, since GIO is really the component that uses theshared-mime-info
database.
Can't: shared-mime-info already depends on glib2, so glib2 cannot depend on shared-mime-info because circular dependencies are not supported.
- Add a
shared-mime-info
dependency togdk-pixbuf2
, and either build-depend onshared-mime-info
or configure with--enable-gio-sniffing
.
This sounds reasonable. It would want to be a library dependency though. Just listing a build dependency won't get the port installed, in the event that a binary from our server is used.
comment:8 Changed 10 years ago by dbevans (David B. Evans)
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Confirmed that although, technically, neither glib2 nor gdkpixbuf2 depend on shared-mime-info, g_content_type_guess() does use it to guess mime type if present. If not, it doesn't fail but falls back to either 'text/plain' if it appears to text or 'application/octet-stream' otherwise. gdk-pixbuf2 will then fail to configure gio sniffing if shared-mime-info (including any previously cached mime data) is not available.
Since glib2 can't depend on shared-mime-info due to the creation of a dependency loop, this means not just gdk-pixbuf2, but any port that wants to use this gio sniffing facility, needs to have shared-mime-info in its dependency tree at run time. Both gtk2 and gtk3 have shared-mime-info as a run time dependency so this is covered in many (but not all?) cases.
Library dependency on shared-mime-info added to gdk-pixbuf2 and revision incremented in r126880 to ensure the presence of shared-mime-info when gdk-pixbuf2 is configured and run.
Good catch, indeed! Thanks.
I've taken a look at this issue and so far have not been able to establish any dependency on shared-mime-info hidden or not.
As you've said, as currently configured, gdk-pixbuf auto-configures whether or not to use gio sniffing based on a test program that calls two gio functions, g_content_type_guess() and g_content_type_from_mime_type() using an inline png test image. If both routines return the same result then the gdk-pixbuf gio code is enabled. If not, gdk-pixbuf uses another approach using internal data for guessing the mime type.
I thought perhaps this meant that glib (home of gio) depended on share-mime-info as you imply but this appears not to be the case either.
In my final test, I did a clean build of glib2 and gdk-pixbuf2 by first deactivating all installed ports, then doing a forced rebuild of glib2 and gdk-pixbuf2 in that sequence. I have confirmed that shared-mime-info is not active at any time during this process and yet the gdk-pixbuf2 configuration test passed and gio sniffing was enabled in gdk-pixbuf2.
So, unless you have further evidence to the contrary, I don't think there is anything to be done here.