Can some specific autodetected dependency be ignored upon rpmbuild
Asked Answered
H

3

7

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
Healing answered 31/8, 2012 at 9:37 Comment(0)
B
3

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/ .

Brie answered 1/9, 2012 at 14:33 Comment(1)
Accepting answer without verification: I probably cannot verify it in the short termHealing
W
4

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$
Withers answered 6/3, 2015 at 16:4 Comment(1)
Finally... It looks like RHEL/CentOS 6 is still 4.8, but RHEL/CentOS 7 bumps to 4.11.Brie
B
3

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/ .

Brie answered 1/9, 2012 at 14:33 Comment(1)
Accepting answer without verification: I probably cannot verify it in the short termHealing
M
-1

Legacy rpm-4.8 and older (CentOS 6.x) have no filtering of autodetected dependencies. However, there's a workaround:

Gzip the library in question before rpmbuild, and gunzip it after installation. Dependency detection of rpmbuild will then ignore the file.

Example situation:

Your awesome-project-1.2.3-4.i686.rpm contains

  • libfoo.so which depends on libxx.so
  • libbar.so which depends on libyy.so
  • libbah.so which depends on libextra-3rdparty-stuff.so that isn't shipped via RPM

You want to have the libxx.so and libyy.so in your RPM's dependencies, but not the libextra-3rdparty-stuff.so.

Now do the trick the rpm spec-file, say awesome-project.spec:

%prep
gzip "$RPM_BUILD_ROOT/usr/lib/libbah.so"
exit

%post
gunzip -f "$RPM_INSTALL_PREFIX/usr/lib/libbah.so.gz
exit

%preun
gzip "$RPM_INSTALL_PREFIX/usr/lib/libbah.so" # so that `rpm -e` doesn't complain about missing file
exit

There you go. No more complaints on missing libextra-3rdparty-stuff.so when installing the RPM.

Mcglynn answered 23/10, 2020 at 22:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.