[ Back to Kevin's Homepage ]

RPM Shortcuts

Everyone's had the problem of "rpm --install some_package.rpm" and getting the message "I need /usr/lib/libgobbletygook.so.3". Below are some suggestions for how you can pre-dump out the contents of your rpms and just grep for the file you need. Note that this doesn't help renamed-package prerequisites, only filename prerequisites.

To link the contents of two directories into one, so you don't have to
figure out what cd the thing is on:

# insert cd#1
mount /dev/cdrom /mnt/cdrom
rsync --archive /mnt/cdrom/. rh80-1/.
eject /mnt/cdrom
# insert cd#2
mount /dev/cdrom /mnt/cdrom
rsync --archive /mnt/cdrom/. rh80-2/.
eject /mnt/cdrom
# insert cd#3
mount /dev/cdrom /mnt/cdrom
rsync --archive /mnt/cdrom/. rh80-3/.
eject /mnt/cdrom

# you can also substitute the loopback mounting of iso's for this:
mkdir /mnt/rh80-1 /mnt/rh80-2 /mnt/rh80-3
mount -t iso9660 -o ro,loop=/dev/loop0 ../rh80-iso/psyche-i386-disc1.iso /mnt/rh80-1
mount -t iso9660 -o ro,loop=/dev/loop1 ../rh80-iso/psyche-i386-disc2.iso /mnt/rh80-2
mount -t iso9660 -o ro,loop=/dev/loop2 ../rh80-iso/psyche-i386-disc3.iso /mnt/rh80-3

mkdir rh80
cd rh80
ln -s ../rh80-?/RedHat/RPMS/* .
	# ? == any one character in a filename (file glob)
	# * == zero or more characters in a filename (file glob)

Now the next piece needs to be executed under sh, bash, or ksh (or any
other bourne shell derivative). Note that bash is the default root and
user shell.

mkdir files
for F in *.rpm ; do
	rpm -qlp $F >files/$F
	done

#	rpm -ql == query the list of files in an rpm
#		-p == use the package specified on the command line
#		rather than the already installed package

since I didn't feel like trying to rename the file (involves messy string
editing) I just create a file in another directory with the output.
In this case files/--name-of-rpm--

So to figure out which rpm contains libFOO ...

cd files
grep /libFOO *

If you don't have enough disk space to have copies of the CDs, you can
also do the following.  Note that when you use grep against multiple
files, grep prefixes the output line with the name of the file.
We can use that to our advantage:

# mount cd1
mkdir /tmp/cd1
cd /tmp/cd1
ln -s /mnt/cdrom/RedHat/RPMS/* .
mkdir files
for F in *.rpm ; do
	rpm -qlp $F >files/$F
	done
eject /mnt/cdrom

# mount cd2
mkdir /tmp/cd2
cd /tmp/cd2
ln -s /mnt/cdrom/RedHat/RPMS/* .
mkdir files
for F in *.rpm ; do
	rpm -qlp $F >files/$F
	done
eject /mnt/cdrom

# mount cd3
mkdir /tmp/cd3
cd /tmp/cd3
ln -s /mnt/cdrom/RedHat/RPMS/* .
mkdir files
for F in *.rpm ; do
	rpm -qlp $F >files/$F
	done
eject /mnt/cdrom

mkdir $HOME/contents_of_cds
mv /tmp/cd1/files $HOME/contents_of_cds/cd1
mv /tmp/cd2/files $HOME/contents_of_cds/cd2
mv /tmp/cd3/files $HOME/contents_of_cds/cd3

and then you can do things like
cd contents_of_cds
grep /libFOO */*

and the output would look like:

cd1/whatever.rpm:/usr/lib/libFOO


Alternatively, you can generate one large file that has all these
pre-embedded:

using the $HOME/contents_of_cds/cd?/ directories, you can:
cd ~/contents_of_cds
grep '' cd?/* >rpm-ql

this will put "cd1/whatever.rpm:/usr/lib/libFOO" into the rpm-ql file,
so you know what CD it really is on! and you only have one file to deal
with rather than three directories full of files.


Created - 2002.04.04 kjw
Last Modified - 2003.02.17 kjw