Strict Standards: Declaration of RSS::DoAction() should be compatible with CMSModule::DoAction($name, $id, $params, $returnid = '') in /home/xandaorg/public_html/modules/RSS/RSS.module.php on line 0

Strict Standards: Non-static method PageInfoOperations::LoadPageInfoByContentAlias() should not be called statically in /home/xandaorg/public_html/index.php on line 154

Warning: Cannot modify header information - headers already sent by (output started at /home/xandaorg/public_html/modules/RSS/RSS.module.php:0) in /home/xandaorg/public_html/index.php on line 299
Xanda - /dev/project - Extract an RPM package without installing it

To be frank there is no direct RPM option available via rpm command to extract an RPM file. But there is a small nifty utility available called rpm2cpio. It Extract cpio archive from RPM Package Manager (RPM) package. With the following hack you will be able to extract an RPM file.

So rpm2cpio converts the .rpm file specified as a single argument to a cpio archive on standard out. If a - argument is given, an rpm stream is read from standard in.

Syntax is as follows:
rpm2cpio myrpmfile.rpm
rpm2cpio - < myrpmfile.rpm
rpm2cpio myrpmfile.rpm | cpio -idmv

Example

Download an RPM file:

$ mkdir test

$ cd test

$ wget http://www.cyberciti.biz/files/lighttpd/rhel4-php5-fastcgi/php-5.1.4-1.esp1.x86_64.rpm

Extract RPM file using rpm2cpio and cpio command:

$ rpm2cpio php-5.1.4-1.esp1.x86_64.rpm | cpio -idmv

Output:

/etc/httpd/conf.d/php.conf
./etc/php.d
./etc/php.ini
./usr/bin/php
./usr/bin/php-cgi
./usr/lib64/httpd/modules/libphp5.so
./usr/lib64/php
./usr/lib64/php/modules
....
.....
..
./var/lib/php/session
./var/www/icons/php.gif
19188 blocks

Output of rpm2cpio piped to cpio command (see how to use cpio) with following options:

  • i: Restore archive
  • d: Create leading directories where needed
  • m: Retain previous file modification times when creating files
  • v: Verbose i.e. display progress

Verify that you have extracted an RPM file in current directory:

$ ls 

Output:

etc  php-5.1.4-1.esp1.x86_64.rpm  usr  var

This is useful if you want to extract configuration file or other file w/o installing an RPM file.