Showing posts with label RPM. Show all posts
Showing posts with label RPM. Show all posts

16 November 2007

How do I extract an RPM package without installing it ?

There is no direct RPM option available via rpm command to extract an RPM file. But there is a small utility available called rpm2cpio. It extract cpio archive from RPM Package Manager (RPM) package.

rpm2cpio converts the .rpm file specified as a single argument to a cpio archive on standard out.

Example

$ mkdir test
$ cd test

Extract RPM file using rpm2cpio and cpio command:

$
rpm2cpio php-5.1.6-12.el5.i386.rpm | cpio -idmv

Output of rpm2cpio piped to cpio command with the following options:

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

Output:

./etc/httpd/conf.d/php.conf
./usr/lib64/httpd/modules/libphp5.so
....
.....
..
./var/lib/php/session
./var/www/icons/php.gif
6349 blocks

Verify that you have extracted an RPM file in current directory:

$ls

Output:


etc php-5.1.4-1.esp1.x86_64.rpm usr var

This is useful if you want to extract configuration file or other file w/o installing an RPM file.

13 November 2007

Linux rpm package failed to install,How can I fix this?

Problem Statement:

I downloaded an RPM file to a Windows machine using Internet Explorer then transferred it to my Linux machine. When I try to install it with the RPM command, I immediately get a prompt back and it does not install.

Solution:

When downloading a file, IE sometimes places square brackets in the resulting filename. When the rpm command is run on a file with square brackets, it fails with no error message and does not install the package. The square brackets are a part of the Linux bash shell and are reserved for a technique called file globbing.

To fix this, rename the RPM with the mv command. When specifying the filename of the RPM at a shell prompt,type the
first few letters, then use the Tab key to autocomplete the name. This ensures that the brackets in the filename are properly delimited. Rename the file to so that it does not contain square brackets. For example:

mv kernel-2\[1\].4.21-20.EL.i686.rpm kernel-2.4.21-20.EL.i686.rpm
Alternatively, you can enclose the file in single quotes, like so:
mv 'kernel-2[1].4.21-20.EL.i686.rpm' kernel-2.4.21-20.EL.i686.rpm

After renaming the file, the rpm command can be used to install the package successfully.

Repair Corrupt RPM Database

Strange things sometimes happen, one of them is a corrupt rpm database. This means that the computer tells you something is installed and it really is not.
Here is how to solve this problem.

First backup and then delete by doing the following command:
$ su -

# cp /var/lib/rpm/__db.001 /home/test
# rm /var/lib/rpm/__db.001
# cp /var/lib/rpm/__db.002 /home/test
# rm /var/lib/rpm/ __db.002
# rpm –rebuilddb