Extract the contents of the RPM

Extract the contents of the RPM

A few times we require to extract the contents of a RPM file.

A common example will be to get some configuration file from a package file or using the binaries to some other distributions.

We can use rpm2cpio to extract the contents of the RPM file.

The following is the syntax which can be used to extract the contents of the RPM file:

[[email protected] ~]# rpm2cpio PACKAGE_FILE.rpm | cpio -idmv

Where,

    i — Restore archive
    d — Create leading directories where needed
    m — Retain previous file modification times when creating files
    v — Verbose i.e. display progress

The following can be considered as an example.

We will extract the contents of the RPM file MySQL-server-5.0.27-0.i386.rpm

[[email protected] gagan]# rpm2cpio MySQL-server-5.0.27-0.i386.rpm | cpio -idmv

Output:

etc/init.d/mysql
etc/logrotate.d/mysql
usr/bin/my_print_defaults
usr/bin/myisam_ftdump
usr/bin/myisamchk
usr/bin/myisamlog
usr/bin/myisampack
.
.
.
.
usr/share/mysql/swedish/errmsg.sys
usr/share/mysql/ukrainian
usr/share/mysql/ukrainian/errmsg.sys
64984 blocks

Now let’s confirm if we have the required files extracted.

[[email protected] ~]# ls

Output:

etc  MySQL-server-5.0.27-0.i386.rpm  usr

No Comments

Post a Comment

Time limit is exhausted. Please reload CAPTCHA.