Red Hat Bugzilla – Bug 3278
--provides and --whatprovides not adequate
Last modified: 2008-05-01 11:37:50 EDT
Very, very, very classic problem. An rpm can't be installed
because it needs file xyz to be present on the system.
Intuitively, "rpm -qp --whatprovides xyz *" should be able
to find this file, but it can't. Yes, rpmfind does exist,
but I don't want to know the Caldera rpm from 2 years ago
that contains the file I need on my Red Hat system. I would
like to suggest the addition of a --whatcontains switch to
rpm. This should be almost trivial to implement. It would
be very nice for the simple user to issue something similar
to the following command:
rpm -qp --whatcontains filexyz /mnt/cdrom/RedHat/RPMS/*
and get the name of the local package file that needs to be
installed. This has many advantages to rpmfind, in that the
user would not require a network connection or a locally
built rpmfind database.
rpm-3.0.4 does the Right Thing when invoked as
rpm --whatprovides /path/to/file
(There's still the "database doesn't know about what's not installed" problem,
but that's a different issue).
I wrote a bash script to do this a while back. I'm not at home at the moment, so
this isn't the original script, but it was similar. I'll post the original
script on Saturday (next time I'll have the chance):
if [ $# -eq 0 ]; then
echo "Usage: `basename $0` file..." >&2
for RPM in *.rpm ; do
for WORD do
if rpm -qlp $RPM 2> /dev/null | fgrep "$WORD" > /dev/null ; then
printf '%38s => %s\n' "$RPM" "$WORD"
Note that the above script will return ALL matches to EACH of the search strings
provided that occur in any of the filenames listed therein.
That'll work :-)
Meanwhile, the original issue (AFAICT) was that --whatprovides looked only
at provides and not at files. In rpm-3.0.4, depending on whether the arg
begins with '/', rpm will look at either provides or file lists, thus
suimplifying the user interface.
If you wish to add the above script to the RPM package, go ahead. I checked it
against my script at home, and there was no functional difference (the only
actual difference was the use of FILE instead of WORD and that is definately