What happened to this site? And what's that frog about?

Placing packages in a starkit

From the old Equi4 Software site wiki 

Starkits make it easy to wrap up package collections and use them with one line of Tcl. Consider for example Kitten - all it takes to use kitten, is that one file called "kitten.kit" and a line in your application: source /path/to/kitten.kit

The reason this works, is because kitten has been set up to mount and extend auto_path when sourced, and then return.

Here's an example of setting up a starkit with all of the packages of tcllib in it, to be called "tcllib.kit":

    • create the following two directories:
        tcllib.vfs/
        tcllib.vfs/lib/
    • create a file called "tcllib.vfs/main.tcl" with these lines in it:
        package require starkit
        if {[starkit::startup] eq "sourced"} return
        # code here would be called when launched as app
    • get a copy of tcllib, and install it in a temp area, say "--prefix=$HOME/mylib/"
    • copy this to the proper spot:
        cp -a $HOME/mylib/lib/tcllib1.3 tcllib.vfs/lib/.
    • (the reason for this indirect approach is to avoid also getting man pages, etc)
    • so what you have now, should be:
        tcllib.vfs/
        tcllib.vfs/main.tcl
        tcllib.vfs/lib/
        tcllib.vfs/lib/tcllib1.3/...
    • to test in unwrapped mode, include this in your application script:
        source tcllib.vfs/main.tcl
    • that's all (you need Tclkit or a recent ActiveTcl for the "starkit" package)
    • when you've verified that it works, wrap it up using SDX:
        sdx wrap tcllib.kit
    • change the source call in your application to:
        source tcllib.kit
    • again, that's it...

One convenience worth mentioning, is to make your app load the starkit if present, or unwrapped otherwise, i.e.:

        if {[file exists tcllib.kit]} {
          source tcllib.kit
        } elseif {[file exists tcllib.vfs/main.tcl]} {
          source tcllib.vfs/main.tcl
        }

(to see the effect this has, have a look at the value of "$auto_path" at this point)

Even if you need shared libraries in there, the essence of the above structure does not really change. Put them inside and make the "load" command go to the right path. To support multiple platforms, you'll need to load different shared lib versions, but again the logic is identical - and can be tested unwrapped first, and wrapped later.





Powered by Mavrig