diff --git a/doc/languages-frameworks/gnome.section.md b/doc/languages-frameworks/gnome.section.md index d5996cce13cfd..f05ca6dc1a449 100644 --- a/doc/languages-frameworks/gnome.section.md +++ b/doc/languages-frameworks/gnome.section.md @@ -34,11 +34,11 @@ To allow software to use various virtual file systems, `gvfs` package can be als ### GdkPixbuf loaders {#ssec-gnome-gdk-pixbuf-loaders} -GTK applications typically use [GdkPixbuf](https://developer.gnome.org/gdk-pixbuf/stable/) to load images. But `gdk-pixbuf` package only supports basic bitmap formats like JPEG, PNG or TIFF, requiring to use third-party loader modules for other formats. This is especially painful since GTK itself includes SVG icons, which cannot be rendered without a loader provided by `librsvg`. +GTK applications typically use [GdkPixbuf](https://developer.gnome.org/gdk-pixbuf/stable/) to load images. But `gdk-pixbuf` package only supports basic bitmap formats like JPEG, PNG or TIFF, requiring third-party loader modules for other formats. GTK itself includes SVG icons, which cannot be rendered without a loader provided by `librsvg`. -Unlike other libraries mentioned in this section, GdkPixbuf only supports a single value in its controlling environment variable `GDK_PIXBUF_MODULE_FILE`. It is supposed to point to a cache file containing information about the available loaders. Each loader package will contain a `lib/gdk-pixbuf-2.0/2.10.0/loaders.cache` file describing the default loaders in `gdk-pixbuf` package plus the loader contained in the package itself. If you want to use multiple third-party loaders, you will need to create your own cache file manually. Fortunately, this is pretty rare as [not many loaders exist](https://gitlab.gnome.org/federico/gdk-pixbuf-survey/blob/master/src/modules.md). +Each loader package will contain a `lib/gdk-pixbuf-2.0/2.10.0/loaders.cache` file containing information about the available loaders. GdkPixbuf looks for these files in the `GDK_PIXBUF_MODULE_FILE` environment variable. Although upstream GdkPixbuf only supports a single file, in nixpkgs it is patched to accept multiple files, separated by `:`. -`gdk-pixbuf` contains [a setup hook](#ssec-gnome-hooks-gdk-pixbuf) that sets `GDK_PIXBUF_MODULE_FILE` from dependencies but as mentioned in further section, it is pretty limited. Loaders should propagate this setup hook. +[`wrapGAppsHook`](#ssec-gnome-hooks-wrapgappshook) handles setting `GDK_PIXBUF_MODULE_FILE` for GTK apps. If you're manually constructing a wrapper (`wrapGAppsHook` is preferred), consider `--prefix`ing the variable rather than overwriting it, so that users can extend your program's capabilities through `services.xserver.gdk-pixbuf.modulePackages`. ### Icons {#ssec-gnome-icons} @@ -106,7 +106,7 @@ For convenience, it also adds `dconf.lib` for a GIO module implementing a GSetti - []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`. -- []{#ssec-gnome-hooks-gdk-pixbuf} `gdk-pixbuf` setup hook will populate `GDK_PIXBUF_MODULE_FILE` with the path to biggest `loaders.cache` file from the dependencies containing [GdkPixbuf loaders](#ssec-gnome-gdk-pixbuf-loaders). This works fine when there are only two packages containing loaders (`gdk-pixbuf` and e.g. `librsvg`) – it will choose the second one, reasonably expecting that it will be bigger since it describes extra loader in addition to the default ones. But when there are more than two loader packages, this logic will break. One possible solution would be constructing a custom cache file for each package containing a program like `services/x11/gdk-pixbuf.nix` NixOS module does. `wrapGAppsHook` copies the `GDK_PIXBUF_MODULE_FILE` environment variable into the produced wrapper. +- []{#ssec-gnome-hooks-gdk-pixbuf} `wrapGAppsHook` will automatically prepend `GDK_PIXBUF_MODULE_FILE` with modules from `gdk-pixbuf` and `librsvg`. To include additional gdk-pixbuf modules, set `extraGdkPixbufModules` with an array of packages. - []{#ssec-gnome-hooks-gtk-drop-icon-theme-cache} One of `gtk3`’s setup hooks will remove `icon-theme.cache` files from package’s icon theme directories to avoid conflicts. Icon theme packages should prevent this with `dontDropIconThemeCache = true;`. diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index b57698cb90b34..903e42de7d747 100644 --- a/doc/stdenv/stdenv.chapter.md +++ b/doc/stdenv/stdenv.chapter.md @@ -1077,10 +1077,6 @@ Adds the `share/texmf-nix` subdirectory of each build input to the `TEXINPUTS` e Sets the `QTDIR` environment variable to Qt’s path. -### gdk-pixbuf {#setup-hook-gdk-pixbuf} - -Exports `GDK_PIXBUF_MODULE_FILE` environment variable to the builder. Add librsvg package to `buildInputs` to get svg support. See also the [setup hook description in GNOME platform docs](#ssec-gnome-hooks-gdk-pixbuf). - ### GHC {#ghc} Creates a temporary package database and registers every Haskell build input in it (TODO: how?). diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml index 79268b398e60f..5cb82edf1ae15 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml @@ -31,6 +31,56 @@ stdenv.buildPlatform.canExecute stdenv.hostPlatform. + + + How gdk-pixbuf modules are set has changed. + + + + + gdk-pixbuf has been patched to accept + multiple loaders.cache files in + $GDK_PIXBUF_MODULE_FILE, separated by + : + + + + + Setting modules through wrapGAppsHook + (preferred method): wrapGAppsHook now + automatically includes modules from + gdk-pixbuf and + librsvg. This is backwards-compatible + for most packages. It no longer looks for a module file in + $GDK_PIXBUF_MODULE_FILE in the build + environment, gdk-pixbuf no longer sets + it when added to buildInputs, and you + no longer need to add gdk-pixbuf or + librsvg to + buildInputs unless the program directly + depends on it. To include additional gdk-pixbuf modules, + set extraGdkPixbufModules with an array + of packages. + + + + + Manually wrapping + $GDK_PIXBUF_MODULE_FILE: The + librsvg loaders.cache still contains + all of the loaders from gdk-pixbuf. + This might change in the future, so it is recommended that + you explicitly include both. As this change allows users + to extend programs with their own loaders, it is + recommended that you --prefix rather + than --set + $GDK_PIXBUF_MODULE_FILE with your + values. For example: + makeWrapper ... --prefix GDK_PIXBUF_MODULE_FILE : "${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache:${gdk-pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" + + + + PHP now defaults to PHP 8.1, updated from 8.0. diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md index 7d2eacce57fed..1deb01105c956 100644 --- a/nixos/doc/manual/release-notes/rl-2211.section.md +++ b/nixos/doc/manual/release-notes/rl-2211.section.md @@ -17,6 +17,17 @@ In addition to numerous new and upgraded packages, this release has the followin built for `stdenv.hostPlatform` (i.e. produced by `stdenv.cc`) by evaluating `stdenv.buildPlatform.canExecute stdenv.hostPlatform`. +- How `gdk-pixbuf` modules are set has changed. + - `gdk-pixbuf` has been patched to accept multiple `loaders.cache` files in `$GDK_PIXBUF_MODULE_FILE`, separated by `:` + - Setting modules through `wrapGAppsHook` (preferred method): + `wrapGAppsHook` now automatically includes modules from `gdk-pixbuf` and `librsvg`. This is backwards-compatible for most packages. + It no longer looks for a module file in `$GDK_PIXBUF_MODULE_FILE` in the build environment, `gdk-pixbuf` no longer sets it when added to `buildInputs`, and you no longer need to add `gdk-pixbuf` or `librsvg` to `buildInputs` unless the program directly depends on it. + To include additional gdk-pixbuf modules, set `extraGdkPixbufModules` with an array of packages. + - Manually wrapping `$GDK_PIXBUF_MODULE_FILE`: + The `librsvg` loaders.cache still contains all of the loaders from `gdk-pixbuf`. This might change in the future, so it is recommended that you explicitly include both. + As this change allows users to extend programs with their own loaders, it is recommended that you `--prefix` rather than `--set` `$GDK_PIXBUF_MODULE_FILE` with your values. + For example: `makeWrapper ... --prefix GDK_PIXBUF_MODULE_FILE : "${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache:${gdk-pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"` + - PHP now defaults to PHP 8.1, updated from 8.0. diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix index d7699b2557fc4..2879b18830ea3 100644 --- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix @@ -10,6 +10,7 @@ , callPackage , wrapGAppsHook , writeTextFile +, gdk-pixbuf }: makeSetupHook { @@ -37,8 +38,12 @@ makeSetupHook { makeWrapper ]; substitutions = { + standardGdkPixbufModules = lib.makeSearchPathOutput "lib" gdk-pixbuf.cacheFile [ gdk-pixbuf librsvg ]; + gdkPixbufCacheFile = gdk-pixbuf.cacheFile; + passthru.tests = let sample-project = ./tests/sample-project; + mock-pixbuf-module = callPackage ./tests/sample-module.nix {}; testLib = callPackage ./tests/lib.nix { }; inherit (testLib) expectSomeLineContainingYInFileXToMentionZ; @@ -64,6 +69,19 @@ makeSetupHook { '' ); + pixbuf-modules = basic.overrideAttrs (old: {extraGdkPixbufModules = [mock-pixbuf-module];}); + + pixbuf-modules-check = let + tested = pixbuf-modules; + in testLib.runTest "pixbuf-modules-check" '' + ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE" "${gdk-pixbuf}/${gdk-pixbuf.cacheFile}"} + ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.cacheFile}"} + ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE" "${mock-pixbuf-module}/${gdk-pixbuf.cacheFile}"} + ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE" "${gdk-pixbuf}/${gdk-pixbuf.cacheFile}"} + ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.cacheFile}"} + ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE" "${mock-pixbuf-module}/${gdk-pixbuf.cacheFile}"} + ''; + # Simple derivation containing a gobject-introspection typelib. typelib-Mahjong = stdenv.mkDerivation { name = "typelib-Mahjong"; diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-module.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-module.nix new file mode 100644 index 0000000000000..09bff039c3ad7 --- /dev/null +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-module.nix @@ -0,0 +1,13 @@ +{stdenv, gdk-pixbuf}: +stdenv.mkDerivation { + name = "mock-gdk-pixbuf-module"; + outputs = ["out" "bin"]; + dontUnpack = true; + buildPhase = '' + mkdir -p $bin + mkdir -p $out/$(dirname ${gdk-pixbuf.cacheFile}) + touch $out/${gdk-pixbuf.cacheFile} + ''; + dontInstall = true; + dontFixup = true; +} \ No newline at end of file diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh index 0acf4a8e6f8d4..a3b75ffa2761d 100644 --- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh @@ -10,8 +10,13 @@ find_gio_modules() { addEnvHooks "${targetOffset:?}" find_gio_modules gappsWrapperArgsHook() { - if [ -n "$GDK_PIXBUF_MODULE_FILE" ]; then - gappsWrapperArgs+=(--set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE") + + gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "@standardGdkPixbufModules@") + + if [ -n "$extraGdkPixbufModules" ]; then + for pkg in $extraGdkPixbufModules; do + gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "$pkg/@gdkPixbufCacheFile@") + done fi if [ -n "$GSETTINGS_SCHEMAS_PATH" ]; then diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix index cbed6a62a3c58..6f058718ab942 100644 --- a/pkgs/development/libraries/gdk-pixbuf/default.nix +++ b/pkgs/development/libraries/gdk-pixbuf/default.nix @@ -19,6 +19,7 @@ , doCheck ? false , makeWrapper , lib +, callPackage , withIntrospection ? (stdenv.buildPlatform == stdenv.hostPlatform) , gobject-introspection }: @@ -42,6 +43,8 @@ stdenv.mkDerivation rec { patches = [ # Move installed tests to a separate output ./installed-tests-path.patch + # Allow for multiple loaders.cache files specified in $GDK_PIXBUF_MODULE_FILE, delimited by ":" + ./multiple-module-files.patch ]; # gdk-pixbuf-thumbnailer is not wrapped therefore strictDeps will work @@ -128,8 +131,6 @@ stdenv.mkDerivation rec { # The tests take an excessive amount of time (> 1.5 hours) and memory (> 6 GB). inherit doCheck; - setupHook = ./setup-hook.sh; - separateDebugInfo = stdenv.isLinux; passthru = { @@ -140,10 +141,12 @@ stdenv.mkDerivation rec { tests = { installedTests = nixosTests.installed-tests.gdk-pixbuf; + multiple-module-files = callPackage ./multiple-module-files-test {}; }; # gdk_pixbuf_moduledir variable from gdk-pixbuf-2.0.pc moduleDir = "lib/gdk-pixbuf-2.0/2.10.0/loaders"; + cacheFile = "lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"; }; meta = with lib; { diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix new file mode 100644 index 0000000000000..1faaabf2f506d --- /dev/null +++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix @@ -0,0 +1,57 @@ +# Simple tests for multiple module files functionality. +# gdk-pixbuf-thumbnailer is used as a simple, command-line consumer of loaders. +# In the future, would like to test unexpected inputs/fuzzing. +{ runCommand, gdk-pixbuf, librsvg, callPackage, imagemagick}: +let + thumbnailer = "${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer"; + + pixbufloader = gdk-pixbuf + "/" + gdk-pixbuf.cacheFile; + svgloader = librsvg + "/" + gdk-pixbuf.cacheFile; + redloader = (callPackage ./test-loader.nix {outputColor="#FF0000";}) + "/" + gdk-pixbuf.cacheFile; + blueloader = (callPackage ./test-loader.nix {outputColor="#0000FF";}) + "/" + gdk-pixbuf.cacheFile; + + svgsample = ./sample.svg; + gifsample = ./sample.gif; +in runCommand "pixbuf-mmf-test" {} '' + mkdir -p $out + set +e + + function svgtest { + modulepath=$1 + GDK_PIXBUF_MODULE_FILE=$modulepath "${thumbnailer}" "${svgsample}" "$out/thumbnail.png" + } + + function colortest { + modulepath=$1 + checkcolor=$2 + GDK_PIXBUF_MODULE_FILE=$modulepath "${thumbnailer}" "${gifsample}" "$out/thumbnail.png" + "${imagemagick}/bin/convert" "$out/thumbnail.png" -resize 1x1 "$out/summarized.txt" + grep "$checkcolor" "$out/summarized.txt" + } + + # sanity check + if svgtest "${pixbufloader}"; then + >&2 echo "Test failed. SVG parsing succeeded even though librsvg loader wasn't provided. This shouldn't happen?" + exit 1 + fi + + # basic check for multiple file loading + if ! svgtest "${pixbufloader}:${svgloader}"; then + >&2 echo "Test failed. Second module file couldn't be loaded." + exit 2 + fi + + # check that priority goes to earlier entries in the list + if ! colortest "${redloader}:${pixbufloader}:${blueloader}" "#FF0000"; then + if colortest "${redloader}:${pixbufloader}:${blueloader}" "#0000FF"; then + >&2 echo "Test failed. Path order priority is incorrect." + exit 3 + else + >&2 echo "Test failed. Unknown error with test loader code." + exit 4 + fi + fi + + echo "Tests succeeded for gdk-pixbuf multiple module files patch." + exit 0 +'' diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.gif b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.gif new file mode 100644 index 0000000000000..46c56831391b2 Binary files /dev/null and b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.gif differ diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.svg b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.svg new file mode 100644 index 0000000000000..05e6c573d490c --- /dev/null +++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader.nix b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader.nix new file mode 100644 index 0000000000000..dae657b720705 --- /dev/null +++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader.nix @@ -0,0 +1,18 @@ +{ stdenv +, gdk-pixbuf +, pkg-config +, meson +, ninja +, outputColor ? "#ffffff" +}: +stdenv.mkDerivation { + name = "gdk-pixbuf-test-loader"; + src = ./test-loader; + buildInputs = [gdk-pixbuf]; + nativeBuildInputs = [pkg-config meson ninja]; + postInstall = '' + mkdir -p $(dirname $out/${gdk-pixbuf.cacheFile}) + ${gdk-pixbuf.dev}/bin/gdk-pixbuf-query-loaders $out/lib/libtest_loader.so > $out/${gdk-pixbuf.cacheFile} + ''; + mesonFlags = ["-DoutputColor=${outputColor}"]; +} \ No newline at end of file diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/loader.c b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/loader.c new file mode 100644 index 0000000000000..59cb1c36b6725 --- /dev/null +++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/loader.c @@ -0,0 +1,123 @@ +#define GDK_PIXBUF_ENABLE_BACKEND +#include +#include +#undef GDK_PIXBUF_ENABLE_BACKEND + + +#ifndef PIXBUF_COLOR +#error PIXBUF_COLOR must be set to a hex color string. +#endif + + +G_MODULE_EXPORT void fill_vtable(GdkPixbufModule* module); + +G_MODULE_EXPORT void fill_info(GdkPixbufFormat* info); + + +typedef struct { + GdkPixbufModuleUpdatedFunc update_func; + GdkPixbufModulePreparedFunc prepare_func; + GdkPixbufModuleSizeFunc size_func; + gpointer user_data; +} TestPixbufCtx; + + +static gpointer begin_load( + GdkPixbufModuleSizeFunc size_func, + GdkPixbufModulePreparedFunc prepare_func, + GdkPixbufModuleUpdatedFunc update_func, + gpointer user_data, + GError** error +) { + TestPixbufCtx* tpc; + + tpc = g_new0(TestPixbufCtx, 1); + tpc->size_func = size_func; + tpc->prepare_func = prepare_func; + tpc->update_func = update_func; + tpc->user_data = user_data; + + return tpc; +} + + +static char * xpm[] = { + // width, height, #colors, #chars_per_pixel + "1 1 1 1", + // palette + "a c " PIXBUF_COLOR, + // image + "a" +}; + +static gboolean stop_load(gpointer context, GError** error) { + TestPixbufCtx* tpc = (TestPixbufCtx*) context; + int width, height; + int requested_width, requested_height; + g_autoptr(GdkPixbuf) pixbuf; + + + width = 1; + height = 1; + requested_width = width; + requested_height = height; + + if (tpc->size_func) { + (*tpc->size_func)(&requested_width, &requested_height, tpc->user_data); + } + + pixbuf = gdk_pixbuf_new_from_xpm_data(xpm); + + if (tpc->prepare_func) { + (*tpc->prepare_func)(pixbuf, NULL, tpc->user_data); + } + + if (tpc->update_func != NULL) { + (*tpc->update_func)(pixbuf, 0, 0, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), tpc->user_data); + } + + g_clear_object(&pixbuf); + g_free(tpc); + + return TRUE; +} + + +static gboolean load_increment(gpointer context, const guchar* buf, guint size, GError** error) { + return TRUE; +} + + +void fill_vtable(GdkPixbufModule* module) { + module->begin_load = begin_load; + module->stop_load = stop_load; + module->load_increment = load_increment; +} + + +void fill_info(GdkPixbufFormat* info) { + static GdkPixbufModulePattern signature[] = { + {"GIF8", NULL, 100}, + {NULL, NULL, 0} + }; + + static gchar* mime_types[] = { + "image/gif", + NULL + }; + + static gchar* extensions[] = { + "gif", + NULL + }; + + info->name = "test"; + info->signature = signature; + info->domain = NULL; + info->description = "Loader for testing priority of loaders"; + info->mime_types = mime_types; + info->extensions = extensions; + info->flags = GDK_PIXBUF_FORMAT_THREADSAFE; + info->disabled = FALSE; + info->license = "MIT"; +} \ No newline at end of file diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson.build b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson.build new file mode 100644 index 0000000000000..d4ff6ebbf14fa --- /dev/null +++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson.build @@ -0,0 +1,11 @@ +project('gdk-pixbuf-test-loader', 'c') + +gdk_pixbuf = dependency('gdk-pixbuf-2.0') +outputColor = get_option('outputColor') + +shared_library('test_loader', + sources: ['loader.c'], + dependencies: [gdk_pixbuf], + install: true, + c_args: ['-DPIXBUF_COLOR="' + outputColor + '"'] +) \ No newline at end of file diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson_options.txt b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson_options.txt new file mode 100644 index 0000000000000..6d0d68a7d0792 --- /dev/null +++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson_options.txt @@ -0,0 +1 @@ +option('outputColor', type:'string') \ No newline at end of file diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch new file mode 100644 index 0000000000000..f1674959b2045 --- /dev/null +++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch @@ -0,0 +1,32 @@ +diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c +index 1827811..eda0c29 100644 +--- a/gdk-pixbuf/gdk-pixbuf-io.c ++++ b/gdk-pixbuf/gdk-pixbuf-io.c +@@ -668,13 +668,24 @@ static gboolean + gdk_pixbuf_io_init (void) + { + char *module_file; +- gboolean ret; ++ gboolean ret = FALSE; + + gdk_pixbuf_io_init_builtin (); + #ifdef USE_GMODULE + module_file = gdk_pixbuf_get_module_file (); ++ gchar **files = g_strsplit(module_file, ":", -1); ++ ++ int num_files = 0; ++ while(files[num_files] != NULL) num_files++; ++ ++ for(int i = num_files - 1; i >= 0; i--){ /* reverse iteration so earlier files have precedence */ ++ if(files[i][0] != '\0'){ /* :: yields an empty split string, we should ignore */ ++ ret |= gdk_pixbuf_io_init_modules (files[i], NULL); ++ } ++ } ++ ++ g_strfreev(files); + #endif +- ret = gdk_pixbuf_io_init_modules (module_file, NULL); + g_free (module_file); + return ret; + } + \ No newline at end of file diff --git a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh b/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh deleted file mode 100644 index ecf9793b91f6c..0000000000000 --- a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh +++ /dev/null @@ -1,17 +0,0 @@ -findGdkPixbufLoaders() { - - # choose the longest loaders.cache - local loadersCache="$1/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" - if [[ -f "$loadersCache" ]]; then - if [[ -f "${GDK_PIXBUF_MODULE_FILE-}" ]]; then - if (( "$(cat "$loadersCache" | wc -l)" > "$(cat "$GDK_PIXBUF_MODULE_FILE" | wc -l)" )); then - export GDK_PIXBUF_MODULE_FILE="$loadersCache" - fi - else - export GDK_PIXBUF_MODULE_FILE="$loadersCache" - fi - fi - -} - -addEnvHooks "$targetOffset" findGdkPixbufLoaders