checking inside rpms

Nine years ago I was trying to find which RPM contained the executable “cluconfig” for configuring clustering – I made these notes on looking for a file in rpms

SUMMARY: needed cluconfig for Cluster Manager -
searched for cluconfig in install disks for RHAS

NOTES:
mount the disk, cd to RPMS directory, run:
for i in *
do
    echo -----------------------------------------
    echo $i
    echo -----------------------------------------
    rpm -q --filesbypkg -p $i | grep cluconfig
done


-----------------------------------------
cervisia-1.4.1-2.i386.rpm
-----------------------------------------
-----------------------------------------
clumanager-1.0.11-1.i386.rpm
-----------------------------------------
clumanager                /sbin/cluconfig
clumanager                /usr/share/man/man8/cluconfig.8.gz
-----------------------------------------
compat-egcs-6.2-1.1.2.16.i386.rpm
-----------------------------------------
-----------------------------------------
compat-egcs-c++-6.2-1.1.2.16.i386.rpm
-----------------------------------------

and there's our rpm

This has come in handy time after time.

Recently I was trying to figure out what had created a set of directories for an application – were they set up by the rpm, or by the application as it started, or through the puppet configuration and install?

To eliminate the rpm as the source I sshed to the deploy server, went into the yum repo and queried the rpm that had been pushed to the offending server. I ran

rpm -q --filesbypkg -p 

and eliminated the rpm as a source quickly.

I ran into a situation a couple of years ago where I needed the original configuration file from an rpm. Not the whole rpm, just the actual file it installed before anything else changed it.

I found that there was no direct way to ask an rpm to just install locally within a directory.
I did find a utility available called rpm2cpio. It extracts a cpio archive from an rpm. And on the web through google I found the following hack…

Syntax is: rpm2cpio myrpmfile.rpm | cpio -idmv

Download an RPM file:
$ mkdir test
$ cd test
$ wget http://www.cyberciti.biz/files/lighttpd/rhel4-php5-fastcgi/php-5.1.4-1.esp1.x86_64.rpm
Extract RPM file using rpm2cpio and cpio command:
$ rpm2cpio php-5.1.4-1.esp1.x86_64.rpm | cpio -idmv

Output of rpm2cpio is piped to cpio command with 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

sudo apt-get install rpm2cpio
to get the package

dsm@dmunsingernx2:~/test$ rpm2cpio
The program 'rpm2cpio' is currently not installed.  You can install it by typing:
sudo apt-get install rpm2cpio
dsm@dmunsingernx2:~/test$ sudo apt-get install rpm2cpio

dsm@dmunsingernx2:~/test$ rpm2cpio internalws-rpm-trunk_110427_093012-1.noarch.rpm | cpio -idmv
./opt/jboss/server/internalws
./opt/jboss/server/internalws/conf
./opt/jboss/server/internalws/conf/bootstrap
./opt/jboss/server/internalws/conf/bootstrap-norepo.xml
./opt/jboss/server/internalws/conf/bootstrap.xml
./opt/jboss/server/internalws/conf/bootstrap/aop.xml
etc

from the resulting install I found my configuration file under $HOME/test/opt/jboss/server/internalws/deploy
The files were not installed locally through my system and cleanup is now deleting a single directory (test) rather than trying the uninstall script and trusting it to do the right thing in eliminating the package – not entirely certain with homebuilt or even open source packages at all times.

–doug