How to extract rpm package on macOS

Extract RPM package on macOS to access its contents, which is especially useful for some old source packages.

Download installation script for the missing package manager for macOS.

$ curl --silent --fail --location  https://raw.githubusercontent.com/Homebrew/install/master/install -o brew-install 

Execute and complete installation process.

$ ruby brew-install

Install rpm2cpio utility.

$ brew install rpm2cpio
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (caskroom/cask, homebrew/core).
==> New Formulae
go-jira                                                   htslib                                                    jabba                                                     keystone
==> Updated Formulae
awscli ✔             aces_container       bmake                docfx                frugal               ibex                 libphonenumber       mdds                 node-build           sbcl                 xctool
faac ✔               angular-cli          clojure              doctl                geckodriver          icoutils             libpqxx              media-info           nomad                smali                xrootd
imagemagick ✔        apache-geode         cockroach            dub                  geoipupdate          [email protected]        libtensorflow        mercurial            opencv               sqlmap               xtensor
openssl ✔            apr-util             codemod              erlang               gjs                  iperf3               libvirt              mg                   osm2pgrouting        statik               yarn
[email protected] ✔        armadillo            conan                expat                gnu-units            ironcli              libxml2              micropython          pdfpc                svgo
pandoc ✔             at-spi2-atk          conjure-up           file-roller          gomplate             jena                 lwtools              minimal-racket       pipenv               tfenv
pyqt ✔               at-spi2-core         consul-template      firebase-cli         gradle               jfrog-cli-go         mailutils            mkdocs               poco                 tippecanoe
sip ✔                atlassian-cli        crowdin              flow                 gucharmap            knot                 mairix               mkvalidator          prest                vagrant-completion
terminal-notifier ✔  bacula-fd            dbus                 fluent-bit           gutenberg            kompose              mariadb              mongoose             re2                  vault-cli
vim ✔                bash-preexec         dcos-cli             fonttools            highlight            libass               [email protected]         mvnvm                redex                vte3
abcmidi              bibtexconv           dmd                  freetds              hyperscan            libhttpseverywhere   maxima               node                 resty                wireguard-tools

==> Installing dependencies for rpm2cpio: xz
==> Installing rpm2cpio dependency: xz
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.3.sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/25/2518e5105c2b290755cda0fd5cd7f71eea4cd4741b70c48250eed1750c3a6814
######################################################################## 100.0%
==> Pouring xz-5.2.3.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/xz/5.2.3: 92 files, 1.4MB
==> Installing rpm2cpio
==> Downloading https://homebrew.bintray.com/bottles/rpm2cpio-1.3.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring rpm2cpio-1.3.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/rpm2cpio/1.3: 2 files, 3.7K

Extract RPM package.

$ rpm2cpio.pl freeswitch-1.6.17-7.mga6.src.rpm | cpio -idmv
check_fs.cfg
check_fs_registered
communicator_semi_6000_20080321.tar.gz
freeswitch-1.2.12-dkms-skypopen.patch
freeswitch-1.2.12-mod_skypopen.patch
freeswitch-1.2.13-mod_shout-ltinfo.patch
freeswitch-1.2.13-python.patch
freeswitch-1.2.13-tinfo.patch
freeswitch-1.2.13-writestring.patch
freeswitch-1.2.3-ac_config.diff
freeswitch-1.2.3-fix-str-fmt.patch
freeswitch-1.2.3-link.patch
freeswitch-1.2.3-mod_ha_cluster.patch
freeswitch-1.4.14-mod_nibblebill-legb-hangup.diff
freeswitch-1.4.15-openssl-1.0.2.patch
freeswitch-1.4.4-gcc491-configure-lame.patch
freeswitch-1.4.7-no-pedantic-perl.patch
freeswitch-1.4.7-pgsql-build.diff
freeswitch-1.6.17-armv7hl-abi.patch
freeswitch-1.6.17.tar.xz
freeswitch-1.6.8-mga-stop-downloading-sounds.patch
freeswitch-contrib-master.tar.bz2
freeswitch-mod_ha_cluster-gcc48.patch
freeswitch-tmpfiles.conf
freeswitch.service
freeswitch.spec
perl-gcc-pedantic-define-working.diff
pocketsphinx-0.8.tar.gz
sphinxbase-0.8.tar.gz
186947 blocks

Done.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.