How to Extract the Contents of an Rpm

How do I extract the contents of an rpm?

Did you try the rpm2cpio commmand? See the example below:

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

/etc/httpd/conf.d/php.conf
./etc/php.d
./etc/php.ini
./usr/bin/php
./usr/bin/php-cgi
etc

Extract RPM to directory other than current directory

Since cpio is just reading from standard input, you can change to another directory before running it:

rpm2cpio mypackage.rpm | (cd /to/other/directory; cpio -idmv)

This is a general solution that will work with a variety of tools. The cpio command has a --directory (-D) option that will accomplish the same thing:

rpm2cpio mypackage.rpm | cpio -D /to/other/directory -idmv

Is there a way to extract .rpm file through windows batch file? Can anyone help me with this?

7zip has the capability to extract files from an .rpm. Use the e option to extract.

7z e file1.rpm

How to extract RPM from RPM database on Red Hat Enterprise Linux

If you want to save a copy of the package as currently installed before upgrading or removing it, use rpm --repackage -- it'll save the RPMs in /var/tmp or /var/spool/repackage or elsewhere, depending on your configuration.

Otherwise, there exists rpmrebuild, which does exactly what you ask for.

Word of caution: with neither of these tools do you obtain the exact same *.rpm as the one you started from. Any changes to the installed files belong to the package will be in the RPMs generated.



Related Topics



Leave a reply



Submit