TIP 430: Add basic ZIP archive support to Tcl

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Sean Woods <yoda@etoyoc.com>
Author:         Donal Fellows <donal.k.fellows@manchester.ac.uk>
Author:         Poor Yorick <tk.tcl.tip@pooryorick.com>
Author:         Harald Oehlmann <oehhar@users.sourceforge.net>
State:          Draft
Type:           Project
Vote:           Pending
Created:        03-Sep-2014
Post-History:   
Keywords:       virtual filesystem,zip,tclkit,boot,bootstrap
Tcl-Version:    8.6.3

Abstract

This proposal will add basic support for mounting zip archive files as virtual filesystems to the Tcl core.

Target Tcl-Version

This TIP targets TCL Version 8.7 or 9.0, whatever comes first.

Rationale

Tcl/Tk relies on the presence of a file system containing Tcl scripts for bootstrapping the interpreter. When dealing with code packed in a self-contained executable, a chicken-and-egg problem arises when developers try to provide this bootstrap from their attached VFS with extensions like TclVfs. TclVfs runs in the Tcl interpreter. The interpreter needs init.tcl, which would mean that the filesystem containing init.tcl is not present until after TclVfs mounts it yet that mount cannot happen until after init.tcl has been loaded. Bootstrap filesystem mounts require built-in support for the filesystem that they use.

With the inclusion of Zlib in the core (starting with 8.6, [234]), all that is required to implement a zip file system based VFS is to add a C-level VFS implementation to decode the zip archive format. Thus: this project.

Note that we are prioritizing the zip archive format also because it is practical to generate the files without a Tcl installation being present; it is a format with widespread OS support. This makes it much easier to bootstrap a build of Tcl that uses it without requiring a native build of tclsh to be present.

Specification

There shall be new commands added to safe interpreters withing Tcl. All of which shall be in the ::zvfs namespace. These commands shall include:

Safe interpreters will not be given the mount or unmount commands. Already mounted file systems will be available via the glob and file commands. These commands, and any commands related to building archives will be marked with the unsafe bit within the zipfs ensemble, and will be removed from any interpreter through the normal mechanism to hide unsafe commands within the core.

Implementation

I have adapted Richard Hipp's work on Tcl As One Big Executable (TOBE) to operate inside of a modern Tcl. That implementation consists of one C file (tclZipvfs.c). I have also prepared new behaviors for inside of Tcl_AppInit() to detect if a zip filesystem is attached to the current executable, and how to extract a "main.tcl" as well as the initial file systems for both Tcl and Tk.

This work is checked in as the "core_zip_vfs" branch on both Tcl and Tk.

C API

Bootstraping

The mount and unmount commands are usable within the core as just another feature engine. A call to TclZipfsInit() will be inserted into tclBasic.c, immediately after the code to initialize zlib.

A modified shell (tclkit.exe) will be generated by Make. This shell will:

Copyright

This document has been placed in the public domain.

History