How to specify a variant to depends_lib in a portfile?
Mike O'Brien
Michael.T.OBrien at aero.org
Tue Aug 16 15:37:07 PDT 2011
On Aug 16, 2011, at 3:22 PM, Ryan Schmidt wrote:
> On Aug 16, 2011, at 16:54, Mike O'Brien wrote:
>
>> We are building a virtual port, which install some 40 (!) ports via depends_lib "port:" entries. Now we find that we must install one particular variant of one of the ports. Is there a way to specify that in a depends-lib entry?
>
> No, this is not possible:
>
> https://trac.macports.org/ticket/126
>
>
>> Or is there some other way to accomplish the same effect?
>
> The standard way we handle this situation is to identify a file that the port installs only when using this variant. Or, if the list of installed files is identical, find some other way to programmatically determine whether the already-installed dependency has the variant selected -- for example, by running its pkg-config script and testing for certain flags.
>
> If the dependency is not yet installed (the special file, or the pkg-config file, does not exist), or the pkg-config results show the variant is not installed, then delete the dependency and error out, explaining to the user they should install the dependency with the variant first.
>
> One example where we've done this in a few ports is those that depend on boost's python capabilities, such as PlasmaClient, which does this:
>
>
> depends_lib port:boost
>
> if {![file exists ${prefix}/lib/libboost_python-mt.dylib]} {
> depends_lib-delete port:boost
> pre-configure {
> ui_error "
> ****
> **** ${name} requires port boost installed with variant +python26.
> **** Please do the following then try installing ${name} again:
> ****
> **** sudo port install boost +python26
> ****
>
> "
> return -code error "incompatible boost installation"
> }
> }
>
>
> The idea is that boost will only install the file ${prefix}/lib/libboost_python-mt.dylib if configured with python support. If that file is not there, either the user has not installed boost at all, or they have already installed it but without python support. Either way, we delete the boost dependency (so that, if the user doesn't already have boost at all, MacPorts will not spend a lot of time building a pythonless boost before producing the error message) and tell the user what to do to proceed.
>
> In fact, this seems slightly incomplete: I'll bet boost would also install that file with its python27 variant, which would not work well for PlasmaClient because it has other python26-based dependencies. So it is important to pick a special file or pkg-config capability that is really unique to the desired variant.
>
>
The problem is that in our case, it's very unlikely that the user will have any variant of the subject port installed at the time he installs the metaport. However, if you install the subject port via lib_depend, the "wrong" variant gets selected. That's what I'm trying to avoid. Looks like there's no way to do this, so we're going to have to go "meta-meta" - use Platypus to wrap a couple of commands, one of which installs the "correct" variant explicitly, and the next one of which installs the (rest of the) metaport.
This isn't a very good solution. Alternatives welcome.
Mike O'Brien
The Aerospace Corporation
More information about the macports-dev
mailing list