Few days back I had put a query.
How to find which rpm provides a file. Many times while installing a rpm,
many dependencies are reported. It is very difficult to locate which rpm
provides these file.
Here is my 10 liner perl solution

------cut here---------
#!/usr/bin/perl -w
$rpmdir=$ARGV[1];
$rpmdir="/mnt/cdrom/RedHat/RPMS" if !$rpmdir;
$findfile=$ARGV[0];
die "$0 usage: filename [rpm directory] \n" if !$findfile;
@filelist=`ls $rpmdir`;
SEARCH:
foreach $filename(@filelist){
next SEARCH if !($filename=~/.rpm/);
chomp($filename);
print "$findfile -> $filename \n" if (`rpm -qlp
$rpmdir/$filename`=~/$findfile/);
}
exit 1;
----------cut here--------
save the file as rpmsearch.


For default rpm directory /mnt/cdrom/RedHat/RPMS
./rpmsearch filename_to_search

For any directory

./rpmsearch filename_to_search /your/rpm/directory.

I know bash could do this in fewer line but ....
Regards,
Mukund Deshmukh
Beta Computronics Pvt. Ltd.
Web Site - www.betacomp.com



----------------------------------------------
Find out more about this and other Linux India 
mailing lists at http://lists.linux-india.org/

Reply via email to