Extracting rpm file command
To be frank there is no direct option available for rpm command to extract an RPM file. But there is a small nifty utility available called rpm2cpio. It rxtract cpio archive from RPM Package Manager (RPM) package. With the following hack you will be able to extract an RPM file.
First you use rpm2cpio to convert the .rpm file into a cpio archive on standard out. If a - argument is given, an rpm stream is read from standard in. The basic syntax is as follows:
pm2cpio myrpmfile.rpm
rpm2cpio - < myrpmfile.rpm
rpm2cpio myrpmfile.rpm | cpio -idmv
Examples - Extract files from rpm
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.rpmTo extract RPM file using rpm2cpio and cpio command, type:
$ rpm2cpio php-5.1.4-1.esp1.x86_64.rpm | cpio -idmv
Sample outputs:
/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 blocksIn this example, output of rpm2cpio command piped to cpio command 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 the current directory:
$ ls
Sample outputs:
etc php-5.1.4-1.esp1.x86_64.rpm usr var
Say hello to Midnight Commander
GNU Midnight Commander (mc) is a directory browser/file manager for Unix-like operating systems. Install mc using the following :
# yum install mc
Opening an RPM file using Midnight Commander (mc)
You can use mc command as follows to browse or extract rpm files:
# mc
Sample outputs:
Fig.01: Browsing / viewing an rpm file with GNU Midnight Commander
Next select an RPM file (such as php-5.3*.rpm) by highlighting the package name and press Enter key. You need to select CONTENTS.cpio file:
Fig.02: The actual php rpm files are contained in the CONTENTS.cpio file
Fig.03: Viewing php.conf file
Conclusion
I hope you will find these tips useful to extract configuration file or other file without installing an RPM file.
Ref: http://www.cyberciti.biz/tips/how-to-extract-an-rpm-package-without-installing-it.html
1555

被折叠的 条评论
为什么被折叠?



