rpmbuild can autodetect dependencies by looking up shared libraries required by binaries included in the package and, while this is a good think almost every time, there are time when it is undesirable but only for some specific libraries. I am referring to the case where some binary file requires libraries that are not provided to the system via its rpm package management but installed directly by third party installers.
Now, the question is: is there a way to keep the autodetect feature active (comes in handy for the other binaries in the package) but ignore/remove only these specific libraries?
Something like
AutoReqIgnore : library1
AutoReqIgnore : library2
I have not found a built-in way, but I wrote a small script that I used as a filter:
#!/usr/bin/perl -w
use strict;
use IPC::Open2;
# This quick script will run the native find-requires (first parameter)
# and then strip out packages we don't want listed.
open2(\*IN, \*OUT, @ARGV);
print OUT while (<STDIN>);
close(OUT);
my $list = join('', <IN>);
# Apply my filter(s):
$list =~ s/^libqt-mt.so.*?$//mg;
print $list;
You can put your own regular expression lines, in this example I removed libqt-mt.so.*
Then, in the .spec
file:
# Note: 'global' evaluates NOW, 'define' allows recursion later...
%global _use_internal_dependency_generator 0
%global __find_requires_orig %{__find_requires}
%define __find_requires %{_builddir}/%{?buildsubdir}/build/find-requires %{__find_requires_orig}
As you can see, this script is in the source tarball under /build/
.
As of rpm-4.9 (Fedora 15), rpm has a standard method to enable filtering of the autogenerated dependencies.
For example, you can write
%global __requires_exclude ^libthirdpartyplugin.so$