Product SiteDocumentation Site

17.5. Summary

This chapter introduces the RPM2 add-on module to allow Perl scripts to access information on RPM package files and in the RPM database. To access an RPM file and query information about that file, you need to call the open_package subroutine. Once you’ve opened the file, you can call the tag, as_nvre, is_source_package, and files subroutines on the header object to query data about the package.
To access the RPM database, call open_rpm_db. Once you’ve opened the database, you can call one of the find subroutines, such as find_by_name or find_by_name_iter, to search for packages. The subroutines that have names ending with _iter, such as find_by_name_iter, return an iterator object to iterate over the packages found. The other find subroutines, such as find_by_name, return a Perl list of the packages found.
You can then call the tag, as_nvre, and files subroutines on the package objects to query information about the packages.
When you are done with the RPM database, call close_rpm_db.