I recently found out about the existence of cpio and how it can be used, among many other things, to extract individual files from an rpm in conjunction with the rpm2cpio tool, like this:
rpm2cpio mypackage.rpm | cpio -idmv ./path/to/individual/file/inside/the/rpm/filename.txt
The problem is that this command will create the directory that matches the file's location inside the rpm, i.e., it will create the directory /path/to/individual/file/inside/the/rpm/
inside the current directory before actually extracting the file.
Is there any way to extract the file to the current directory without creating the whole directory structure?
Thanks in advance!!
Extract files from an RPM package's cpio archive The rpm2cpio command will output (to stdout) a cpio archive from the RPM package. To extract the package files we'll use the output from rpm2cpio and then use the cpio command to extract and create the files we need. The cpio command copies files to and from archives.
If you want to extract files from an RPM package without installing it, here is how: first obtain a cpio archive from the RPM file, and then extract actual files from the cpio archive. The following describes how to achieve this from the Linux command line.
To do that, you can use the rpm2cpio conversion tool. The rpm2cpio tool extracts the content of a source or binary RPM in the form of a CPIO, not a TAR, archive.
You can use --to-stdout
for cpio
. E.g.:
# rpm2cpio id3lib-3.8.3-28.fc18.x86_64.rpm | cpio -iv --to-stdout ./usr/share/doc/id3lib-3.8.3/README > /tmp/README ./usr/share/doc/id3lib-3.8.3/README 2173 blocks #
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With