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 rpmfile

PARAMETERS

rpmfile
    The path to the RPM file from which to extract the CPIO archive. If omitted, rpm2cpio reads the RPM data from standard input.

DESCRIPTION

The rpm2cpio command extracts the contents of an RPM (Red Hat Package Manager) archive into a CPIO (Copy In/Out) archive. This allows you to access the individual files contained within the RPM package without actually installing the package. This is useful for examining package contents, extracting specific files, or converting the RPM to a different archive format.

It takes the RPM file either from standard input or as an argument and writes a CPIO archive to standard output. The CPIO archive can then be piped to other utilities like cpio itself to extract the files to a directory.

CAVEATS

rpm2cpio does not handle dependency resolution or installation. It simply extracts the archived files from the RPM. It's also important to remember that this command is primarily for extracting the data archive and may not properly handle RPM-specific metadata or scripts.

USAGE EXAMPLES

To extract a CPIO archive from an RPM file named 'example.rpm':
rpm2cpio example.rpm > example.cpio

To extract all files from 'example.rpm' to a directory 'extract':
rpm2cpio example.rpm | cpio -idmv --directory extract

To pipe an rpm to rpm2cpio (for example downloading a file with wget):
wget -O- 'http://example.com/package.rpm' | rpm2cpio | cpio -idmv

HISTORY

rpm2cpio has been part of the RPM ecosystem for a long time, serving as a crucial tool for inspecting and manipulating RPM packages without requiring installation. Its functionality has remained relatively stable, primarily focused on its core task of RPM to CPIO conversion. The command is often found in minimal linux environments as it doesn't need large libraries for RPM dependencies.

SEE ALSO

rpm(8), cpio(1), ar(1)

Copied to clipboard