[TIP] View or Extract RPM Packages Content

Case:
You have an RPM package file, for example file.rpm. You want to view what files it contains, and then extract them just as if it was a .tar.gz archive. By the way, it’s a pity Konqueror doesn’t provide a reasonable context menu when you rightclick on it, but only offers to compress (like any regular file) or open it with Software Installer. (I’m talking about KDE, don’t know about Gnome Nautilus). Moreover, if you choose to open it with ark, it doesn’t recognise the format. Of course, the easiest way would be to launch Midnight Commander, “enter” this file as if it was a regular folder and copy whatever you need, but we are looking for a non-interactive and more straightforward method here.

Incantation:

rpm2cpio file.rpm | cpio -t
rpm2cpio file.rpm | cpio -i

Notes:
*) rpm2cpio converts the .rpm file specified as a single argument to a cpio archive on standard out;
*) The -t switch of cpio prints a table of contents of the input, and the -i does the extraction;
*) I tested this on Fedora;
*) The command rpm2cpio is a part of the rpm package on Fedora. You should see how to obtain it for your distro;
*) The command cpio is a separate package on Fedora. You should see how to obtain it for your distro;

Advertisements
This entry was posted in console and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s