Mount Metakit (starpack) from tclsh

Prologue

  • starpacks are containers or filesystems to store data or files
  • Starkits are nearly the same as starpacks but are self executable.
  • starpacks can also be mounted by tclkit - binaries to access their content

Issue

  • in later Tcl 8.6 and Tcl 9.0 I fail to mount a starpack by tclsh

Preparation

The standard method to create a starpack

  • create the kit-File from an empty myMk.tcl file
tclkit-win64-tcl.exe sdx.kit   qwrap myMk.tcl
    # C:\runtime\bawtTcl\9.0.1\bin\tclkit-win64-tcl.exe C:\runtime\bawtTcl\9.0.1\bin\sdx.kit   qwrap myMk.tcl
    
    03.05.2025  21:40               648 myMk.kit
  • unwrap myMk.kit file to a directory myMk.vfs
tclkit-win64-tcl.exe sdx.kit   unwrap myMk.kit
    # C:\runtime\bawtTcl\9.0.1\bin\tclkit-win64-tcl.exe C:\runtime\bawtTcl\9.0.1\bin\sdx.kit   unwrap myMk.kit
    
    03.05.2025  21:36                 5 myMk.tcl
    03.05.2025  21:47    <DIR>          myMk.vfs
  • the content of directory myMk.vfs
        ...\myMk.vfs
            │
            ├───lib
            │   └───app-myMk
            │       ├───myMk.tcl
            │       └───pkgIndex.tcl
            │
            └───main.tcl
  • do some modifications ...
        ...\myMk.vfs
            │
            ├───lib
            │   └───app-myMk    03.05.2025  21:47
            │       ├───a
            │       │   └───a-a
            │       ├───b            
            │       │
            │       ├───myMk.tcl
            │       └───pkgIndex.tcl
            │
            └───main.tcl
  • ... and write updates to myMk.kit
tclkit-win64-tcl.exe sdx.kit   wrap myMk.kit
    # C:\runtime\bawtTcl\9.0.1\bin\tclkit-win64-tcl.exe C:\runtime\bawtTcl\9.0.1\bin\sdx.kit   wrap myMk.kit
    
    8 updates applied
  • read content of myMk.kit by a script
# readMk.tcl

    # Load the VFS Metakit package
package require vfs::mk4

    # Create a temporary mount point
set mountpoint [file join [file dirname [file normalize [info script]]] myMount]
puts "   -> \$mountpoint $mountpoint"
file mkdir $mountpoint

    # Mount the .kit file as a virtual filesystem
vfs::mk4::Mount myMk.kit $mountpoint

    # List the files inside
puts "Contents of VFS in myMk.kit:"
foreach f [glob -directory $mountpoint *] {
    puts "    $f"
    foreach ff [glob -directory $f *] {
        puts "    $ff"
        foreach fff [glob -directory $ff *] {
            puts "    $fff"
            foreach ffff [glob -directory $fff *] {
                puts "    $ffff"
            }
        }
    }
}

    # unmount the virtual filesystem
vfs::unmount $mountpoint
  • and execute it by a tclkit
tclkit-win64-tcl.exe readMk.tcl
    # C:\runtime\bawtTcl\9.0.1\bin\tclkit-win64-tcl.exe readMk.tcl

           -> $mountpoint C:/Dateien/TMP/202505/Tcl-mk-fs/myMount
        Contents of VFS in myMk.kit:
            C:/Dateien/TMP/202505/Tcl-mk-fs/myMount/main.tcl
            C:/Dateien/TMP/202505/Tcl-mk-fs/myMount/lib
            C:/Dateien/TMP/202505/Tcl-mk-fs/myMount/lib/app-myMk
            C:/Dateien/TMP/202505/Tcl-mk-fs/myMount/lib/app-myMk/myMk.tcl
            C:/Dateien/TMP/202505/Tcl-mk-fs/myMount/lib/app-myMk/pkgIndex.tcl
            C:/Dateien/TMP/202505/Tcl-mk-fs/myMount/lib/app-myMk/a
            C:/Dateien/TMP/202505/Tcl-mk-fs/myMount/lib/app-myMk/a/a-a
            C:/Dateien/TMP/202505/Tcl-mk-fs/myMount/lib/app-myMk/b

Problem

tclsh: vfs::mk4 fails called by tclsh

When running this script out of tclsh instead of tclkit, tclsh fails on

vfs::mk4::Mount
tclsh.exe readMk.tcl
    # C:\runtime\bawtTcl\9.0.1\bin\tclsh.exe readMk.tcl
        can't find package vfs::mkcl
            while executing
        "package require vfs::mkcl"
            (procedure "vfs::mk4::Mount" line 4)
            invoked from within
        "vfs::mk4::Mount myMk.kit $mountpoint"
            (file "readMk.tcl" line 14)

Questions

  • Do i do something wrong?
  • is vfs::mk4 available in tclkit only?
  • should there be an additional package providing vfs::mkcl to be loaded dynamically?
    • vanillawish had a package named vqtcl
  • or something else?

aplsimple - 2025-05-04 08:28:04

>> or something else?

Of course, there is something else: Single file applications in Tcl 9. No creating main.tcl file which may be so weird depending on the app's needs.

The technology works in Windows and Linux and is in Tcl/Tk 9 trend. Alas, it's still underestimated, while being one of Tcl's most attractive features.

Though, if your workflow suggests tclkit technology only, then the above link wouldn't fit it.


ManfredR - 2025-05-04 12:48:54

aplsimple Thanks for this link!

For some legacy code, the build process belongs to the metakit-starpack concept.

... and I do not want to invest resources to also update the build process ...

... , but shouldn't be there be a solution to mount metakit-starpacks also from tclsh, like it is for other file-systems, e.g. zip, ...


reg2s - 2025-05-07 09:40:19

It is possible to mount metakit with tclsh by adding vqtcl and tclvfs packages.

I've successfully build them in MSYS2, taking from these repositories:

https://github.com/ISalzman/vqtcl

https://github.com/tcl-mirror/tclvfs