portfile question concerning optional deps

Ryan Schmidt ryandesign at macports.org
Thu Mar 3 14:20:51 PST 2011


On Mar 3, 2011, at 16:11, Daniel J. Luke wrote:

> On Mar 3, 2011, at 4:52 PM, Marko Käning wrote:
>> 
> 
>> I want A to be dependent on either B-release or B-devel, exclusively!
>> 
>> Say, the user has installed B-devel before installing port A: In that case I want to let port A accept B-devel as the default dep.
>> If, however, B-release is installed, than that one should be accepted.
>> 
>> How can I test in the portfile for already installed ports?
> 
> Usually this is done with bin/lib/path style dependencies (instead of port)
> 
> So, you pick something in B that port A needs to have there (a library, binary, header file) and depend on that.
> 
> MacPorts will install the port you choose (which should be B-release by default) if the file isn't found. If the file is there (from either B-release or B-devel), it won't install anything.
> 
> You can have a variant which flips which port gets installed (or depends with a port: style dependency instead) if you think that that will make things easier for the end user as well.
> 
> For example, if you want to depend on either mysql5 or mysql5-devel, you could use:
> 
> path:bin/mysql_config5:mysql5
> 
> (which says, look for mysql_config5 in $prefix/bin, if it's not there install the mysql5 port).
> 
> This could also be written as:
> 
> bin:mysql_config5:mysql5
> 
> If you wanted to depend on libsdl.dylib from either libsdl or libsdl-devel, you could use:
> 
> lib:libsdl:libsdl

Do not use bin:- or lib:-style dependencies for this purpose; they would allow a file outside of the MacPorts prefix to satisfy the dependency, and we don't want that. Use only path:-style.






More information about the macports-dev mailing list