darwinports_fastload source iteration

Paul Guyot pguyot at kallisys.net
Wed Jan 24 15:48:33 PST 2007


Le 24 janv. 07 à 07:12, Kevin Ballard a écrit :

> Hrm, nobody has responded. I guess nobody cares?
>
> If I don't hear anything back in the next few days, I'll go ahead  
> and commit the change.

I wrote those lines because we use readdir native command through  
MacPorts instead of glob. I don't know why, but I thought there was a  
good reason for the presence and use of a native replacement. Maybe  
when the readdir command was developed, it was in the Tcl 8.2.x area  
and glob didn't take the -directory option. Or the glob function from  
the Tcl version that shipped with a supported release of MacOS X was  
buggy or horribly slow.

>> I was just poking around and in darwinports_fastload.tcl.in I  
>> discovered the following:
>>
>> # I could iterate on the directory, but the only way I know in Tcl  
>> involves a
>> # native function we provide in pextlib.
>> set dir [file join "@prefix_expanded@" share darwinports Tcl port1.0]
>> catch {source [file join $dir pkgIndex.tcl]}
>> set dir [file join "@prefix_expanded@" share darwinports Tcl  
>> package1.0]
>> catch {source [file join $dir pkgIndex.tcl]}
>> set dir [file join "@prefix_expanded@" share darwinports Tcl  
>> pextlib1.0]
>> catch {source [file join $dir pkgIndex.tcl]}
>> set dir [file join "@prefix_expanded@" share darwinports Tcl  
>> registry1.0]
>> catch {source [file join $dir pkgIndex.tcl]}
>>
>> It's actually rather trivial to do this iteration - that block can  
>> be replaced with:
>>
>> foreach dir [glob -directory "@prefix_expanded@" -join share  
>> darwinports Tcl *] {
>>     catch {source [file join $dir pkgIndex.tcl]}
>> }
>>
>> Should I go ahead and commit this change?

Now, to answer this question:

>> Incidentally, this will source darwintrace1.0/pkgIndex.tcl (which  
>> the manual sourcing doesn't), but I looked in that file and it's  
>> just comments, so it won't make a difference. I am curious as to  
>> what darwintrace1.0 is for, since it doesn't provide any packages  
>> in pkgIndex.tcl.

Indeed, darwintracelib1.0 doesn't have a pkgIndex.tcl file, and this  
is on purpose. The code and the comment above were written before  
darwintracelib. This package doesn't provide anything Tcl uses  
directly. Instead, it provides a native library used with library  
injection mechanism for the implementation of the trace mode. See port 
(1) for documentation on the trace mode (enabled by -t).

Paul




More information about the macports-dev mailing list