LinuxCommandLibrary

rpm2cpio

Extract cpio archive from RPM package

TLDR

Convert an RPM package to a cpio archive and save it as file.cpio in the current directory

$ rpm2cpio [path/to/file.rpm]
copy

SYNOPSIS

rpm2cpio [RPM_FILE]
rpm2cpio < RPM_FILE

PARAMETERS

RPM_FILE
    The path to the RPM package file from which the CPIO archive is to be extracted. If not specified, rpm2cpio reads the RPM package from standard input.

DESCRIPTION

The rpm2cpio command is a lightweight utility designed to extract the payload (file data) from an RPM package. Unlike the rpm command itself, which manages package installation and query, rpm2cpio focuses solely on extracting the file archive contained within an RPM. It reads an RPM package, either from a specified file or from standard input, and then outputs the embedded CPIO archive to standard output. This output can then be piped to the cpio command (e.g., rpm2cpio package.rpm | cpio -idmv) to extract the actual files to the filesystem. It's particularly useful for inspecting package contents without installing them, or for extracting specific files from an RPM package without administrative privileges or disturbing an existing system installation.

CAVEATS

rpm2cpio only extracts the CPIO data stream; it does not extract the files to the filesystem. To extract files, its output must be piped to the cpio command (e.g., rpm2cpio mypackage.rpm | cpio -idmv). It does not provide access to RPM metadata (e.g., package name, version, dependencies); for that, the rpm command's query functionality is required.

TYPICAL USAGE

The most common way to use rpm2cpio is to pipe its output directly to the cpio command to extract the files. For example:
rpm2cpio mypackage.rpm | cpio -idmv
Here, -i extracts files, -d creates leading directories, -m preserves modification times, and -v lists files verbosely.

HISTORY

rpm2cpio is typically distributed as part of the RPM Package Manager suite itself. Its development is intertwined with the evolution of RPM. It serves as a fundamental helper utility, providing a low-level interface to extract the core file archive from an RPM package, reflecting RPM's internal structure where file data is stored in a CPIO archive. Its design principle is 'do one thing and do it well', focusing purely on the CPIO extraction aspect without added complexity.

SEE ALSO

rpm(8), cpio(1), rpmbuild(8)

Copied to clipboard