Ports and their dependencies (run deps and also versioning questions)

Ryan Schmidt ryandesign at macports.org
Mon Jun 9 21:30:13 PDT 2008


On Jun 9, 2008, at 19:53, Tabitha McNerney wrote:

> On 6/9/08, Ryan Schmidt wrote:
>
>> On Jun 9, 2008, at 11:23, Tabitha McNerney wrote:
>>
>>> This may sound like a dumb question, but what would be a  
>>> suggested way to discover if Apple / Mac OS X is provided the  
>>> same or similar library for a non-port library dependency of type  
>>> lib: (e.g. depends_lib: lib:libogg)? In the case of a bin: type I  
>>> can easily do something like:
>>>
>>> $ which perl
>>>
>>> Easy as pie. Is there a command similar to "which" that can be  
>>> passed the name of a library from a MacPorts file such as  
>>> "libogg" written above? A program such as libtool? Which would  
>>> come back with info definitively yes or no about the library name  
>>> collision? I suppose I could also dig for it in /usr/lib but it  
>>> would be nice to have something like "which" for libraries as  
>>> part of my MacPorts quality control script.
>>
>> Why do you want to know? :-)
>>
>> As a general rule, if you're writing a port that has dependencies  
>> on other libraries, declare the dependency on other MacPorts  
>> ports. There's no need to investigate which libraries might  
>> already be provided with the version of Mac OS X you happen to  
>> have on your computer because it might be different in other  
>> versions on Mac OS X which is why we try to use only other  
>> MacPorts ports so we know what we're getting.
>
> Ryan, I think I am confused, sorry. The reason I want to know is  
> that I want to be sure that any of the hundreds of ports I install,  
> say on an Xserve, are in fact only dependent on libraries of other  
> MacPorts which libraries would need to be installed. In fact, I  
> don't want any libraries to depend on OS X's names of those same  
> libraries but there might be an exception or two. For example, I do  
> use Apple's X11 application and so let's take the ImageMagik  
> MacPort as an example. ImageMagic has a depend_lib that outputs on  
> the command line (port info --depends_lib ...) with a non-port  
> dependency of type "lib:" like this:
>
> lib:libX11.6:XFree86
>
> How do I (or better yet a script I'm writing) parse that  
> information? Meaning, for example, are libraries associated with  
> libX11.6 supplied by another Mac Port, or does MacPorts look on the  
> root file system (e.g., Mac OS X 10.5 Leopard) to try and find the  
> libraries supplied by Apple (?) with the same namespace associated  
> with "libX11.6"?

X11 is an exception to the usual rule, because the X11 system Apple  
provides is good and has a Mac OS X look and feel, and XFree86 is  
large, takes a long time to build, and in the end you get something  
that looks like Linux, not Mac OS X. Also X11 software seems to be  
special in that it needs to install into /usr/X11R6 (or /usr/X11 on  
10.5 and greater) so you can only install XFree86 if you have not  
already installed Apple's X11. But Apple's X11 is installed by  
default on 10.5 and later, and is pretty common on 10.4 too. It's  
available as a download for 10.3, and isn't available on earlier Mac  
OS X.

For these reasons, for ports that depend on an X Window system, the  
dependency should be written "lib:libX11.6:XFree86" so that they will  
use the Apple X11 installation if it's installed. If you really do  
not want to use Apple's X11 to satisfy the X dependency, then  
uninstall Apple's X11 (remove /usr/X11 (or /usr/X11R6 on 10.4 or  
earlier) and /Applications/Utilities/X11.app), and then MacPorts will  
build and use the XFree86 port.

Another option is to use the xorg port. xorg is a competing X Window  
system which should also work. It will also provide libX11.6 so it  
will also satisfy that dependency.


> Another example, lets' take the sodipodi port. It has a library non- 
> port dependency that looks like this:
>
> lib:libgnomeprintui-2-2:libgnomeprintui
>
> Can either the libraries associated with libgnomeprintui-2-2 or  
> libgnomeprintui be provided potentially by Mac OS X?

