Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract a file from an rpm to the current directory?

Tags:

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!!

like image 213
PabloDario Avatar asked May 16 '13 21:05

PabloDario


People also ask

How do I extract files from RPM?

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.

How extract RPM file in Ubuntu?

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.

What utility will extract files from an RPM package without installing the package?

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.


1 Answers

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 #  
like image 82
Aaron D. Marasco Avatar answered Sep 23 '22 17:09

Aaron D. Marasco