Для извлечения файлов из RPM пакета пригодится небольшая утилита rpm2cpio. В Ubuntu ее можно установить командой
sudo aptitude install rpm2cpio
rpm2cpio извлекает cpio архив, хранящийся в RPM. Таким образом становится возможным извлечь из RPM нужные файлы без его установки.
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
Examples — Extract files from rpm
Download an RPM file:
$ mkdir test
Extract RPM file using rpm2cpio and cpio command:
$ cd test
$ wget http://www.cyberciti.biz/files/lighttpd/rhel4-php5-fastcgi/php-5.1.4-1.esp1.x86_64.rpm
$ 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.