Saturday 23 July 2016

Extracting files from RPMs

So why would you ever need to extract files from rpms. The rpm is a single neat program that we can install with rpm -ivh <rpm_name>. Why would we want to break it down?
Well, there can be a number of reasons ranging from a messed up configuration file to removal of the installed binary.

So in this example we'll breakdown the httpd rpm into its constituent files.

Before breaking down an rpm let first under stand what its made of?
Initially we take the directory structure that make up the package & put them in a .cpio file. Then we add a description & some dependency information & the file.cpio,description & dependency information bundled together make up the file.rpm.

To start off we'll use the yumdownloader program to download the rpm from the yum repository:


Now yumdownloader downloads the package only & not associated dependencies.
If you wish to download the dependencies as well use the command repotrack <package name>.

Once we have that we'll use the rpm2cpio command to strip the description & dependency information & get the rpm down to the cpio file.
We then run the cpio command with the cpio archive file being being redirected as input & this will extract the entire file structure in the current working directory.


Another cool thing about the whole process is that although we strip down the rpm to its directory structure the rpm2cpio command still preserves the original rpm file that we downloaded with yumdownloader.

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...