Using outside values in a Portfile tcl

Ryan Schmidt ryandesign at macports.org
Fri Sep 20 23:33:03 UTC 2019



On Sep 20, 2019, at 10:37, Gerben Wierda wrote:

> The mail-server Portfile has this in it:
> 
> # Network configuration
> # hard-coded examples
> set host     		host
> set domain		domain
> set tld			tld
> set fullhost		${host}.${domain}.${tld}
> set domaintld		${domain}.${tld}
> set HOST                [string toupper ${host}]
> set DOMAIN     		[string toupper ${domain}]
> set TLD        		[string toupper ${tld}]
> set FULLHOST		[string toupper ${fullhost}]
> set DOMAINTLD           [string toupper ${domaintld}]
> set relayhost           mymailrelay.tld
> 
> Now,  obviously, my system isn’t called host.domain.tld or the relayhost mymailrelay.tld.
> 
> Is there a way I can influence these variables from the ‘outside’, so by using envrionment variables or by providing them in some way with the 'port install’ command?

The way that's written, no. It sets the variables. It does not allow specifying them from the outside. You could run:

sudo port install mail-server host=example.com

but it would have no effect. The portfile would overwrite any values set from outside the portfile.

To support what you're proposing, the portfile would need to check whether each/any of those variables are already set before setting them.

We don't usually allow ports to accept customization via variables like this. If we wanted to support it, then at least the port would have to make sure that it disabled the use of any precompiled archives (by clearing the archive_sites variable) so that it did not download an archive from our server that would know nothing about the variable changes you make on the command line.



More information about the macports-users mailing list