Placing packages in a starkit

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":

        tcllib.vfs/
        tcllib.vfs/lib/
        package require starkit
        if {[starkit::startup] eq "sourced"} return
        # code here would be called when launched as app
        cp -a $HOME/mylib/lib/tcllib1.3 tcllib.vfs/lib/.
        tcllib.vfs/
        tcllib.vfs/main.tcl
        tcllib.vfs/lib/
        tcllib.vfs/lib/tcllib1.3/...
        source tcllib.vfs/main.tcl
        sdx wrap tcllib.kit
        source tcllib.kit

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.