April 11, 2008

Display the Contents of an RPM or Tar Archive

An RPM is just an archive of files. I believe that all of the various archiving programs (tar, cpio, etc.) provide you with a way to list the contents of their archives. An RPM is no different. You need to figure out if foo.rpm provides libfoo.so. Making use of the rpm2cpio, cpio, and grep programs, we can do just this:

unix% rpm2cpio foo.rpm | cpio -t | grep "libfoo.so"
/usr/lib/libfoo.so.2
unix%

Conversely, you can display the contents of a tar archive in one step:
unix% tar -tvf foo.tar
foo/
foo/bar.txt
foo/bills
foo/private/
foo/private/tax-return.pdf
unix%

Neither of these steps will actually extract files from the archive.

Being a diehard Debian user, it feels weird to write my first post about an RPM tip. By day, I admin a large number of Suse servers for a financial company. For me, there is no escaping the dreaded RPM.

Unix questions are always welcome.
Send questions to unix@tributetogrr.blogspot.com

No comments: