Библиотека сайта rus-linux.net
From time to time, you might find it necessary to extract one or more files from a package file. One way to do this would be to:
Install the package
Make a copy of the file(s) you need
Erase the package
An easier way would be to use rpm2cpio.
As the name implies, rpm2cpio takes an RPM package file and converts it to a cpio archive. Because it's written to be used primarily as a filter, there's not much to be specified. rpm2cpio takes only only one argument, and even that's optional!
logrotatepackage file. We've also redirected rpm2cpio's output to a file called
blah.cpio. Next, using the file command, we find that the resulting file is indeed a true-blue cpio archive file. The following command is entirely equivalent to the one above and shows rpm2cpio's ability to read the package file from its standard input:
In this example, we used the -t option to direct cpio to produce a "table of contents" of the archive created by rpm2cpio. This can make it much easier to get the right filename and path when you want to extract a file.
logrotatepackage. In the table of contents, we see that the full path is
usr/man/man8/logrotate.8. All we need to do is to use the filename and path as shown below:
In this case, the cpio options -i, -v, and -d direct cpio to:
Extract one or more files from an archive.
Display the names of any files processed, along with the size of the archive file, in 512-byte blocks. 
Create any directories that precede the filename specified in the cpio command.
Since the current directory didn't have a
usr/man/man8/ path in it, the
-d option caused cpio to create
all the directories leading up to the
file in the current directory. Based on this, it's probably safest to
use cpio outside the normal
system directories unless you're comfortable with
cpio, and you know what you're doing!
Note that the size displayed by cpio is the size of the cpio archive and not the package file.