diff options
| author | hypnotoad <yoda@etoyoc.com> | 2014-10-21 01:04:07 (GMT) |
|---|---|---|
| committer | hypnotoad <yoda@etoyoc.com> | 2014-10-21 01:04:07 (GMT) |
| commit | 9171dde34641416c1530c7a8ba9aa49ca267a55c (patch) | |
| tree | 7532a8a9134f13ff0870ca98e033e741bbf69364 | |
| parent | 6826dbab466f01f5d52b4ff477e810297aa96991 (diff) | |
| download | tcl-9171dde34641416c1530c7a8ba9aa49ca267a55c.zip tcl-9171dde34641416c1530c7a8ba9aa49ca267a55c.tar.gz tcl-9171dde34641416c1530c7a8ba9aa49ca267a55c.tar.bz2 | |
Replaced calls to zip with calls to the new pure-tcl zipfile encoder embedded
in zvfstools.
Fixed a bug in the encoder for zvfstools. It was exporting files, but not directories.
This lack of directories was causing the bootloader to miss that /zvfs/boot/tcl/init.tcl
existed, because it was checking for the existance of /zvfs/boot/tcl. I compared the
archives created by zvfstools::mkzip to the archives created by zip, and the
difference came down to the fact that zip did create TOC entries for directories
and zvfstools::mkzip was failing to do so. (So I'm pretty sure the new behavior
is "standard.")
| -rw-r--r-- | library/zvfstools/zvfstools.tcl | 28 | ||||
| -rw-r--r-- | tools/mkzip.tcl | 6 | ||||
| -rw-r--r-- | unix/Makefile.in | 15 | ||||
| -rw-r--r-- | win/Makefile.in | 12 |
4 files changed, 37 insertions, 24 deletions
diff --git a/library/zvfstools/zvfstools.tcl b/library/zvfstools/zvfstools.tcl index 05119c6..f755283 100644 --- a/library/zvfstools/zvfstools.tcl +++ b/library/zvfstools/zvfstools.tcl @@ -80,6 +80,7 @@ proc ::zvfs::walk {base {excludes ""} {match *} {path {}}} { if {!$excluded} {lappend result $file} } foreach dir [glob -nocomplain -tails -types d -directory $base $imatch] { + lappend result $dir set subdir [walk $base $excludes $match $dir] if {[llength $subdir]>0} { set result [concat $result [list $dir] $subdir] @@ -137,7 +138,7 @@ proc ::zvfs::add_file_to_archive {zipchan base path {comment ""}} { [string length $utfpath] [string length $extra]] append local $utfpath $extra puts -nonewline $zipchan $local - + if {[file isfile $fullpath]} { # If the file is under 2MB then zip in one chunk, otherwize we use # streaming to avoid requiring excess memory. This helps to prevent @@ -242,12 +243,24 @@ proc ::zvfs::mkzip {filename args} { fcopy $rt $zf close $rt } elseif {$opts(-zipkit)} { - set zkd "#!/usr/bin/env tclkit\n\# This is a zip-based Tcl Module\n" - append zkd "package require vfs::zip\n" - append zkd "vfs::zip::Mount \[info script\] \[info script\]\n" - append zkd "if {\[file exists \[file join \[info script\] main.tcl\]\]} \{\n" - append zkd " source \[file join \[info script\] main.tcl\]\n" - append zkd "\}\n" + set zkd {#!/usr/bin/env tclsh +# This is a zip-based Tcl Module +if {![package vsatisfies [package provide zvfs] 1.0]} { + package require vfs::zip + vfs::zip::Mount [info script] [info script] +} else { + zvfs::mount [info script] [info script] +} +# Load any CLIP file present +if {[file exists [file join [info script] pkgIndex.tcl]] } { + set dir [info script] + source [file join [info script] pkgIndex.tcl] +} +# Run any main.tcl present +if {[file exists [file join [info script] main.tcl]] } { + source [file join [info script] main.tcl] +} + } append zkd \x1A puts -nonewline $zf $zkd } @@ -261,7 +274,6 @@ proc ::zvfs::mkzip {filename args} { set paths [glob -nocomplain {*}$args] } foreach path $paths { - puts $path append cd [add_file_to_archive $zf $opts(-directory) $path] incr count } diff --git a/tools/mkzip.tcl b/tools/mkzip.tcl new file mode 100644 index 0000000..e53bae3 --- /dev/null +++ b/tools/mkzip.tcl @@ -0,0 +1,6 @@ +### +# Wrapper to allow access to Tcl's zvfs::mkzip command from Makefiles +### +package require zvfs +source [file join [file dirname [file normalize [info script]]] .. library zvfstools zvfstools.tcl] +zvfs::mkzip {*}$argv diff --git a/unix/Makefile.in b/unix/Makefile.in index 918e9fc..b635c0a 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -661,10 +661,6 @@ ${TCL_EXE}: ${TCLSH_OBJS} ${TCL_LIB_FILE} ${TCL_STUB_LIB_FILE} # Must be empty so it doesn't conflict with rule for ${TCL_EXE} above ${NATIVE_TCLSH}: -null.zip: - touch .empty - zip null.zip .empty - # Rather than force an install, pack the files we need into a # file system under our control tclzsh.vfs: @@ -681,13 +677,12 @@ ${TCLZSH_BASE}_bare: ${TCLZSH_OBJS} ${TCL_LIB_FILE} ${TCL_STUB_LIB_FILE} ${LIBS} @EXTRA_TCLSH_LIBS@ \ ${CC_SEARCH_FLAGS} -o ${TCLZSH_BASE}_bare - # Builds an executable linked to the Tcl dynamic library -${TCLZSH_EXE}: ${TCLZSH_BASE}_bare null.zip tclzsh.vfs - cp -f ${TCLZSH_BASE}_bare ${TCLZSH_BASE}.zip - cat null.zip >> ${TCLZSH_BASE}.zip - cd tclzsh.vfs ; zip -rAq ${UNIX_DIR}/${TCLZSH_BASE}.zip . - mv ${TCLZSH_BASE}.zip ${TCLZSH_EXE} +${TCLZSH_EXE}: ${TCLZSH_BASE}_bare tclzsh.vfs + ./${TCLZSH_BASE}_bare ../tools/mkzip.tcl ${TCLZSH_EXE} \ + -runtime ${TCLZSH_BASE}_bare \ + -directory tclzsh.vfs + chmod a+x ${TCLZSH_EXE} # Builds an executable directly from the Tcl sources tclzsh-static: ${TCLZSH_OBJS} ${OBJS} ${ZLIB_OBJS} null.zip tclzsh.vfs diff --git a/win/Makefile.in b/win/Makefile.in index 6877938..0b34570 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -441,18 +441,18 @@ null.zip: tclzsh.vfs: $(TCLSH) $(DDE_DLL_FILE) $(REG_DLL_FILE) @echo "Building VFS File system in tclzsh.vfs" @$(TCL_EXE) "$(ROOT_DIR)/tools/mkVfs.tcl" \ - "$(WIN_DIR)/tclzsh.vfs/tcl$(VERSION)" "$(ROOT_DIR)" windows + "$(WIN_DIR)/tclzsh.vfs/boot/tcl" "$(ROOT_DIR)" windows tclzsh_bare: $(TCLZSH_OBJS) @LIBRARIES@ $(TCL_STUB_LIB_FILE) tclsh.$(RES) $(CC) $(CFLAGS) $(TCLZSH_OBJS) $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE) $(LIBS) \ tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE) @VC_MANIFEST_EMBED_EXE@ -$(TCLZSH): tclzsh_bare null.zip tclzsh.vfs - cp tclzsh_bare tclzsh.zip - cat null.zip >> tclzsh.zip - cd tclzsh.vfs ; zip -rAq $(WIN_DIR)/tclzsh.zip . - mv tclzsh.zip $(TCLZSH) +$(TCLZSH): tclzsh_bare tclzsh.vfs + ./${TCLZSH_BASE}_bare ../tools/mkzip.tcl ${TCLZSH_EXE} \ + -runtime ${TCLZSH_BASE}_bare \ + -directory tclzsh.vfs + chmod a+x ${TCLZSH_EXE} # Builds an executable directly from the Tcl sources tclzsh-direct: $(TCLZSH_OBJS) ${GENERIC_OBJS} $(TOMMATH_OBJS) ${WIN_OBJS} ${ZLIB_OBJS} @LIBRARIES@ $(TCL_STUB_LIB_FILE) tclsh.$(RES) null.zip tclzsh.vfs |
