Another issue related to dependency location is how to establish a model whereby unbundled products express dependencies between themselves.
For example, the unbundled product XYZ might have dependencies on the product ABC. This dependency can be established by a host package installation script. This script generates a symbolic link to the installation point of the ABC product, as shown in the following figure.
Figure 10-2 Unbundled Co-Dependencies
The binaries and shared objects of the XYZ product can represent their dependencies on the ABC product using the symbolic link. This link is now a stable reference point. For the application xyz, this runpath would be as follows.
$ cc -o xyz xyz.c '-R$ORIGIN/../lib:$ORIGIN/../ABC/lib' \ -L/opt/ABC/lib -lX -lA $ elfdump -d xyz | egrep 'NEEDED|RUNPATH' [0] NEEDED 0x1b5 libX.so.1 [1] NEEDED 0x1bf libA.so.1 .... [2] NEEDED 0x18f libc.so.1 [5] RUNPATH 0x1c9 $ORIGIN/../lib:$ORIGIN/../ABC/lib
and similarly for the dependency libX.so.1 this runpath would be as follows.
$ cc -o libX.so.1 -G -Kpic X.c '-R$ORIGIN:$ORIGIN/../ABC/lib' \ -L/opt/ABC/lib -lY -lC $ elfdump -d libX.so.1 | egrep 'NEEDED|RUNPATH' [0] NEEDED 0x96 libY.so.1 [1] NEEDED 0xa0 libC.so.1 [5] RUNPATH 0xaa $ORIGIN:$ORIGIN/../ABC/lib
If this product is now installed under /usr/local/XYZ, its post-install script would be required to establish a symbolic link.
$ ln -s ../ABC /usr/local/XYZ/ABC
If your PATH is augmented with /usr/local/XYZ/bin, then invocation of the application xyz results in a path name lookup for its dependencies as follows.
$ ldd -s xyz .... find object=libX.so.1; required by xyz search path=$ORIGIN/../lib:$ORIGIN/../ABC/lib (RUNPATH/RPATH from file xyz) trying path=/usr/local/XYZ/lib/libX.so.1 libX.so.1 => /usr/local/XYZ/lib/libX.so.1 find object=libA.so.1; required by xyz search path=$ORIGIN/../lib:$ORIGIN/../ABC/lib (RUNPATH/RPATH from file xyz) trying path=/usr/local/XYZ/lib/libA.so.1 trying path=/usr/local/ABC/lib/libA.so.1 libA.so.1 => /usr/local/ABC/lib/libA.so.1 find object=libY.so.1; required by /usr/local/XYZ/lib/libX.so.1 search path=$ORIGIN:$ORIGIN/../ABC/lib \ (RUNPATH/RPATH from file /usr/local/XYZ/lib/libX.so.1) trying path=/usr/local/XYZ/lib/libY.so.1 libY.so.1 => /usr/local/XYZ/lib/libY.so.1 find object=libC.so.1; required by /usr/local/XYZ/lib/libX.so.1 search path=$ORIGIN:$ORIGIN/../ABC/lib \ (RUNPATH/RPATH from file /usr/local/XYZ/lib/libX.so.1) trying path=/usr/local/XYZ/lib/libC.so.1 trying path=/usr/local/ABC/lib/libC.so.1 libC.so.1 => /usr/local/ABC/lib/libC.so.1 find object=libB.so.1; required by /usr/local/ABC/lib/libA.so.1 search path=$ORIGIN (RUNPATH/RPATH from file /usr/local/ABC/lib/libA.so.1) trying path=/usr/local/ABC/lib/libB.so.1 libB.so.1 => /usr/local/ABC/lib/libB.so.1