nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ fetchurl, stdenv, substituteAll
2, libtool, gettext, zlib, bzip2, flac, libvorbis
3, exiv2, libgsf, rpm, pkgconfig, fetchpatch
4, gstreamerSupport ? true, gst_all_1 ? null
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 ? null, gtk3 ? null
16, videoSupport ? true, ffmpeg_3 ? null, libmpeg2 ? null}:
17
18assert gstreamerSupport -> gst_all_1 != null && builtins.isList (gstPlugins gst_all_1);
19assert gtkSupport -> glib != null && gtk3 != null;
20assert videoSupport -> ffmpeg_3 != null && libmpeg2 != null;
21
22stdenv.mkDerivation rec {
23 name = "libextractor-1.9";
24
25 src = fetchurl {
26 url = "mirror://gnu/libextractor/${name}.tar.gz";
27 sha256 = "1zz2zvikvfibxnk1va3kgzs7djsmiqy7bmk8y01vbsf54ryjb3zh";
28 };
29
30 patches = [
31 ./fix-gcc8-build.patch
32 # Fixes build with exiv2 0.27
33 (fetchpatch {
34 name = "libextractor-exiv2-0.27.patch";
35 url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/libextractor-exiv2-0.27.patch?h=packages/libextractor&id=4dc53f7fc69210ae571285dface108ed65d8ee53";
36 sha256 = "0w4gc1q1m1yxsd4hv105nblmif465nw3g5nxzldy0x2rl9mdncg6";
37 })
38 (fetchpatch {
39 name = "CVE-2019-15531.patch";
40 url = "https://git.gnunet.org/libextractor.git/patch/?id=d2b032452241708bee68d02aa02092cfbfba951a";
41 sha256 = "01xhcjbzv6p53wz7y2ii76kb8m9iwvnm4ip9w4a0bpgaxqz4b9fw";
42 excludes = [ "ChangeLog" ];
43 })
44 ] ++ stdenv.lib.optionals gstreamerSupport [
45
46 # Libraries cannot be wrapped so we need to hardcode the plug-in paths.
47 (substituteAll {
48 src = ./gst-hardcode-plugins.patch;
49 load_gst_plugins = stdenv.lib.concatMapStrings
50 (plugin: ''gst_registry_scan_path(gst_registry_get(), "${plugin}/lib/gstreamer-1.0");'')
51 (gstPlugins gst_all_1);
52 })
53 ];
54
55 preConfigure =
56 '' echo "patching installation directory in \`extractor.c'..."
57 sed -i "src/main/extractor.c" \
58 -e "s|pexe[[:blank:]]*=.*$|pexe = strdup(\"$out/lib/\");|g"
59 '';
60
61 buildInputs =
62 [ libtool gettext zlib bzip2 flac libvorbis exiv2
63 libgsf rpm
64 pkgconfig
65 ] ++ stdenv.lib.optionals gstreamerSupport
66 ([ gst_all_1.gstreamer ] ++ gstPlugins gst_all_1)
67 ++ stdenv.lib.optionals gtkSupport [ glib gtk3 ]
68 ++ stdenv.lib.optionals videoSupport [ ffmpeg_3 libmpeg2 ];
69
70 configureFlags = [
71 "--disable-ltdl-install"
72 "--with-ltdl-include=${libtool}/include"
73 "--with-ltdl-lib=${libtool.lib}/lib"
74 "--enable-xpdf"
75 ];
76
77 # Checks need to be run after "make install", otherwise plug-ins are not in
78 # the search path, etc.
79 # FIXME: Tests currently fail and the test framework appears to be deeply
80 # broken anyway.
81 doCheck = false;
82 #postInstall = "make check";
83
84 meta = {
85 description = "Simple library for keyword extraction";
86
87 longDescription =
88 '' GNU libextractor is a library used to extract meta-data from files
89 of arbitrary type. It is designed to use helper-libraries to perform
90 the actual extraction, and to be trivially extendable by linking
91 against external extractors for additional file types.
92
93 The goal is to provide developers of file-sharing networks or
94 WWW-indexing bots with a universal library to obtain simple keywords
95 to match against queries. libextractor contains a shell-command
96 extract that, similar to the well-known file command, can extract
97 meta-data from a file an print the results to stdout.
98
99 Currently, libextractor supports the following formats: HTML, PDF,
100 PS, OLE2 (DOC, XLS, PPT), OpenOffice (sxw), StarOffice (sdw), DVI,
101 MAN, FLAC, MP3 (ID3v1 and ID3v2), NSF(E) (NES music), SID (C64
102 music), OGG, WAV, EXIV2, JPEG, GIF, PNG, TIFF, DEB, RPM, TAR(.GZ),
103 ZIP, ELF, S3M (Scream Tracker 3), XM (eXtended Module), IT (Impulse
104 Tracker), FLV, REAL, RIFF (AVI), MPEG, QT and ASF. Also, various
105 additional MIME types are detected.
106 '';
107
108 license = stdenv.lib.licenses.gpl2Plus;
109
110 maintainers = [ ];
111 platforms = stdenv.lib.platforms.linux;
112 };
113}