Exploring RPM package contents

RPM Package Manager (RPM, yeah recursive acronym!) earlier known as the Redhat Package Manager is a free and open source package management system.

The point of this story isn’t the steps to create RPM or it’s history. It is about how to explore the contents of a RPM package. Now, why would one go on snooping around a package?

Simple, someone who is curious about what all binaries, libraries and config files are being offloaded into the root file system. This analysis could help someone in getting a better understanding about an application especially the dependencies.

Now, there are various ways of searching or querying for files within a package. If one where to explore the man page of the rpm, all the different options is available there.

Dumping all the contents of the RPM package.

Now, suppose say you want to just see what all does the RPM package contain then the easiest way to do that is to execute the command,

the values q, l and p pertain to l pertains to listing, q for query and p for package.

Using this command will just output all the contents of the rpm package, i.e. file and directories.

Querying for a specific file in a RPM packages

Suppose we are only concerned with a specific file, i.e. to which package it belongs to then, the command one should execute is,

the option whatprovides, acts as a keyword to search for the term following it in the query.

Finding the documents for a given package

Now, suppose you are new to a project and would like to explore the available documents before getting started with the work. Most of the mature packages come with a certain level of documentation, at the very least a man page. The command which one could use for finding all the related documentation for a particular package is,

the option d, is for documentation.

Now, sometimes we might not be aware of the package which actually contains a certain script or binary we are using, so in that case, one could modify the above command into

where, f when used in query would look for the particular file we have mentioned as the file name in the available packages in the system and accordingly in whatever package it finds that file, we’ll get a listing for the documents.

Just like documentation, one can also query for configuration files by using the -c flag in the query.

What the package provides or requires?

Suppose you just have a package ( maybe your friend has a query and he just dropped a random package name ), now how do you quickly find what it actually provides, i.e. what features. Similarly what if you have an RPM package but no documentation to tell you what all dependencies should already be present for this to be successfully installed ?

For the first case, we have the command

This will give back a list of capabilities which are part of this package. Moving on to the second part, the command one should go for is

This will return a list of capabilities required for our package. Now, again if one isn’t aware of the package name, the person can use the -f flag to query by a file name.

Just getting a data dump

Sometimes one would be requiring an increased level of information for each of the files included in the package, that is where one needs to use the dump option.

This will output the file size, minor and major number, symlink flag, checksum, usergroup, file owner, etc.

Though there’s still a lot which can be done using the rpm query, the above mentioned are the basic commands which would help you get started with the explorations. For further analysis of the files, one could pipe the output of the rpm query to use grep and do a regex matching.

To the souls who want to learn more about the RPM, they should look into the Maximum RPM page.