setting variants on the fly

Ryan Schmidt ryandesign at macports.org
Wed Nov 21 20:34:52 PST 2007


On Nov 21, 2007, at 06:55, Markus Weissmann wrote:

> On Wed, 2007-11-21 at 06:17 -0500, Randall Wood wrote:
>
>> Is it possible?
>>
>> What I would like to do is be able to test either that a dependency
>> was installed with a certain variant or that a file exists and then
>> set a variant on the port being installed based on that information.
>>
>> Background:
>> I am reworking the gtk2 port so that it can be installed without X11.
>> What I want to be able to do is have "sudo port install gtk2" work
>> correctly, installing gtk2 with the correct variants for the machine
>> its being installed on without user intervention or complaint.
>
> I didn't try to hack a Portfile to do this, so no idea; if these are
> common tests, we could include them in port(1) like with the platform
> and architecture variants.
>
> Depending on a variant of a port to be installed will create a big  
> mess
> and is imho a bad idea:
> If A requires C1, B requires C0 and C1 conflicts with C0 you're stuck.
> I'd like to avoid having this kind of conflicts in the first place by
> _not_ relying on variants. If it is crucial for a port to have  
> something
> installed in a "non-standard" way, either create a new port that takes
> the non-standard options or try to make your requirements the defaults
> for the dependencies.
> A good example I just recently saw are the smlnj/smlnj-dev ports which
> can both be installed simultaneously (different versions); ncurses and
> ncursesw als come to my mind here.

I think Randall is going for something like this: gtk2 can use either  
x11 or quartz libraries. He would like to be able to detect which of  
these is already installed and select the correct variant of gtk2  
automatically. And if neither x11 nor quartz is installed, then he  
would like to use, let's say x11. I hope I've understood the request  
correctly. If so, I think this can be done.  Something like:

if {quartz is available} {
	default_variants +quartz
} else {
	default_variants +x11
}

"quartz is available" could be implemented by looking whether a  
specific file is present ("if {[file exists somefile]} {...}"). Or,  
it could be implemented by checking if a particular port is installed  
("if {![catch {registry_active someport}]} {...}").



More information about the macports-dev mailing list