tpack - Tcl script packer - Manual
There are two versions currently of that script: tpack-tar.tcl which should work on Tcl 8.5 and Tcl 8.6 and tpack-b64.tcl which should work with Tcl 8.5, 8.6 and 9.0 in principle. For Tcl 8.4 enabled version see here.
### single file apps
tpack wrap APPNAME.tapp
tpack wrap APPNAME.tapp --lz4
./APPNAME.tapp
For instance for an application mini.tapp, you need a file mini.tcl and a folder mini.vfs with the following structure:
lib main.tcl
Where lib contains the Tcl packages your application needs and main.tcl look usually like this:
### file: mini.vfs/main.tcl
lappend auto_path [file join [file dirname [info script]] lib]
See the samples folder for an example of such a mini-application and other example applcations.
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/lib. 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 can create standalone applications containing some tar-file loader, the application code from app.tcl and and the library code from app.vfs.
Installation of the created application is than easy:
- rename app.tapp to app.bin or just app
- make it executable
- move it to a directory belonging to your PATH variable
In case of two file applications:
- make the file app.ttcl executable
- copy the files app.ttcl and app.ttar to a directory belonging to your PATH variable
Installation of the tpack executable itself is as well easy, just copy the file tpack.tcl as tpack to a folder belonging to your PATH variable.
Here an example on how to do that on a Linux system using wget:
wget https://raw.githubusercontent.com/mittelmark/tpack/main/tpack-b64.tcl -O tpack.tcl
chmod 755 tpack.tcl
mv tpack.tcl ~/bin/tpack
tpack --version
0.7.1
Here a comparison table between three deployment strategies:
| Deployment | files | Compression | Tclkit 8.4** | Tclkit 8.5 | Tclkit 8.6 | Tcl 8.4** | Tcl 8.5 | Tcl 8.6 | Tcl 9.0 |
|---|---|---|---|---|---|---|---|---|---|
| starkit | 1 | yes | yes | yes | yes | no | no | no | no |
| zipkit | 1 | yes | no | no | no | no | no | no | yes |
| tpack | 1,2 | yes* | yes | yes | yes | yes | yes | yes | yes |
*tpack can use the lz4 application to compress the script, and at runtime decompress the script without this executable. So lz4 compression with tpack requires an lz4 executable during file creation and at least Tcl 8.5 at runtime to unpack the code in the background before execution.
Before you deliver the tpack application files you can obviously compress them yourself using gzip, zip or other tools.
Tcl/Tclkit 8.4 requires version of tpack before version 0.4.0 which you can retrieve from here
- mndoc - source code documentation tool
- tmdoc - literature programming with Tcl
- mkdoc - source code documentation tool (archived, see mndoc)
- pantcl - reporting tool for literate programming as pandoc filter
- 2025-01-07: v0.7.1 fix for Windows not having variable USER but USERNAME
- 2025-10-26: v0.7.0 tmp folder multiuser fix for the same application on the same same machine
- 2025-10-13: v0.6.0 compression level set to 9 as lz4 v1.10 seems to have lower default
- 2025-01-03: v0.5.0 switched default from tar to base64 as the code storage as tar code had some issues
- 2025-01-01: v0.4.0 starting support for Tcl 9
BSD 3-Clause License
Copyright (c) 2021-2025 Detlef Groth tpack code
Copyright (c) 2017 dbohdan pur Tcl lz4 decompression code
Copyright (c) 2013 Andreas Kupries andreas_kupries(at)users.sourceforge(dot)net (tar code)
Copyright (c) 2004 Aaron Faupell afaupell(at)users.sourceforge(sot)net (tar code)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.