libextractor.rb (3040B)
1 # frozen_string_literal: true 2 3 # This file makes the libextractor Git repository a Homebrew tap; see 4 # README for how to install from it. 5 class Libextractor < Formula 6 desc "Library to extract meta data from files" 7 homepage "https://www.gnu.org/software/libextractor/" 8 license "GPL-3.0-or-later" 9 head "git://git.gnunet.org/libextractor.git", branch: "master" 10 11 depends_on "autoconf" => :build 12 depends_on "automake" => :build 13 depends_on "pkgconf" => :build 14 depends_on "texinfo" => :build 15 16 depends_on "exiv2" 17 depends_on "ffmpeg" 18 depends_on "flac" 19 depends_on "gdk-pixbuf" 20 depends_on "gettext" 21 depends_on "giflib" 22 depends_on "glib" 23 depends_on "gstreamer" 24 depends_on "jpeg-turbo" 25 depends_on "libarchive" 26 depends_on "libgsf" 27 depends_on "libmagic" 28 depends_on "libmpeg2" 29 depends_on "libogg" 30 depends_on "libtiff" 31 depends_on "libtool" 32 depends_on "libvorbis" 33 depends_on "poppler" 34 depends_on "rpm" 35 depends_on "tidy-html5" 36 37 uses_from_macos "bzip2" 38 uses_from_macos "zlib" 39 40 conflicts_with "csound", because: "both install `extract` binaries" 41 42 deny_network_access! 43 44 def install 45 system "./bootstrap" 46 system "./configure", "--disable-silent-rules", *std_configure_args 47 system "make", "install" 48 end 49 50 test do 51 # extract runs each plugin in libextractor-helper, so these also 52 # check that the helper is found next to the plugins 53 { 54 "png" => ["test.png", "image dimensions - 8x8"], 55 "mime" => ["test.png", "mimetype - image/png"], 56 "jpeg" => ["test.jpg", "image dimensions - 1x1"], 57 "tiff" => ["test.tiff", "created by software - Pixelmator 3.2"], 58 "pdf" => ["test.pdf", "page count - 1"], 59 "archive" => ["test.jar", "embedded filename - META-INF/MANIFEST.MF"], 60 "thumbnailffmpeg" => ["test.mp4", "thumbnail - (binary"], 61 }.each do |plugin, (fixture, expected)| 62 assert_match expected, shell_output("#{bin}/extract -n -l #{plugin} #{test_fixtures(fixture)}") 63 end 64 65 (testpath/"test.c").write <<~C 66 #include <stdio.h> 67 #include <extractor.h> 68 69 static int 70 count (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, 71 enum EXTRACTOR_MetaFormat format, const char *data_mime_type, 72 const char *data, size_t data_len) 73 { 74 ++*(int *) cls; 75 return 0; 76 } 77 78 int 79 main (int argc, char **argv) 80 { 81 struct EXTRACTOR_PluginList *plugins; 82 int items = 0; 83 84 plugins = EXTRACTOR_plugin_add (NULL, "png", NULL, 85 EXTRACTOR_OPTION_DEFAULT_POLICY); 86 EXTRACTOR_extract (plugins, argv[1], NULL, 0, &count, &items); 87 EXTRACTOR_plugin_remove_all (plugins); 88 printf ("%d\\n", items); 89 return 0 == items; 90 } 91 C 92 system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lextractor", "-o", "test" 93 assert_operator shell_output("./test #{test_fixtures("test.png")}").to_i, :>, 0 94 end 95 end