1{ lib, stdenv, fetchurl, fetchpatch, substituteAll
2, libtool, gettext, zlib, bzip2, flac, libvorbis
3, exiv2, libgsf, rpm, pkg-config
4, gstreamerSupport ? true, gst_all_1
5# ^ Needed e.g. for proper id3 and FLAC support.
6# Set to `false` to decrease package closure size by about 87 MB (53%).
7, gstPlugins ? (gst: [ gst.gst-plugins-base gst.gst-plugins-good ])
8# If an application needs additional gstreamer plugins it can also make them
9# available by adding them to the environment variable
10# GST_PLUGIN_SYSTEM_PATH_1_0, e.g. like this:
11# postInstall = ''
12# wrapProgram $out/bin/extract --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0"
13# '';
14# See also <https://nixos.org/nixpkgs/manual/#sec-language-gnome>.
15, gtkSupport ? true, glib, gtk3
16, videoSupport ? true, ffmpeg_4, libmpeg2
17}:
18
19stdenv.mkDerivation rec {
20 pname = "libextractor";
21 version = "1.11";
22
23 src = fetchurl {
24 url = "mirror://gnu/libextractor/${pname}-${version}.tar.gz";
25 sha256 = "sha256-FvYzq4dGo4VHxKHaP0WRGSsIJa2DxDNvBXW4WEPYvY8=";
26 };
27
28 patches = [
29 (fetchpatch {
30 name = "libextractor-exiv2-0.28.patch";
31 url = "https://git.pld-linux.org/?p=packages/libextractor.git;a=blob_plain;f=libextractor-exiv2-0.28.patch;h=d763b65f2578f1127713de8dc82f432d34f95a85;hb=0e7de1c6794e8c331a1a1a6a829993c7cd217d3a";
32 hash = "sha256-szAv2A+NmiQyj2+R7BO6fHX588vlTgljPtrnMR6mgGY=";
33 })
34 ] ++ lib.optionals gstreamerSupport [
35
36 # Libraries cannot be wrapped so we need to hardcode the plug-in paths.
37 (substituteAll {
38 src = ./gst-hardcode-plugins.patch;
39 load_gst_plugins = lib.concatMapStrings
40 (plugin: ''gst_registry_scan_path(gst_registry_get(), "${lib.getLib plugin}/lib/gstreamer-1.0");'')
41 (gstPlugins gst_all_1);
42 })
43 ];
44
45 preConfigure =
46 '' echo "patching installation directory in \`extractor.c'..."
47 sed -i "src/main/extractor.c" \
48 -e "s|pexe[[:blank:]]*=.*$|pexe = strdup(\"$out/lib/\");|g"
49 '';
50
51 nativeBuildInputs = [ pkg-config ];
52
53 buildInputs =
54 [ libtool gettext zlib bzip2 flac libvorbis exiv2
55 libgsf rpm
56 ] ++ lib.optionals gstreamerSupport
57 ([ gst_all_1.gstreamer ] ++ gstPlugins gst_all_1)
58 ++ lib.optionals gtkSupport [ glib gtk3 ]
59 ++ lib.optionals videoSupport [ ffmpeg_4 libmpeg2 ];
60
61 configureFlags = [
62 "--disable-ltdl-install"
63 "--with-ltdl-include=${libtool}/include"
64 "--with-ltdl-lib=${libtool.lib}/lib"
65 "--enable-xpdf"
66 ];
67
68 # Checks need to be run after "make install", otherwise plug-ins are not in
69 # the search path, etc.
70 doCheck = false;
71 doInstallCheck = true;
72 installCheckPhase = "make check";
73
74 meta = with lib; {
75 description = "Simple library for keyword extraction";
76
77 longDescription =
78 '' GNU libextractor is a library used to extract meta-data from files
79 of arbitrary type. It is designed to use helper-libraries to perform
80 the actual extraction, and to be trivially extendable by linking
81 against external extractors for additional file types.
82
83 The goal is to provide developers of file-sharing networks or
84 WWW-indexing bots with a universal library to obtain simple keywords
85 to match against queries. libextractor contains a shell-command
86 extract that, similar to the well-known file command, can extract
87 meta-data from a file an print the results to stdout.
88
89 Currently, libextractor supports the following formats: HTML, PDF,
90 PS, OLE2 (DOC, XLS, PPT), OpenOffice (sxw), StarOffice (sdw), DVI,
91 MAN, FLAC, MP3 (ID3v1 and ID3v2), NSF(E) (NES music), SID (C64
92 music), OGG, WAV, EXIV2, JPEG, GIF, PNG, TIFF, DEB, RPM, TAR(.GZ),
93 ZIP, ELF, S3M (Scream Tracker 3), XM (eXtended Module), IT (Impulse
94 Tracker), FLV, REAL, RIFF (AVI), MPEG, QT and ASF. Also, various
95 additional MIME types are detected.
96 '';
97
98 license = licenses.gpl3Plus;
99
100 maintainers = [ maintainers.jorsn ];
101 platforms = platforms.linux;
102 };
103}