Local RPM Find

2004 June 11 at 23:28 » Tagged as :

rpmfind.net and other similar sites are pretty neat, but they cannot tell you about the rpms in your CD spindle. rpmfind doesn't tell you about the source tarballs either. So I decided to create something along these lines for my own local use, hopefully you will find it usefull too.

The first step of course is to create a database, I used mysql for this but almost any db will do.

#

# Table structure for table `rpmCD`

#

CREATE TABLE rpmCD (

id int(11) NOT NULL auto_increment,

label varchar(32) NOT NULL default '',

file varchar(255) NOT NULL default '',

PRIMARY KEY (id),

FULLTEXT KEY label (label,file)

) TYPE=MyISAM CHARSET=latin1;

# --------------------------------------------------------

#

# Table structure for table `rpmFiles`

#

CREATE TABLE rpmFiles (

rpmId int(11) NOT NULL default '0',

fileName varchar(255) NOT NULL default '',

KEY rpmId (rpmId),

FULLTEXT KEY fileName (fileName)

) TYPE=MyISAM CHARSET=latin1;

The second table can be used to store the list of files contained with in each RPM (when you attempt to compile from source the build system will complain about missing headers or shared objects and not RPMS so this table can be rather usefull). Unfortunatley since thousands of files are contained in each RPM it can grow very rapidly and not everyone will need it.

here is the link to the script that creates the table. You probably wouldn't want to sit down and load up all your CDs into the database it can become quite tedius. I loaded up a few cds each time I had to look for some rpm/tarball or the other.

use the script as follows.

cd /mnt/cdrom

php -f /home/raditha/rpmdb.php 'CD LABEL'

Replace CD LABEL with whatever label you have on the cd. You can eliminate the cd /mnt/cdrom/ step by editing the following line in the php script

$files = split("n",`find . -name '*rpm'`);

Just replace the dot (.) with /mnt/cdrom/ and you can run the script from anywhere without changing into the cdrom folder. $files = split("n",`find . -name '*rpm'`);

Now you may ask how do you query the database? I use the mysql command line client, you can use phpmyadmin instead.