tpack


Name

tpack - - tar file based deployment system for Tcl applications, supports Tcl 8.4, 8.5, 8.6, 8.7 without any additional libraries on all platforms

Usage

$ tpack wrap APPNAME.tcl APPNAME.vfs

Creates APPNAME.ttcl, the application, and APPNAME.ttar containing your library(ies).

Description

DDG 2021-09-13: tpack is a Tcl script which can be used to deploy your Tcl application to other computers and users. It is not a virtual file system approach. During the first application run files will be installed in a temporary directly and used from there. Unpacking of files will be redone automatically if the files in the program folder are newer than those files in the temporary folder. As input you give your application file app.tcl and a folder containing your libraries app.vfs. The folder structure is the same as for the starkit approach, by careful design of the file app.vfs/main.tcl the same folder can be as well used to for building starkits and tarkits. The script tpack.tcl creates from the file app.tcl a file app.ttcl containing the required parts from the tar library of tcllib to untar tar files and at the end your application code. From the folder app.vfs a tar archive with the extension .ttar is created: app.ttar. To deploy your application those two files has to be copied to the other computer, the file app.ttcl can be as well renamed to let's say app.bin or even app as long as app.ttar is in the same folder like the ttcl file.

Comparison

Here a comparison table between three deployment strategies:

DeploymentfilesCompressionTclkit 8.4Tclkit 8.5Tclkit 8.6Tclkit 8.7Tcl 8.4Tcl 8.5Tcl 8.6Tcl 8.7
starkit1yesyesyesyesyesnononono
zipkit1yesnononoyesnononoyes
tarkit2noyesyesyesyesyesyesyesyes

Links

Example

Here is an example for a minimal application consisting of some application file mini.tcl and a folder mini.vfs with some small library test:

## FILE mini.tcl
#!/usr/bin/env tclsh
package require test
puts mini
puts [test::hello]

## FILE mini.vfs/main.tcl
lappend auto_path [file join [file dirname [info script]] lib]

## FILE mini.vfs/lib/test/pkgIndex.tcl
package ifneeded test 0.1 [list source [file join $dir test.tcl]]

## FILE mini.vfs/lib/test/test.tcl
package require Tcl
package provide test 0.1
namespace eval ::test { }
proc ::test::hello { } { puts "Hello World!" }

Such a sample application can be downloaded here: https://github.com/mittelmark/DGTcl/blob/master/apps/tpack/tpack-sample.zip

You can then create your two files using the following commandline:

tpack wrap mini

This will create the files mini.ttcl and mini.ttar which are the files you need to deploy on your computer which should have an existing Tcl installation as prerequisite. For more details consult the manual at http://htmlpreview.github.io/?https://github.com/mittelmark/DGTcl/blob/master/apps/tpack/tpack.html


See also

  • starkit - standard Tclkit approach since Tcl 8.4
  • zipkit - the new zip file based approach since Tcl 8.7
  • tarpack for deploying multi-file libraries as single file Tcl-modules.

Discussion

DDG - 2021-09-13: My motivation was that Tcl 8.7 is not yet released and Tclkit based deployment to Windows requires often ignoring Virus-scan messages by the users. So I gave this purely Tcl only Tar file based approach a trial. With 8.7 certainly the zipkit way would be the certainly the better one as it offers compression and other more sophisticated possibilities.