From 555b8c1a46c197d251553a25e051da9e76ddc3af Mon Sep 17 00:00:00 2001 From: Johannes Rosenberger Date: Tue, 28 Apr 2020 18:10:19 +0200 Subject: [PATCH] libextractor: add support for gstreamer plugin The gstreamer plugin provides support for additional common file/tagging formats like id3 tags in mp3 files. In addition, it e.g. exposes more tags than the FLAC plugin for FLAC files. Increase of closure size: 86.71 MB (52.8%) --- .../libraries/libextractor/default.nix | 28 +++++++++++++++++-- .../libextractor/gst-hardcode-plugins.patch | 11 ++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/libraries/libextractor/gst-hardcode-plugins.patch diff --git a/pkgs/development/libraries/libextractor/default.nix b/pkgs/development/libraries/libextractor/default.nix index ea155440c8d1..3db0b056c0f0 100644 --- a/pkgs/development/libraries/libextractor/default.nix +++ b/pkgs/development/libraries/libextractor/default.nix @@ -1,8 +1,21 @@ -{ fetchurl, stdenv, libtool, gettext, zlib, bzip2, flac, libvorbis +{ fetchurl, stdenv, substituteAll +, libtool, gettext, zlib, bzip2, flac, libvorbis , exiv2, libgsf, rpm, pkgconfig, fetchpatch +, gstreamerSupport ? true, gst_all_1 ? null +# ^ Needed e.g. for proper id3 and FLAC support. +# Set to `false` to decrease package closure size by about 87 MB (53%). +, gstPlugins ? (gst: [ gst.gst-plugins-base gst.gst-plugins-good ]) +# If an application needs additional gstreamer plugins it can also make them +# available by adding them to the environment variable +# GST_PLUGIN_SYSTEM_PATH_1_0, e.g. like this: +# postInstall = '' +# wrapProgram $out/bin/extract --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0" +# ''; +# See also . , gtkSupport ? true, glib ? null, gtk3 ? null , videoSupport ? true, ffmpeg ? null, libmpeg2 ? null}: +assert gstreamerSupport -> gst_all_1 != null && builtins.isList (gstPlugins gst_all_1); assert gtkSupport -> glib != null && gtk3 != null; assert videoSupport -> ffmpeg != null && libmpeg2 != null; @@ -28,6 +41,15 @@ stdenv.mkDerivation rec { sha256 = "01xhcjbzv6p53wz7y2ii76kb8m9iwvnm4ip9w4a0bpgaxqz4b9fw"; excludes = [ "ChangeLog" ]; }) + ] ++ stdenv.lib.optionals gstreamerSupport [ + + # Libraries cannot be wrapped so we need to hardcode the plug-in paths. + (substituteAll { + src = ./gst-hardcode-plugins.patch; + load_gst_plugins = stdenv.lib.concatMapStrings + (plugin: ''gst_registry_scan_path(gst_registry_get(), "${plugin}/lib/gstreamer-1.0");'') + (gstPlugins gst_all_1); + }) ]; preConfigure = @@ -40,7 +62,9 @@ stdenv.mkDerivation rec { [ libtool gettext zlib bzip2 flac libvorbis exiv2 libgsf rpm pkgconfig - ] ++ stdenv.lib.optionals gtkSupport [ glib gtk3 ] + ] ++ stdenv.lib.optionals gstreamerSupport + ([ gst_all_1.gstreamer ] ++ gstPlugins gst_all_1) + ++ stdenv.lib.optionals gtkSupport [ glib gtk3 ] ++ stdenv.lib.optionals videoSupport [ ffmpeg libmpeg2 ]; configureFlags = [ diff --git a/pkgs/development/libraries/libextractor/gst-hardcode-plugins.patch b/pkgs/development/libraries/libextractor/gst-hardcode-plugins.patch new file mode 100644 index 000000000000..73ecf5f252f6 --- /dev/null +++ b/pkgs/development/libraries/libextractor/gst-hardcode-plugins.patch @@ -0,0 +1,11 @@ +--- a/src/plugins/gstreamer_extractor.c ++++ b/src/plugins/gstreamer_extractor.c +@@ -2215,6 +2215,7 @@ void __attribute__ ((constructor)) + gstreamer_init () + { + gst_init (NULL, NULL); ++ @load_gst_plugins@ + g_log_set_default_handler (&log_handler, NULL); + g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, + &log_handler, NULL); +