RPM::Database(3)

NAME
RPM::Database - Access to the RPM database of installed packages

SYNOPSIS
    use RPM::Database;
    tie %RPM, "RPM::Database" or die "$RPM::err";
    for (sort keys %RPM)
    {
        ...
    }

DESCRIPTION
The RPM::Database package provides access to the database of installed packages on a system. The database may be accessed as either a tied hash or as a blessed reference to a hash. The keys of the hash represent packages on the system. The order in which they are returned by any of `keys', `each' or `values', is determined by the internal database ordering. Unlike the keys in RPM::Header (see the RPM::Header manpage), the keys here are in fact case-sensitive.

The return value corresponding to each key is a reference to a RPM::Header object. The header object is marked read-only, as the RPM database is not directly modifiable via this interface.

There are also a number of class methods implemented, which are described in the next section.

USAGE

  Creating an Object
An object may be created one of two ways:

    tie %D, "RPM::Database";
    $dataref = new RPM::Database;
The latter approach offers more direct access to the class methods, while also permitting the usual tied-hash operations such as fetching:

    $dataref->{package}    # Such as "rpm" or "perl"

  Class Methods
The following methods are available to objects of this class, in addition to the tied-hash suite of operations. If the object is a hash instead of a hash reference, it can be used to call these methods via:

    (tied %hash)->method_name(...)

init
    This causes a complete initialization of the RPM database. It must be run with sufficient permissions to create/update the relevant files. It must also be called as a static method, to avoid having any file descriptors open on the database at the time.

rebuild
    This rebuilds the database (same as "rpm --rebuilddb"). As with init above, this requires adequate permissions and must be invoked as a static method.

find_by_file(file)
    Returns a list of RPM::Header objects that correspond to the package(s) claiming ownership of the file "file".

find_by_group(group)
    Returns of a list of headers for all packages flagged as being in the group specified.

find_what_provides(provides)
    Search as above, but based on which package(s) provide the functionality specified as "provides".

find_what_requires(requires)
    Return a list of headers for the packages that directly depend on the specified package for installation and operation. The specified package should be just the name, no version or release information.

find_what_conflicts(conflicts)
    List those packages that have conflicts based on the value of "conflicts".

find_by_package(package)
    This performs the search by a specific package name. This is the API call used by the FETCH tied-hash method, but this differs in that if there is in fact more than one matching record, all are returned.

Any of the `find_*' routines can take an RPM::Header object as an argument, in which case the package name will be retrieved and used for the argument. In some cases (such as `find_by_file'), this is probably not what you want. But in other cases such as `find_what_requires', it may be exactly what you want.

  Importable Defaults
Given that there may be only one concurrent process with the rpm database open, and given that such would lead to a lot of program code starting with the same sequence of use/tie or use/new, the following identifiers may be imported from the package:

%RPM
    A hash pre-tied to the RPM::Database package (and thus the rpm database).

$RPM
    A RPM::Database object, referencing a hash tied to the rpm database.

DIAGNOSTICS
Direct binding to the internal error-management of rpm is still under development. At present, most operations generate their diagnostics to STDERR.

CAVEATS
This is currently regarded as alpha-quality software. The interface is subject to change in future releases.

SEE ALSO
the RPM manpage, the RPM::Header manpage, the perl manpage, the rpm manpage

AUTHOR
Randy J. Ray <rjray@blackperl.com>