RPM::Search - Search all available RPMs
# On (recent) RPM based systems my $db = RPM::Search->new(); my @names = $db->search(qr/perl-Mo.se/); # or @names = $db->search('perl-CGI-*'); # or @names = $db->search('cpanminus'); if ( @names ) { my $pkgs = join ", ", @names; `/usr/bin/yum -y install $pkgs`; } else { print "No matching packages\n"; }
This module allows one to search the entire collection of RPMs available for a given installed Linux distribution that uses RPMs, not just listing the RPMs already installed on a system.
And frankly, have you tried using yum search?
yum search
Eventually, I plan to use this functionality to make a plugin for cpanminus to suggest vendor-supplied packages instead of building them "from scratch."
cpanminus
These are standard Perlish accessors: pass an argument to set it, pass no argument to get the current value.
Base location of the yum data (default: none)
Fully qualified path to the primary SQLite database (default: none)
DBI handle to the yum SQLite database
Make a new RPM::Search object. Will automatically search for an appropriate yum database and open a handle to the data set unless you pass valid arguments to the dbh and/or yum_primary_db attributes at construction time.
Returns a new RPM::Search object.
This method searches for an appropriate yum database starting at the location passed as a parameter. If no parameter is given, the method will use cache_base. If cache_base is not set, the method will use /var/cache/yum.
This call populates yum_primary_db.
The return value is boolean: true for success, false for failure.
This method opens a connection to the yum SQLite database. The DSN is constructed from the passed in parameter. If no parameter is passed in, the method will use yum_primary_db.
This method populates dbh.
This method causes a fatal error on any failure.
This method searches the RPM database using an optional pattern parameter. If no pattern is given, the method returns all available package names. (Note: This will be thousands of packages.)
The format of the pattern can be one of the following:
A regular expression using the qr// construct.
qr//
A SQL-ish wildcard expression using % and _
A filesystem like glob expression using ? and *
A scalar which must be a literal match for a package name in the database to return any results
The method returns an array of all matching package names (which may be zero results.) Undef is returned on errors.
Mark Allen, mrallen1 at yahoo dot com
mrallen1 at yahoo dot com
Please report any bugs or feature requests to bug-rpm-search at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RPM-Search.
bug-rpm-search at rt.cpan.org
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc RPM::Search
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=RPM-Search
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/RPM-Search
CPAN Ratings
http://cpanratings.perl.org/d/RPM-Search
MetaCPAN
https://metacpan.org/module/RPM::Search/
Github
https://github.com/mrallen1/RPM-Search.git
Copyright 2011 Mark Allen.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install RPM::Search, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPM::Search
CPAN shell
perl -MCPAN -e shell install RPM::Search
For more information on module installation, please visit the detailed CPAN module installation guide.