CentOS - Extract RPM

Preface

Sometime it we will need to extract data included in RPM package as we are looking for particular information but we do not won’t to install the whole RPM. In this document I would like to describe simple way how we can extract data from RPM without installing it.

Tools for data extracting

rpm2cpio

In general it is possible to say that RPM is an form of archive package that is possible to convert in to cpio format that is possible to present on standard output or convert to file structure.

cpio

Following archive formats are supported: binary, old ASCII, new ASCII, crc, HPUX binary, HPUX old ASCII, old tar, and POSIX.1 tar. The tar format is provided for compatibility with the tar program. By default, cpio creates binary format archives, for compatibility with older cpio programs. When extracting from archives, cpio automatically recognizes which kind of archive it is reading and can read archives created on machines with a different byte-order.

Extract RMP

Extract RPM -> STDOUT

It is possible to extract the RPM directly to your STDOUT so that you can redirect it to another destination. The format of extracted data will be cpio.

Example:

[root@CentOS test]# rpm2cpio pwdb-0.62-2tr.i586.rpm
0707010025024d000081a400000000000000000000000145e301aa00000086000000160000004100000000000000000000001000000000./etc/pwdb.conf#
# This is the configuration file for the pwdb library

List only file structure

Some time you will need to see only the file structure of data from RPM. According to this it to print the whole RPM to STDOUT is not really handy as well extracting of all data from RPM is not really needed.

Example:

[root@CentOS test]# rpm2cpio pwdb-0.62-2tr.i586.rpm | cpio -t
./etc/pwdb.conf
./lib/libpwdb.so.0.62
./usr/share/doc/pwdb-0.62
./usr/share/doc/pwdb-0.62/CREDITS
./usr/share/doc/pwdb-0.62/Copyright
./usr/share/doc/pwdb-0.62/README
./usr/share/doc/pwdb-0.62/pwdb.txt
343 blocks

Extract RPM -> Files

In some cases you will prefer to extract RPM data to file structure so that you can see what will be installed or you are only looking for particular information about extracted RPM.

Example:

[root@CentOS test]# ls
pwdb-0.62-2tr.i586.rpm

[root@CentOS test]# rpm2cpio pwdb-0.62-2tr.i586.rpm | cpio -ivd
./etc/pwdb.conf
./lib/libpwdb.so.0.62
./usr/share/doc/pwdb-0.62
./usr/share/doc/pwdb-0.62/CREDITS
./usr/share/doc/pwdb-0.62/Copyright
./usr/share/doc/pwdb-0.62/README
./usr/share/doc/pwdb-0.62/pwdb.txt
343 blocks

[root@CentOS test]# find ./*
./etc
./etc/pwdb.conf
./lib
./lib/libpwdb.so.0.62
./pwdb-0.62-2tr.i586.rpm
./usr
./usr/share
./usr/share/doc
./usr/share/doc/pwdb-0.62
./usr/share/doc/pwdb-0.62/pwdb.txt
./usr/share/doc/pwdb-0.62/README
./usr/share/doc/pwdb-0.62/CREDITS
./usr/share/doc/pwdb-0.62/Copyright
Navigation
Print/export
QR Code
QR Code wiki:os:centos:centos-extract-rpm (generated for current page)