Optional requirements for RPM
(Wow, it's been over a year since my last blog post…)
At work, I have a program that optionally could use the Qt libraries, but I didn't want my RPM to actually require libqt-mt.so
like it wanted to. And RPM doesn't seem to support an "OptRequires
" or something similar… so here's my hack of a solution.
I put this script named find-requires
into my project's "build
" subdirectory so it is included in the "Source
" tarball that rpmbuild
will be using. I wrote it to be expandable.
#!/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;
Then put in your .spec
file this, which will call our script with the original script as the first parameter:
# 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}
Comments
No comments.