PSA: RPMs and Required Libs

Might as well start with the obvious: I’m a RPM tyro. I’ve only written one RPM spec file from scratch, and that only possible by leaning heavily on this excellent RPM tutorial.

Recently I was writing a Makefile to replace a documented manual process for creating an RPM, and I encountered the following weirdness: an RPM I created would not install, citing missing shared libraries, but running ldd on the executable extracted from the RPM showed that the loader could find the libraries, and in fact the executable loaded and ran with out complaint.

More concretely, output from

rpm -i --test foo.rpm

…resulted in

error: Failed dependencies:
    libcidr.so.0()(64bit) is needed by dnsapserver-5.0.1.8b1a2eb-12.x86_64
    libevent-2.0.so.5()(64bit) is needed by dnsapserver-5.0.1.8b1a2eb-12.x86_64
    libevent_pthreads-2.0.so.5()(64bit) is needed by dnsapserver-5.0.1.8b1a2eb-12.x86_64
    libmemcached.so.9()(64bit) is needed by dnsapserver-5.0.1.8b1a2eb-12.x86_64

…but output from

ldd foo.exe

…included

libcidr.so.0 => /usr/local/lib/libcidr.so.0 (0x00007fef28d21000)
libevent-2.0.so.5 => /usr/lib64/libevent-2.0.so.5 (0x00007fef2935d000)
libevent_pthreads-2.0.so.5 => /usr/lib64/libevent_pthreads-2.0.so.5 (0x00007fef28f2a000)
libmemcached.so.9 => /usr/lib64/libmemcached.so.9 (0x00007fef2912c000)

Here was the problem: I had installed libcidr, libevent,  and libmemcached by building them from source, and then using make to install them:

sudo make install
sudo ldconfig -v

My initial work-around was to install the RPM without checking dependencies:

sudo rpm -i --nodeps foo.rpm

That works, but every time I did it, I felt like I really needed to shower.

A real solution, suggested by a colleague after I mentioned this ugliness during a stand-up meeting: install the packages by using RPMs.

BAM!

Apparently, rpm checks an rpm database rather than using ldd or some other mechanism to determine  what’s available.  And apparently installing from make results in the libraries being available to the loader, but with no updates to the RPM database.

This makes sense, but by no means can I assure you that it’s the solution in every case.  What is certain is that in this case, it worked for me.

In any event, now that rpm has quit complaining, I’m a happy camper, and my water bill is getting some relief.

Postscript

“So just how DOES one extract the contents from an RPM file?” I hear you ask.

“Use rpm2cpio,” I answer, “like this:”

rpm2cpio foo.rpm | cpio -idmv

 

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