I have an rpm and I want to treat it like a tarball. I want to extract the contents into a directory so I can inspect the contents. I am familiar with the querying commands of an uninstalled package. I do not simply want a list of the contents of the rpm. i.e.
$ rpm -qpl foo.rpm
I want to inspect the contents of several files contained in the rpm. I do not want to install the rpm. I am also aware of the rpms ability to do additional modifictions in the %post sections, and how to check for those. i.e.
$ rpm -qp --scripts foo.rpm
However in this case that is of no concern to me.
Sometimes you can encounter an issue with intermediate RPM archive:
That means it could be packed, these days it is LZMA2 compression as usual, by
xz
:otherwise you could try:
Most distributions have installed the GUI app file-roller which unpacks tar, zip, rpm and many more.
This will extract the contents in the current directory.
7-zip understands most kinds of archives, including rpm and the included cpio.
The "DECOMPRESSION" test fails on CygWin, one of the most potentiaally useful platforms for it, due to the "grep" check for "xz" being case sensitive. The result of the "COMPRESSION:" check is:
Simply replacing 'grep -q' with 'grep -q -i' everywhere seems to resolve the issue well.
I've done a few updates, particularly adding some comments and using "case" instead of stacked "if" statements, and included that fix below
For those who do not have rpm2cpio, here is the ancient rpm2cpio.sh script that extracts the payload from a *.rpm package.
Reposted for posterity … and the next generation.
Invoke like this: ./rpm2cpio.sh .rpm | cpio -dimv
Did you try the
rpm2cpio
commmand? See the example below: