Product SiteDocumentation Site

Programming with the RPM Database

In addition to providing query routines for RPM files, you can also access the RPM database with the RPM2 package.
To access the RPM database, your Perl script must first open the database.

Opening the database

Open the RPM database with a call to open_rpm_db on the RPM2 object. For example:
my $rpm_db = RPM2->open_rpm_db();
You can also specify the directory where the RPM database resides. This is most useful for accessing a database in a non-standard location. For example:
my $rpm_db = RPM2->open_rpm_db( "-path" => "/var/lib/rpm" );
Note
The -path is normally used as a Perl bareword but is shown here as a string.
Once you have an RPM database object, you can call one of the find subroutines to find packages in most of the same ways as supported by the rpm –q command.