I know of no version of Mac OS X that includes any Gnome components.  
The sodipodi port has no maintainer, so it has not seen any love in a  
long time. The dependency on lib:libgnomeprintui-2-2:libgnomeprintui  
has been in the port since it was originally authored in r4876 on  
2004-01-19, likely well before MacPorts had port:-style dependencies.  
I changed it to a port:-style dependency in r37496.

> Or like the non-port dependency of type path:, only these lib: non- 
> port dependencies can be found within the MacPorts prefix on the  
> filesystem?

All non-port dependencies could be satisfied by things outside of  
MacPorts, even path:-style depending on how the path is written.

For example, mpg123 declares a peculiar dependency on "path:/System/ 
Library/Frameworks/CoreAudio.framework:XXX". I guess it means it  
requires the CoreAudio framework, and if that's not present, then  
your Mac OS X is too old? If that case ever occurs, of course, an  
error will be printed that port "XXX" could not be found, so this  
isn't a good way to solve this problem.


> I just want to be sure that I can know with certainty if any of  
> these libraries might be somehow be provided by OS X and if so when  
> to be alerted when this might be the case ahead of time before I  
> install a port.

There's no way to know before you install a port what will ultimately  
happen when you install it. What it links with could even vary based  
on Mac OS X version or even your processor architecture.

But after a port is installed, you can use "otool -L" on all Mach-O  
files installed by the port to see what it's actually linking with.  
For example, here's what cairo links with:


$ port contents cairo | sed 1d | xargs file \
| grep Mach-O | sed 's%[: ].*$%%' | uniq \
| xargs otool -L
/opt/local/lib/libcairo.2.17.5.dylib:
         /opt/local/lib/libcairo.2.dylib (compatibility version  
20.0.0, current version 20.5.0)
         /opt/local/lib/libfontconfig.1.dylib (compatibility version  
5.0.0, current version 5.0.0)
         /opt/local/lib/libiconv.2.dylib (compatibility version  
7.0.0, current version 7.0.0)
         /opt/local/lib/libz.1.dylib (compatibility version 1.0.0,  
current version 1.2.3)
         /opt/local/lib/libexpat.1.dylib (compatibility version  
7.0.0, current version 7.2.0)
         /opt/local/lib/libfreetype.6.dylib (compatibility version  
10.0.0, current version 10.16.0)
         /opt/local/lib/libpng12.0.dylib (compatibility version  
30.0.0, current version 30.0.0)
         /opt/local/lib/libXrender.1.dylib (compatibility version  
5.0.0, current version 5.0.0)
         /usr/X11R6/lib/libX11.6.dylib (compatibility version 6.2.0,  
current version 6.2.0)
         /usr/X11R6/lib/libSM.6.dylib (compatibility version 6.0.0,  
current version 6.0.0)
         /usr/X11R6/lib/libICE.6.dylib (compatibility version 6.3.0,  
current version 6.3.0)
         /opt/local/lib/libpixman-1.0.dylib (compatibility version  
11.0.0, current version 11.0.0)
         /System/Library/Frameworks/CoreServices.framework/Versions/A/ 
CoreServices (compatibility version 1.0.0, current version 18.0.0)
         /System/Library/Frameworks/ApplicationServices.framework/ 
Versions/A/ApplicationServices (compatibility version 1.0.0, current  
version 22.0.0)
         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,  
current version 88.3.9)
$


As it shows, the cairo library links with fontconfig, libiconv, zlib,  
expat, freetype, libpng, xrender and libpixman from MacPorts; libX11,  
libSM and libICE from Apple's X11; and CoreServices,  
ApplicationServices and libSystem provided by the core Mac OS X.

Replace "cairo" with the name of another installed port in the  
command line above to see what that port links with.



More information about the macports-users mailing list