Updated 2018-06-22 04:17:43 by Stu

Thatch - Tcl Attach

Create standalone Tcl/Tk apps.

Thatch can be found at https://chiselapp.com/user/stwo/repository/thatch

  • Stu 2018-06-21 Version 0.3. (New: Compression)
  • Stu 2018-06-11 Version 0.2.
  • Stu 2018-05-25 Version 0.1.

Standalone TkChat runtime+installer made with Thatch and SIFT: tkchat-1.482.zip

See also the example on this page.

Page history:

  • Stu 2018-06-11 Added TkChat example.
  • Stu 2018-05-25 Created this page.

Thatch

Rough Doc

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 is a stream-like operation.
Thatch will traverse the file, copying input to output,
skipping removals and adding new files.

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

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.

Making a standalone installable TkChat with Thatch and SIFT

# Shell script to build "thatched" TkChat.
# With optional SIFT installer.

# 1. Adjust vars to match your system.
# 2. Run this script: $ sh mktkchatthatch
#    You will now have a single-file TkChat
#    with optional installer.
# 3. If using SIFT to install, wish is mandatory:
#    $ ./tkchat-1.482.tcl --install ./tkchat-1.482.tcl /new/home/for/tkchat user group 755 /path/to/wish


V=1.482
TCLSH=tclsh8.6
WISH=wish8.6
THATCHTOOL=~/tcl/thatch/bin/thatchtool.tcl
THATCH=~/tcl/thatch/library/thatch.tcl
GET=wget
TAR=tar
SIFT=yes
OUT=tkchat-$V.tcl


rm -f $OUT

$GET http://tkchat.tcl.tk/files/tkchat-$V.kit
$GET http://www.equi4.com/pub/sk/readkit.tcl

if test X"$SIFT" = X"yes"; then
        preamble=''
        $GET http://www3.bell.net/stwo/software/sift-1.0.tar.gz
        $TAR xzf sift-1.0.tar.gz
        siftfile=sift/sift.installscript
        binpath=/usr/local/bin
        tclsh=$WISH
        name=tkchat
        filename=$OUT
        comment="TkChat - The Tcler's Chat."
        sed -e "s|%%name%%|$name|g ; s|%%filename%%|$filename|g ; s|%%comment%%|$comment|g ; s|%%binpath%%|$binpath|g ; s|%%tclsh%%|$tclsh|g" < $siftfile > $OUT
else
        preamble='-wb'
        > $OUT
fi

$TCLSH readkit.tcl -x tkchat-$V.kit

