NAME

RPM::Search - Search all available RPMs

SYNOPSIS

# 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";
}

PURPOSE

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?

Eventually, I plan to use this functionality to make a plugin for cpanminus to suggest vendor-supplied packages instead of building them "from scratch."

ATTRIBUTES

These are standard Perlish accessors: pass an argument to set it, pass no argument to get the current value.

cache_base

Base location of the yum data (default: none)

yum_primary_db

Fully qualified path to the primary SQLite database (default: none)

dbh

DBI handle to the yum SQLite database

METHODS

new()

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.

find_yum_db()

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.

open_db()

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.

search()

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.

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

AUTHOR

Mark Allen, mrallen1 at yahoo dot com

BUGS

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.

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc RPM::Search

You can also look for information at:

LICENSE AND COPYRIGHT

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.