Invoking tcl

View: New views
7 Messages — Rating Filter:   Alert me  

Invoking tcl

by Lists :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to do some scripting in tcl for a port file that is a  
little out of the norm for what is needed in most ports.

How do I invoke tcl in a sample script?

In bash, I would create a new file, enter the shebang of #!/bin/bash  
and go at it.  I honestly can not find tcl on my system.

`which`, `whereis` return nothing.
--
Scott * If you contact me off list replace talklists@ with scott@ *

_______________________________________________
macports-dev mailing list
macports-dev@...
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

Re: Invoking tcl

by Jeremy Lavergne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

tclsh

On Nov 4, 2009, at 5:44 PM, Scott Haneda wrote:

> I am trying to do some scripting in tcl for a port file that is a  
> little out of the norm for what is needed in most ports.
>
> How do I invoke tcl in a sample script?
>
> In bash, I would create a new file, enter the shebang of #!/bin/bash  
> and go at it.  I honestly can not find tcl on my system.
>
> `which`, `whereis` return nothing.



_______________________________________________
macports-dev mailing list
macports-dev@...
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

smime.p7s (5K) Download Attachment

Re: Invoking tcl

by Lists :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for setting me straight on the tcl and tclsh ting

I am working on taking a large list of variants, and generating the  
conflicts dynamically.  The below works, but I think I need to eval it  
is in some way to get ports to recognize it.

set variants {english french spanish japanese dutch}

foreach variant_name $variants {
      # Quick way to remove the working variant from the list
      set no_conflicts [lsearch -all -inline -not -exact $variants  
$variant_name]
      set a [subst {variant $variant_name conflicts $no_conflicts  
description "Use $variant_name for server messages" {
                configure.args-append --with-language=$variant_name }
      }]
      puts $a
}

Better representation here: http://pastie.org/684447

Here is what it is printing out output
http://pastie.org/684449

Which I could copy and paste into the portfile, but I want to be more  
dynamic abut it.  I have tried this previous example a few ways, and  
am not getting it:

# Add langugage variants
foreach {language arg} ${languages} {
    set variant lang_[strsed ${arg} {g/-/_/}]
    set conflicts {}
    foreach {ignore conflicting_arg} ${languages} {
        if {${conflicting_arg} != ${arg}} {
            set conflicting_variant lang_[strsed ${conflicting_arg}  
{g/-/_/}]
            lappend conflicts ${conflicting_variant}
        }
    }
    eval [subst {
        variant ${variant} conflicts ${conflicts} description "Use $
{language} language for server messages" {
            configure.args-append   --with-language=${arg}
        }
    }]
}

Yes, I can go with the existing code, but I seem to understand the one  
I wrote, and it seems to be shorter, and better tailored to this  
case.  Thanks for any pointers.  tcl is a weird language.
--
Scott * If you contact me off list replace talklists@ with scott@ *
_______________________________________________
macports-dev mailing list
macports-dev@...
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

Re: Invoking tcl

by Lists :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Any takers?  This is the last thing from getting me to port  
submission, or I can go the sloppy way and allow copy and paste, which  
makes the portfile about 50 lines more than it need be.

Thanks all.
--
Scott * If you contact me off list replace talklists@ with scott@ *

On Nov 4, 2009, at 10:43 PM, Scott Haneda wrote:

> Thanks for setting me straight on the tcl and tclsh ting
>
> I am working on taking a large list of variants, and generating the  
> conflicts dynamically.  The below works, but I think I need to eval  
> it is in some way to get ports to recognize it.
>
> set variants {english french spanish japanese dutch}
>
> foreach variant_name $variants {
>     # Quick way to remove the working variant from the list
>     set no_conflicts [lsearch -all -inline -not -exact $variants  
> $variant_name]
>     set a [subst {variant $variant_name conflicts $no_conflicts  
> description "Use $variant_name for server messages" {
>               configure.args-append --with-language=$variant_name }
>     }]
>     puts $a
> }
>
> Better representation here: http://pastie.org/684447
>
> Here is what it is printing out output
> http://pastie.org/684449
>
> Which I could copy and paste into the portfile, but I want to be  
> more dynamic abut it.  I have tried this previous example a few  
> ways, and am not getting it:
>
> # Add langugage variants
> foreach {language arg} ${languages} {
>   set variant lang_[strsed ${arg} {g/-/_/}]
>   set conflicts {}
>   foreach {ignore conflicting_arg} ${languages} {
>       if {${conflicting_arg} != ${arg}} {
>           set conflicting_variant lang_[strsed ${conflicting_arg}  
> {g/-/_/}]
>           lappend conflicts ${conflicting_variant}
>       }
>   }
>   eval [subst {
>       variant ${variant} conflicts ${conflicts} description "Use $
> {language} language for server messages" {
>           configure.args-append   --with-language=${arg}
>       }
>   }]
> }
>
> Yes, I can go with the existing code, but I seem to understand the  
> one I wrote, and it seems to be shorter, and better tailored to this  
> case.  Thanks for any pointers.  tcl is a weird language.

