Last Updated: July 12, 2019

Deploying Tcl Applications with Starpacks

Finally your software is complete! Ready to leave the nest of your development environment, spread its wings, fly into the wide world of unpredictable user environments… and crash.  Deployment: the bane of software developers.

All of the subtle and not-so-subtle dependencies your application has on things in your development environment don’t necessarily carry over to the end users. Particularly the important parts: the packages, the runtime, the data files, and what-not.

Cue “wrapping”, the method of choice for Tcl applications.

Take the interpreter, the packages (binary and pure Tcl), the data files, and put them into a single new file: the application executable. All the dependencies are satisfied, carried within that one file and independent of the system environment (e.g. the user’s own, incompatible Tcl installation).

Installation is via copying, un-installation via deletion.

Of the various methods developed over the years (freewrap, mktclapp, prowrap), ActiveState chose starpacks, both as the method to support the tools in our Tcl Dev Kit, and as the way these tools are packaged themselves.

Built on top of the virtual filesystem support added to the Tcl core in the 8.4 development cycle eight years ago, a slightly modified runtime, called a basekit or tclkit, accesses a metakit database attached to it as if it were a regular filesystem. All file commands work, and everything built on top of them–including Tcl’s package management. While some care is needed to run the application both wrapped and unwrapped, the changes are minimal and done only once, in the startup.

The above description also provides the major reason for us choosing this technology. All the other methods are based on custom hacks of and patches to the Tcl library. Starpacks are based on public APIs and need only a bit of custom building for the creation of their basekit runtimes, and even there only the public APIs of the core are used to achieve the customized startup looking for and initializing access to the attached filesystem.

Tcl Dev Kit’s main tool for packaging Tcl applications is TclApp, a graphical front-end to the core functionality of wrapping files and packages into starpacks. The virtual filesystem explorer, TclVFSE for short, is a supporting tool for examining starpacks and their contents. The TDK has a 21 day trial, so you can try these tools out for yourself and see if they fit your needs.

Title photo courtesy of Iftikhar Shah on Unsplash.

Andreas Kupries

Andreas Kupries

Andreas Kupries is a senior Tcl developer at ActiveState where his focus is the ActiveTcl distribution. He also works on the Tcl Dev Kit component of ASPN Tcl. Andreas is a member of the Tcl Core Team. He's the Tcllib release manager and has authored more than 25 Tcl modules and extensions! He has a Master in Computer Science from the RWTH Aachen.