[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;

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*