How to open and extract RPM file on MacOS

Published Tuesday, Oct 29, 2019 by Tony Davis

Background

Are you trying to extract the contents of an RPM file on your Mac? I found myself in a similar situation, wanting to view the standard contents of a configuration file stored inside an RPM. Here’s a guide on how to open and extract an RPM file on MacOS.

Procedure

First, download and install Homebrew on MacOSX.

MacBook:~ user$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

After successfully installing Homebrew, it’s time to install the rpm2cpio utility. This tool will be crucial to our task of extracting the RPM on MacOS.

MacBook:~ user$ brew install rpm2cpio
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
==> Fetching rpm2cpio
==> Downloading https://ghcr.io/v2/homebrew/core/rpm2cpio/manifests/1.4-1
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/rpm2cpio/blobs/sha256:a0d766ccb
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################### 100.0%
==> Pouring rpm2cpio--1.4.arm64_ventura.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/rpm2cpio/1.4: 3 files, 3.2KB
==> Running `brew cleanup rpm2cpio`...

With the rpm2cpio utility installed, you can now extract the RPM package in your MacOS. Run the following command to extract the contents of the RPM file.

MacBook:~ user$ rpm2cpio chrony-4.3-1.el9.x86_64.rpm | cpio -idmv
./etc/chrony.conf
./etc/chrony.keys
./etc/dhcp/dhclient.d/chrony.sh
./etc/logrotate.d/chrony
./etc/sysconfig/chronyd
./usr/bin/chronyc
./usr/lib/.build-id
./usr/lib/.build-id/27
./usr/lib/.build-id/27/22526e8b01c2e304dae76c95b96d08368d541b
./usr/lib/.build-id/bc
./usr/lib/.build-id/bc/b4a77a141da491a2df6664d74de0193e276d7c
./usr/lib/NetworkManager
./usr/lib/NetworkManager/dispatcher.d
./usr/lib/NetworkManager/dispatcher.d/20-chrony-dhcp
./usr/lib/NetworkManager/dispatcher.d/20-chrony-onoffline
./usr/lib/systemd/ntp-units.d/50-chronyd.list
./usr/lib/systemd/system/chrony-wait.service
./usr/lib/systemd/system/chronyd.service
./usr/lib/sysusers.d/chrony.conf
./usr/sbin/chronyd
./usr/share/doc/chrony
./usr/share/doc/chrony/FAQ
./usr/share/doc/chrony/NEWS
./usr/share/doc/chrony/README
./usr/share/licenses/chrony
./usr/share/licenses/chrony/COPYING
./usr/share/man/man1/chronyc.1.gz
./usr/share/man/man5/chrony.conf.5.gz
./usr/share/man/man8/chronyd.8.gz
./var/lib/chrony
./var/log/chrony
1253 blocks

And there you have it, a simple and effective method to open and extract an RPM file on MacOS. Now you can navigate and explore the contents of your RPM file as needed.

Updates

2023-05-22: This article has been recently updated to reflect the latest commands for the Homebrew package manager and to illustrate the extraction process using a current RPM file.