Previous Section  < Day Day Up >  Next Section

Recipe 2.9. Tracking Source-Built Libraries on an RPM-Based System

2.9.1 Problem

You want to run both source-built programs and RPMs on the same system. But RPM does not know about the source-built libraries, so it incorrectly reports dependency errors.

2.9.2 Solution

Use the rpm-orphan-find script. This script searches for all the libraries on your system, then compares the results with the contents of the RPM database. Any orphaned libraries are then rolled into a new, virtual .rpm. There are no files in this .rpm, just a list of provides. Run this like any Bash script:

# chmod +x rpm-orphan-find

# ./rpm-orphan-find

When the script is finished, install the shiny new .rpm, and your formerly orphaned libraries will be included in your RPM database.

2.9.3 Program: rpm-orphan-find

Thank you to Paul Heinlein and Peter Samuelson for this great script.


## rpm-orphan-find, a script that finds

## orphaned libs on an RPM-based system

## and rolls them into a virtual .rpm

## written by Paul Heinlein and Peter Samuelson

## Copyright 2003

## You may use, distribute or modify this

## program under the terms of the GPL.

OS=$(uname -s)

LIBS="/lib /usr/lib $(cat /etc/"

NAME=$(echo ${OS}-base-libs | tr '[A-Z]' '[a-z]')

VER=1.0; REL=1

TMPSPEC=$(mktemp /tmp/${NAME}.spec.XXXXXX)


exec 9>$TMPSPEC


cat <<_ _eof_ _ >&9

Summary: $OS Base Virtual Package

Name: $NAME

Version: $VER

Release: $REL

Group: System Environment/Base

License: None

_ _eof_ _


found=0; orphan=0;

echo "Scanning system libraries $NAME version $VER-$REL..."

find $LIBS -type f \( -name '*.so.*' -o -name '*.so' \) |

while read f



  if ! rpm -qf $f >/dev/null 2>&1



    echo "Provides: $(basename $f)" >&9


  echo -ne "Orphans found: $orphan/$found...\r"


echo ''; echo ''


cat <<_ _eof_ _ >&9



This is a virtual RPM package.  It contains no

actual files.  It uses the 'Provides' token from RPM 3.x and later to list many of the 

shared libraries that are part of the base operating system and associated subsets for 

this $OS environment.



# nothing to do



# nothing to do



# nothing to do



# nothing to do



# nothing to do




_ _eof_ _


exec 9>&-

rpmbuild -ba $TMPSPEC; rm $TMPSPEC

Note that rpmbuild has replaced rpm. Since when, you ask? Since the turn of the century. It first appeared in Red Hat 8, RPM Version 4.1. The old RPM commands often still work, though, because they are aliased in /etc/popt. Run rpm —version to see what version you have.

If you have an older version of RPM, edit the last line of the script as follows:

rpm -bb $TMPSPEC; rm $TMPSPEC

2.9.4 See Also

    Previous Section  < Day Day Up >  Next Section