Extract files from a RPM without installing the package

Posted in howto , Linux

extract

Have you ever wanted to unpack an RPM just to get to the contents of a single file or two? You could install it, but what if you have conflicting packages or you don’t want to modify the system files right now. You can query a package without installing, but you can’t open those files.

rpm2cpio

This little utility comes with rpm, so it’s already installed and waiting for you. rpm2cpio converts a rpm file specified as as a command argument (or as standard input) and spits it out as a cpio archive to standard output.

rpm2cpio VirtualBox-3.2-3.2.6_63112_fedora12-1.i686.rpm | cpio -idm

This will unpack the rpm into the current directory. If the rpm contained files that go into /etc/ and /usr/bin, then you’ll have a ./usr/bin and ./etc.

If you want to break stuff, try doing that starting from the root directory. Now you’ll have all the files installed without installing the metadata using RPM. The rpm database will have no idea what you’ve just installed, so you won’t be able to simple uninstall later.

The only good news is any files that already exist with the same or newer timestamps will NOT be overwritten. So in some special cases, this may be what you want to do.

# rpm2cpio setup-*.rpm | cpio -idmv
cpio: ./etc/hosts not created: newer or same age version exists

Posted by admica   @   6 December 2010

Related Posts

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

*

Previous Post
«
Next Post
»
Powered by Wordpress   |   Lunated designed by ZenVerse

Valid XHTML 1.0 Transitional