Product SiteDocumentation Site

Working with RPM Files

The RPM C library provides functions to read RPM files as well as query the RPM database. Going beyond querying, you can perform all the tasks that the rpm and rpmbuild commands do, since both these commands are written in C using the RPM library. That said, some tasks are much easier than other tasks. If you are writing a complex package installation program, or a program that keeps various systems up to date with regards to package versions, you may want to look at the Python RPM API instead of the C RPM library.
Cross Reference
Chapter 16, Programming RPM with Python covers the Python RPM API.

Opening RPM files

When working with an RPM file from within a program, the first thing you need to do is open the file. Use Fopen:
FD_t Fopen(const char * path,
const char * fmode);
Fopen works like the standard C function fopen(3).
The reason the RPM library wraps the input/output C library functions is to ensure portability to other operating systems. This is a fairly common technique.