libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 130051c82986b6d304b6f883380f7285955d06b5
parent 49c61d3b5a9e4f6a1b4a3625ffbb0f6a8e88ee0c
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 12 Nov 2026 00:08:22 +0100

homebrew: add a formula so the Git repository can be tapped directly

It builds the development version on macOS with every plugin whose library
Homebrew provides.

Assisted by LLM

Diffstat:
MChangeLog | 6++++++
AHomebrewFormula/libextractor.rb | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MREADME | 26+++++++++++++++++++++++++-
3 files changed, 126 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +Thu Nov 12 12:08:21 AM CET 2026 + Add a Homebrew formula (HomebrewFormula/libextractor.rb), so that + the Git repository can be used as a Homebrew tap that builds the + development version on macOS with every plugin whose library + Homebrew provides; README explains how. -CG + Thu Nov 12 12:08:16 AM CET 2026 Give a plugin up to 120 seconds to load before treating it as blocked. A plugin whose libraries loaded slowly the first time diff --git a/HomebrewFormula/libextractor.rb b/HomebrewFormula/libextractor.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +# This file makes the libextractor Git repository a Homebrew tap; see +# README for how to install from it. +class Libextractor < Formula + desc "Library to extract meta data from files" + homepage "https://www.gnu.org/software/libextractor/" + license "GPL-3.0-or-later" + head "git://git.gnunet.org/libextractor.git", branch: "master" + + depends_on "autoconf" => :build + depends_on "automake" => :build + depends_on "pkgconf" => :build + depends_on "texinfo" => :build + + depends_on "exiv2" + depends_on "ffmpeg" + depends_on "flac" + depends_on "gdk-pixbuf" + depends_on "gettext" + depends_on "giflib" + depends_on "glib" + depends_on "gstreamer" + depends_on "jpeg-turbo" + depends_on "libarchive" + depends_on "libgsf" + depends_on "libmagic" + depends_on "libmpeg2" + depends_on "libogg" + depends_on "libtiff" + depends_on "libtool" + depends_on "libvorbis" + depends_on "poppler" + depends_on "rpm" + depends_on "tidy-html5" + + uses_from_macos "bzip2" + uses_from_macos "zlib" + + conflicts_with "csound", because: "both install `extract` binaries" + + deny_network_access! + + def install + system "./bootstrap" + system "./configure", "--disable-silent-rules", *std_configure_args + system "make", "install" + end + + test do + # extract runs each plugin in libextractor-helper, so these also + # check that the helper is found next to the plugins + { + "png" => ["test.png", "image dimensions - 8x8"], + "mime" => ["test.png", "mimetype - image/png"], + "jpeg" => ["test.jpg", "image dimensions - 1x1"], + "tiff" => ["test.tiff", "created by software - Pixelmator 3.2"], + "pdf" => ["test.pdf", "page count - 1"], + "archive" => ["test.jar", "embedded filename - META-INF/MANIFEST.MF"], + "thumbnailffmpeg" => ["test.mp4", "thumbnail - (binary"], + }.each do |plugin, (fixture, expected)| + assert_match expected, shell_output("#{bin}/extract -n -l #{plugin} #{test_fixtures(fixture)}") + end + + (testpath/"test.c").write <<~C + #include <stdio.h> + #include <extractor.h> + + static int + count (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, const char *data_mime_type, + const char *data, size_t data_len) + { + ++*(int *) cls; + return 0; + } + + int + main (int argc, char **argv) + { + struct EXTRACTOR_PluginList *plugins; + int items = 0; + + plugins = EXTRACTOR_plugin_add (NULL, "png", NULL, + EXTRACTOR_OPTION_DEFAULT_POLICY); + EXTRACTOR_extract (plugins, argv[1], NULL, 0, &count, &items); + EXTRACTOR_plugin_remove_all (plugins); + printf ("%d\\n", items); + return 0 == items; + } + C + system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lextractor", "-o", "test" + assert_operator shell_output("./test #{test_fixtures("test.png")}").to_i, :>, 0 + end +end diff --git a/README b/README @@ -72,7 +72,6 @@ available in order for maximum coverage: * libjpeg (v8 or later) * libmagic (file) * libmpeg2 -* libmp4v2 * librpm * libsmf * libtidy @@ -100,3 +99,28 @@ tools they need (mingw-w64, qemu-utils, lame, ffmpeg). Finally, 'zzuf' is a fuzzing tool that can optionally be detected by the build system and be used for debugging / testing. It is not required at runtime or for normal builds. + + +Installing on macOS with Homebrew +================================= + +The libextractor Git repository is also a Homebrew tap. Its formula +builds the current development version with every plugin whose +library Homebrew provides, which pulls in many other formulae (among +them FFmpeg, GStreamer and GTK): + + brew tap gnu/libextractor git://git.gnunet.org/libextractor.git + brew trust --tap gnu/libextractor + brew install --HEAD gnu/libextractor/libextractor + +Tapping clones the whole repository (about 100 MB). 'brew upgrade' +only updates a HEAD installation when asked to look for new commits: + + brew upgrade --fetch-HEAD gnu/libextractor/libextractor + +Homebrew's own 'libextractor' formula ('brew install libextractor') +installs the latest release instead, with only the plugins that need +no further libraries. Both install the same files, so uninstall one +before installing the other, with 'brew uninstall libextractor' (add +'--ignore-dependencies' if formulae such as gnunet depend on it). +Formulae that depend on libextractor accept either.