60

I am on a MacBook Pro running Apple Leopard (Mac OS X 10.5.8).

I would like to unpackage a RPM and view the files contained within the wget-1.11.4-2.el5_4.1.src.rpm . I don't need to install the files to a particular location or run any %postinstall scripts or anything. I just want to unpackage this RPM so that I can view the source files underneath.

Is it possible to unpackage a RPM file on a non-RedHat/CentOS system?

Stefan Lasiewski
  • 19,264
  • 24
  • 70
  • 85

7 Answers7

57

On modern systems, the built-in tar utility supports several other archive formats including rpm. So you can extract the files from the rpm with

tar -xf foo.rpm

Note that if you've installed GNU tools, tar may invoke GNU tar instead of the one that ships with macOS, depending on which set of GNU tools and on your $PATH. You need to use /usr/bin/tar, not GNU tar.

You can install rpm through Darwin Ports or Fink or Mac Ports or even a Darwin port, rpm4darwin.

To extract files from an rpm package without installing it, you can use the companion utility rpm2cpio, e.g.

rpm2cpio foo.rpm | cpio -i -d 

There's also a portable rpm2cpio script if you don't want or can't get the version that's bundled with the rpm utility (the script may not work with older or newer versions of the rpm format though).

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
29

From the command line you can use the tar command. For example tar -tf example.rpm | less to list all of the files in the rpm.

Dave Gray
  • 103
  • 3
Jon Ashdown
  • 391
  • 3
  • 4
10

To unpack all the files to the local directory:

tar -xvzf some.rpm

without the need to install any new tools

8

Homebrew also has a recipe for rpm installation, just run

brew install rpm
Andrew
  • 181
  • 1
  • 3
4

I would think that (like Windows and Linux) any archiver program should be able to decompress it. iArchiver, the unArchiver, and Archiver all list "read-only RPM" in their supported formats.

mlschechter
  • 496
  • 3
  • 10
2

The portable rpm2cpio script is really good!

Robin Liu
  • 21
  • 2
2

Yes you can, Midnight Commander opens RPM files. I don't use it but google list some links that might point at a GUI.

Eliran Malka
  • 259
  • 2
  • 10
Maciej Piechotka
  • 16,578
  • 11
  • 57
  • 93