Extracting data from RPM packages


You can download RPM packages locally using the yum’s download only plugin. Use the following command to install this feature:

yum install yum-plugin-downloadonly

The package can then be downloaded using the following command:

yum install –downloadonly –downloaddir=/root/downloads python

Another method in which rpm packages can be downloaded locally is by using the yumdownloader command, you’ll need to install the yum-utils package to enable it:

yum install yum-utils

Then you can use yumdownloader  with the –destdir option to download a RPM package to a desired location:

yumdownloader python  –destdir /root/downloads/

Remember that if an RPM package has several dependencies, you can download them by using the yumdownloader command with the –resolve option just like in the following example:

yumdownloader mysql-server –destdir /root/downloads/ –resolve

I’ve downloaded too many RPM packages because I’ve selected all mysq-server dependencies. For training purposes I’ll clean all RPM packages except the python one:

find /root/downloads/ -type f -not -name “*python*” | xargs rm -f

Now that we’ve managed to download an RPM package on our workstation, it’s time to extract their cpio archive by using the rpm2cpio command:

rpm2cpio python-2.6.6-64.el6.x86_64.rpm > python-2.6.6-64.el6.x86_64.cpio

Once the .cpio archive has been created, use the cpio command to extract its content:

cpio -i –make-directories < python-2.6.6-64.el6.x86_64.cpio

cpio command in Linux

cpio command in Linux

Once the archieve has been extracted, use the tree command to view its structure: tree -d usr/

tree command in Linux

tree command in Linux

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s