cpio and rpm2cpio howto

To extract a cpio file:

cpio -iv < cpio_file

To list the contents of a cpio file:

cpio -itv < cpio_file

To create a cpio file with all files in the current directory:

ls | cpio -o > cpio_file

To extract all files from an RPM:

rpm2cpio RPM_file | cpio -idv

To extract individual file(s) from an RPM:

rpm2cpio RPM_file | cpio -id individual_file(s)

e.g. Extracting libcrypto.so.0.9.7a and libssl.so.0.9.7a from openssl-0.9.7a-2.i386.rpm:

rpm2cpio openssl-0.9.7a-2.i386.rpm | cpio -it egrep “libcrypto.so.0.9.7a|libssl.so.0.9.7a”

-rwxr-xr-x 1 root root 992092 Feb 27 12:10 ./lib/libcrypto.so.0.9.7a
-rwxr-xr-x 1 root root 216004 Feb 27 12:10 ./lib/libssl.so.0.9.7a

rpm2cpio openssl-0.9.7a-2.i386.rpm | cpio -idv ./lib/libssl.so.0.9.7a ./lib/libcrypto.so.0.9.7a

This will extract the two files from the RPM into a ./lib subdirectory.

Tags: , , , ,

Leave a Reply