$THATCHTOOL \
        -c \
        -o - \
        -m /tkchat.tcl \
        $preamble \
        -tb \
        $THATCH \
        -home ./tkchat-$V.vfs/bin -rehome / \
        certs.pem%base64 \
        mousewheel.tcl \
        tkchat.desktop \
        tkchat.ico%base64 \
        tkchat.svg \
        tkchat.tcl \
        tkchat48.gif%base64 \
        tkchat48.png%base64 \
        tkchat_clock.tcl \
        tkchat_console.tcl \
        tkchat_leo.tcl \
        tkchat_mjpeg.tcl \
        tkchat_mms.tcl \
        tkchat_power.tcl \
        tkchat_rss.tcl \
        tkchat_url.tcl \
        tkchat_whiteboard.tcl \
        tkchat_winico.tcl \
        images/network-offline.png%base64 \
        images/network-online.png%base64 \
        images/roster_away.png%base64 \
        images/roster_chat.png%base64 \
        images/roster_disabled.png%base64 \
        images/roster_dnd.png%base64 \
        images/roster_online.png%base64 \
        images/roster_xa.png%base64 \
        images/z_away.gif%base64 \
        images/z_chat.gif%base64 \
        images/z_disabled.gif%base64 \
        images/z_dnd.gif%base64 \
        images/z_online.gif%base64 \
        images/z_xa.gif%base64 \
        msgs/de.msg \
        msgs/en.msg \
        msgs/ru.msg \
        -rehome /packages \
        askleo/askleo.tcl \
        askleo/pkgIndex.tcl \
        choosefont/README \
        choosefont/choose_gtk.tcl \
        choosefont/choose_w32.tcl \
        choosefont/choosefont.tcl \
        choosefont/critcl.tcl \
        choosefont/pkgIndex.tcl \
        choosefont/Tcl/choosefont.tcl \
        choosefont/Tcl/dkf_chooseFont.tcl \
        choosefont/win32-ix86/choosefont.dll%base64 \
        picoirc/picoirc.tcl \
        picoirc/pkgIndex.tcl \
        rssrdr/pkgIndex.tcl \
        rssrdr/rssrdr.tcl \
        -home ./tkchat-$V.vfs/lib -rehome / \
        autoproxy/autoproxy.tcl \
        autoproxy/pkgIndex.tcl \
        autoscroll/autoscroll.tcl \
        autoscroll/pkgIndex.tcl \
        cmdline/cmdline.tcl \
        cmdline/pkgIndex.tcl \
        cmdline/typedCmdline.tcl \
        critcl/Config \
        critcl/critcl.tcl \
        critcl/pkgIndex.tcl \
        ffidl/ffidlrt.tcl \
        ffidl/libFfidl0.6.dylib%base64 \
        ffidl/pkgIndex.tcl \
        htmlparse/htmlparse.tcl \
        htmlparse/pkgIndex.tcl \
        idle/idle.tcl \
        idle/pkgIndex.tcl \
        iocpsock/iocpsock30.dll%base64 \
        iocpsock/pkgIndex.tcl \
        jabberlib/browse.tcl \
        jabberlib/caps.tcl \
        jabberlib/disco.tcl \
        jabberlib/groupchat.tcl \
        jabberlib/ibb.tcl \
        jabberlib/jabberlib.tcl \
        jabberlib/jlibhttp.tcl \
        jabberlib/jlibsasl.tcl \
        jabberlib/jlibtls.tcl \
        jabberlib/muc.tcl \
        jabberlib/pkgIndex.tcl \
        jabberlib/pubsub.tcl \
        jabberlib/roster.tcl \
        jabberlib/saslmd5.tcl \
        jabberlib/service.tcl \
        jabberlib/stanzaerror.tcl \
        jabberlib/streamerror.tcl \
        jabberlib/tinydom.tcl \
        jabberlib/wrapper.tcl \
        khim/ROOT.msg \
        khim/cs.msg \
        khim/da.msg \
        khim/de.msg \
        khim/en.msg \
        khim/es.msg \
        khim/khim.tcl \
        khim/pkgIndex.tcl \
        khim/pl.msg \
        khim/ru.msg \
        khim/uk.msg \
        log/log.tcl \
        log/pkgIndex.tcl \
        md5/md5x.tcl \
        md5/pkgIndex.tcl \
        platform/pkgIndex.tcl \
        platform/platform.tcl \
        platform/shell.tcl \
        sha1/pkgIndex.tcl \
        sha1/sha1.tcl \
        struct/graph.tcl \
        struct/matrix.tcl \
        struct/pkgIndex.tcl \
        struct/queue.tcl \
        struct/stack.tcl \
        struct/struct.tcl \
        struct/tree.tcl \
        style/as.tcl \
        style/lobster.tcl \
        style/pkgIndex.tcl \
        style/style.tcl \
        tcllibc/critcl.tcl \
        tcllibc/pkgIndex.tcl \
        tclxml3.1/pkgIndex.tcl \
        tclxml3.1/sgml-8.1.tcl \
        tclxml3.1/sgmlparser.tcl \
        tclxml3.1/tclparser-8.1.tcl \
        tclxml3.1/xml-8.1.tcl \
        tclxml3.1/xml__tcl.tcl \
        tclxml3.1/xmldep.tcl \
        tclxml3.1/xpath.tcl \
        textutil/adjust.tcl \
        textutil/pkgIndex.tcl \
        textutil/repeat.tcl \
        textutil/split.tcl \
        textutil/string.tcl \
        textutil/tabify.tcl \
        textutil/textutil.tcl \
        textutil/trim.tcl \
        tooltip/pkgIndex.tcl \
        tooltip/tipstack.tcl \
        tooltip/tooltip.tcl \
        uri/pkgIndex.tcl \
        uri/uri.tcl \
        uri/urn-scheme.tcl \
        uuid/pkgIndex.tcl \
        uuid/uuid.tcl \
        winico/Winico06.dll%base64 \
        winico/pkgIndex.tcl \
        winpm/pkgIndex.tcl \
        winpm/winpm01.dll%base64 \
        critcl/critcl_c/preload.c \
        critcl/critcl_c/tcl.h \
        critcl/critcl_c/tclAppInit.c \
        critcl/critcl_c/tclDecls.h \
        critcl/critcl_c/tclPlatDecls.h \
        critcl/critcl_c/tk.h \
        critcl/critcl_c/tkDecls.h \
        critcl/critcl_c/tkPlatDecls.h \
        idle/win32-ix86/idle.dll%base64 \
        tcllibc/linux-ix86/tcllibc.so%base64 \
        tcllibc/win32-ix86/tcllibc.dll%base64 \
        critcl/critcl_c/X11/X.h \
        critcl/critcl_c/X11/Xatom.h \
        critcl/critcl_c/X11/Xfuncproto.h \
        critcl/critcl_c/X11/Xlib.h \
        critcl/critcl_c/X11/Xutil.h \
        critcl/critcl_c/X11/cursorfont.h \
        critcl/critcl_c/X11/keysym.h \
        critcl/critcl_c/X11/keysymdef.h \
        critcl/critcl_c/X11/tkIntXlibDecls.h \
>> $OUT

chmod u+x $OUT

# EOF