thatch(n) 0.4 thatch "Thatch"

Name

thatch - Thatch

Table Of Contents

Synopsis

  • package require Tcl 8.5
  • package require thatch ?0.4?

Description

Thatch (Tcl Attach) attaches files together, separated with ^Z to make a single "executable" script.

The purpose of Thatch is to create standalone scripts, "final products", ready to be run anywhere Tcl and/or Tk is available.

The idea is to package all the sources for a program plus the sources for all the Tcl extensions used by the program plus any other resources needed by the program into the "final product".

Thatch can work like an archive but that isn't its purpose. Thatch might look like a VFS but it isn't.

A thatched file isn't really meant to be changed once it's created.

Thatch can handle extensions that use pkgIndex.tcl files, tclIndex files and Tcl module (*.tm) files

Thatch normally stores files as text but Thatch can be told to base64 encode a file so images etc. can be used.

Thatch can use checksums on files.

When running a thatched program, Thatch will normally override file,glob,source, and image. These can be disabled when calling thatchSetup.

Overrides behave almost exactly like the commands they override.

Internally, Thatch doesn't understand directories it matches filenames.

Modifying a thatched file with thatch is a stream-like operation. Thatch will traverse the file, copying input to output, skipping removals and adding new files.

If a thatched file is all text then it can be modified with a text editor. As long as there are no size or checksum attributes this will work. In the line above the file that starts with "# THATCH", simply delete any size or checksum attributes and their values.

If using checksumming, make sure to add the necessary files from the Tcllib extensions.

If using base64, files from Tcllib are needed if there is a chance that the thatched program will be run under a Tcl that doesn't have base64.

TODO:

Thatch currently works well and is stable for basic usage. Improvement is still needed in all areas, especially documentation.

The glob override may be problematic. Suggest using -noglob for now unless really needed.

Thatchtool gui is imperfect when modifying thatched files.

STRUCTURE

A "thatched" file structure.
Basic:
+---------+
|  Boot   |
+---------+
| Thatch  |
+---------+
| Blob(s) |
+---------+
Detailed:
+ Preamble & Boot
|
|   Preamble (sh)
|     The first line(s) at the top of the file
|     that exec tclsh, wish or whatever your style is.
.
|   Boot (Tcl)
|    Boot is responsible for loading and initializing Thatch.
|      Load:
|        Open [info script],
|        read to and skip over the first ^Z (skip ourselves),
|        the blob from that point to the next ^Z should be Thatch.
|        Read the blob and [uplevel #0] it.
|      Initialize:
|        Call ::thatch::thatchSetup [info script] {*}$options.
|
|    The example and thatchtool-generated boot assume that Thatch is in plain text.
+
| ^Z
+
| Thatch
+
| ^Z
+
| File 1
+
| ^Z
+
| File 2
+
| ^Z
+
| File n
+
| EOF or ^Z EOF

Keywords

app

Category

App building tools