internal-to-Portfile variable during upgrade?

Rainer Müller raimue at macports.org
Thu Jul 8 01:39:40 PDT 2010


On 07/07/2010 10:37 PM, Michael Dickens wrote:
> I can set up the Portfile to default to using, say, "qt4-mac" by either
> (1) setting variable defaults such that this is the case, and then
> changing those variables when variants are selected; or (2) by creating
> a bunch of variants and then setting "default_variants".  I can convince
> 'port' to do either of the those properly -- except solely during
> 'upgrade', which seems to ignore anything except the default settings
> (i.e., variants are not fully executed).  Looking through the debug
> output, I can see comments such as "Merging existing variants '+qt4'
> into variants" and "Executing variant qt4 provides qt4" ... but the
> variants do not seem to be being honored, at least with respect to
> setting my ${qt_dir} variable -- it always comes out as the default
> setting (which, because of the way I've written the Portfile, is "").

As variants are treated like procs, they have their own scope. A simple
'set' is in the local scope only and therefore does not change the
variable outside. You can use the 'global' keyword to make variable
available everywhere.

set foo ""

variant a {
    global foo
    set foo a
}

variant b {
    global foo
    set foo b
}

Rainer


More information about the macports-dev mailing list