_______________________________________________
macports-dev mailing list
macports-dev@...
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

Re: Invoking tcl

by Jordan K. Hubbard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, I read your message a couple of times and still don't really see a question in there anywhere.  What specifically are you asking?

- Jordan

On Nov 5, 2009, at 8:09 PM, Scott Haneda wrote:

> Any takers?  This is the last thing from getting me to port submission, or I can go the sloppy way and allow copy and paste, which makes the portfile about 50 lines more than it need be.
>
> Thanks all.
> --
> Scott * If you contact me off list replace talklists@ with scott@ *
>
> On Nov 4, 2009, at 10:43 PM, Scott Haneda wrote:
>
>> Thanks for setting me straight on the tcl and tclsh ting
>>
>> I am working on taking a large list of variants, and generating the conflicts dynamically.  The below works, but I think I need to eval it is in some way to get ports to recognize it.
>>
>> set variants {english french spanish japanese dutch}
>>
>> foreach variant_name $variants {
>>    # Quick way to remove the working variant from the list
>>    set no_conflicts [lsearch -all -inline -not -exact $variants $variant_name]
>>    set a [subst {variant $variant_name conflicts $no_conflicts description "Use $variant_name for server messages" {
>>              configure.args-append --with-language=$variant_name }
>>    }]
>>    puts $a
>> }
>>
>> Better representation here: http://pastie.org/684447
>>
>> Here is what it is printing out output
>> http://pastie.org/684449
>>
>> Which I could copy and paste into the portfile, but I want to be more dynamic abut it.  I have tried this previous example a few ways, and am not getting it:
>>
>> # Add langugage variants
>> foreach {language arg} ${languages} {
>>  set variant lang_[strsed ${arg} {g/-/_/}]
>>  set conflicts {}
>>  foreach {ignore conflicting_arg} ${languages} {
>>      if {${conflicting_arg} != ${arg}} {
>>          set conflicting_variant lang_[strsed ${conflicting_arg} {g/-/_/}]
>>          lappend conflicts ${conflicting_variant}
>>      }
>>  }
>>  eval [subst {
>>      variant ${variant} conflicts ${conflicts} description "Use ${language} language for server messages" {
>>          configure.args-append   --with-language=${arg}
>>      }
>>  }]
>> }
>>
>> Yes, I can go with the existing code, but I seem to understand the one I wrote, and it seems to be shorter, and better tailored to this case.  Thanks for any pointers.  tcl is a weird language.
>
> _______________________________________________
> macports-dev mailing list
> macports-dev@...
> http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

_______________________________________________
macports-dev mailing list
macports-dev@...
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

Re: Invoking tcl

by Lists :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Doing this sucks:

variant lang_brazilian             description "Use Brazilian language  
for server messages" { configure.args-append --with-language=brazilian }

variant lang_czech                 description "Use Czech language for  
server messages" { configure.args-append --with-language=czech }

repeat 15 more times...
it also does not add in the fact that one language is going to  
conflict with another.

So I made a tcp iteration that generated the correct code for the  
portfile from a list.  I can copy the output into the file, but would  
rather it eval in place.

I can not get the eval to work when I run port variants pure-ftpd, it  
just ignores it.
--
Scott * If you contact me off list replace talklists@ with scott@ *

On Nov 6, 2009, at 6:10 PM, Jordan K. Hubbard wrote:

> Well, I read your message a couple of times and still don't really  
> see a question in there anywhere.  What specifically are you asking?

_______________________________________________
macports-dev mailing list
macports-dev@...
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

Re: Invoking tcl

by Jordan K. Hubbard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Nov 6, 2009, at 6:24 PM, Scott Haneda wrote:

> Doing this sucks:
>
> variant lang_brazilian             description "Use Brazilian language for server messages" { configure.args-append --with-language=brazilian }
>
> variant lang_czech                 description "Use Czech language for server messages" { configure.args-append --with-language=czech }

And how many ports do that?  I mean, if this pattern is pervasive across the collection then you probably want to create some sort of "lang" procedure which sets the appropriate configure args and checks an internal variable to see if two languages have been specified in conflict.  Otherwise, you'd still have to stick the same work procedure into each Portfile that wanted to use it, so I'm not sure how much it would save you unless each port also declared such variants multiple times.

> I can not get the eval to work when I run port variants pure-ftpd, it just ignores it.

Well, variant is itself a procedure and it's probably not going to eval its arguments in the way you want, unless you mean something else here...  Otherwise, you can insert any Tcl code you like into a Portfile and it will run if called through one of the existing hooks, so a hook proc could always create an expression dynamically and eval that, if that's what you want...

- Jordan
_______________________________________________
macports-dev mailing list
macports-dev@...
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev