checking for swig variants in a pre-fetch hook

Joshua Root jmr at macports.org
Fri Jul 4 08:23:40 PDT 2008


Adam Mercer wrote:
> On Fri, Jul 4, 2008 at 1:38 AM, Joshua Root <jmr at macports.org> wrote:
> 
>> Changing the if line to this should do it:
>>
>> if {![llen [glob ${prefix}/share/swig/*/python/python.swg]]} {
> 
> Using the above line only half works if a file doesn't satisfy the
> above pattern port errors out straight away, the different ui_error
> messages aren't displayed. I have the following in a pre-fetch hook:
> 
> pre-fetch {
>   if {![llen [glob ${prefix}/share/swig/*/python/python.swg]]} {
>     ui_error "The python variant of swig is not installed. Please run"
>     ui_error "the following commands:"
>     ui_error "$ sudo port uninstall swig"
>     ui_error "$ sudo port install swig +python"
>     error "python variant of swig required"
>   }
> }
> 
> then the only thing displayed on error is:
> 
> --->  Fetching py25-scipy
> Error: Target org.macports.fetch returned: no files matched glob
> pattern "/opt/local/share/swig/*/python/python.swg"
> Error: Status 1 encountered during processing.
> 
> How can I get the messages to display?

Ah, sorry, I forgot that glob errors if nothing matches. Add -nocomplain:

if {![llen [glob -nocomplain ${prefix}/share/swig/*/python/python.swg]]}

- Josh


More information about the macports-dev mailing list