tcl expert needed

Bjarne D Mathiesen macintosh at mathiesen.info
Sun Jun 3 07:52:59 PDT 2012


Ryan Schmidt wrote:
> 
> On Jun 2, 2012, at 18:34, Bjarne D Mathiesen wrote:
> 
>> Jeremy Lavergne wrote:
>>>> I've got a problem where the same action has to be done, but depending
>>>> on whether I'm in /post-destroot/ or /post-activate/ I need to create
>>>> and install in different directories
>>>
>>> That's precisely what the post-destroot and post-activate blocks do: they execute during post-destroot phase or post-activate phase, respectively.
>>
>> I know that, but can I query a variable or something that tells me
>> exactly which phase I'm in ???
> 
> Not that I know of.
> 
>> eg :
>>
>> proc doSomething args {
>>    switch ${phase} {
>>    "destroot"      -
>>    "post-destroot" { set where "destroot" }
>>    "activate"      -
>>    "post-activate" { set where "" }
>>    }
>>    xinstall -d ${where}[dict get ${apache} libexecdir]
>>    /do a lot of stuff/
>> }
> 
> What is the specific task you're going to do? Depending on the task, you probably want to either always do it in destroot, or always in activate; I can't think of a case where you'd want to make that dependent on some situation.

I've got this piece of actual code :

+++ code start +++
#
# mimics installation via apxs, but under Debian/Ubuntu layout
# which renders apxs useless for activating modules
# has been made simpler as we always starts with a clean slate
#
# expanded functionality compared to apxs:
#   ++ optionally installs dylibs
#
proc apxsInstall { moduleName activate dylibs } {
    global apache destroot prefix

    xinstall -m 0755 -d -W ${destroot}[dict get ${apache} sysconfdir] \
        mods-available  mods-enabled

    # strip pre-/suffix from moduleName
    set moduleName [regsub {_module} ${moduleName} "" ]
    set moduleName [regsub {mod_}    ${moduleName} "" ]

    set  loadFileName   [dict get ${apache}
sysconfdir]/mods-available/${moduleName}.load
    set  loadFile       [open ${loadFileName} w 644]

    foreach libName ${dylibs}  {
        set  dylibFile   [ exec find ${prefix}/lib -type f -iname
"lib${libName}*.dylib" ]
        puts ${loadFile} "LoadFile ${dylibFile}"
    }

    puts  ${loadFile} "LoadModule ${moduleName}_module [dict get
${apache} libexecdir]/mod_${moduleName}.so"

    close ${loadFile}

    if { ${activate} == "yes" } {
            exec "[dict get ${apache} sbindir]/a2enmod" ${moduleName}
    }

}
+++ code end +++

I just thought it would be nice having the option of either using it in
destroot or install.

But I've settled on destroot as the most proper place.

:-)
-- 
Bjarne D Mathiesen
København N ; Danmark ; Europa
----------------------------------------------------------------------
denne besked er skrevet i et totalt M$-frit miljø
MacOS X 10.7.3 Lion ; 2.8GHz Intel Core i7 ; 16GB 1067MHz DDR3


More information about the macports-dev mailing list