Extract RPM to directory other than current directory Extract RPM to directory other than current directory shell shell

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


Or even easier:

rpmdev-extract -C DIR mypackage.rpm