Index: kitsh/build.sh ================================================================== --- kitsh/build.sh +++ kitsh/build.sh @@ -193,44 +193,39 @@ ## Determine if we have a Tclkit to do this work TCLKIT="${TCLKIT:-tclkit}" if echo 'exit 0' | "${TCLKIT}" >/dev/null 2>/dev/null; then ## Install using existing Tclkit ### Call installer - echo "Running: \"${TCLKIT}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\"" - "${TCLKIT}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" || exit 1 - else - if [ ! -f ./kit.exe ]; then - if echo 'exit 0' | ./kit >/dev/null 2>/dev/null; then - ## Bootstrap (cannot cross-compile) - ### Call installer - cp kit runkit - echo "set argv [list {${KITTARGET_NAME}} starpack.vfs {${ENABLECOMPRESSION}}]" > setup.tcl - echo 'if {[catch { clock seconds }]} { proc clock args { return 0 } }' >> setup.tcl - echo 'source installvfs.tcl' >> setup.tcl - - echo 'Running: echo | ./runkit setup.tcl' - echo | ./runkit setup.tcl || exit 1 - else - ## Install using Tclsh, which may work if we're not using Metakit - ### Call installer - echo "Running: \"${TCLSH_NATIVE}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\"" - "${TCLSH_NATIVE}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" || exit 1 - fi - else - ## Install using Tclsh, which may work if we're not using Metakit - ### Call installer - echo "Running: \"${TCLSH_NATIVE}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\"" - "${TCLSH_NATIVE}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" || exit 1 - fi - fi + echo "Running: \"${TCLKIT}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\" \"${KITTARGET_NAME}.new\"" + "${TCLKIT}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" "${KITTARGET_NAME}.new" || exit 1 + else + if echo 'exit 0' | ./kit >/dev/null 2>/dev/null; then + ## Bootstrap (cannot cross-compile) + ### Call installer + echo "set argv [list {${KITTARGET_NAME}} starpack.vfs {${ENABLECOMPRESSION}} {${KITTARGET_NAME}.new}]" > setup.tcl + echo 'if {[catch { clock seconds }]} { proc clock args { return 0 } }' >> setup.tcl + echo 'source installvfs.tcl' >> setup.tcl + + echo 'Running: echo | ./kit setup.tcl' + echo | ./kit setup.tcl || exit 1 + else + ## Install using Tclsh, which may work if we're not using Metakit + ### Call installer + echo "Running: \"${TCLSH_NATIVE}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\" \"${KITTARGET_NAME}.new\"" + "${TCLSH_NATIVE}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" "${KITTARGET_NAME}.new" || exit 1 + fi + fi + + cat "${KITTARGET_NAME}.new" > "${KITTARGET_NAME}" || exit 1 + rm -f "${KITTARGET_NAME}.new" # Cleanup if [ "${KITTARGET}" = "kitdll" ]; then ## Remove built interpreters if we are building KitDLL -- ## they're just tiny stubs anyway - rm -f kit runkit + rm -f kit fi exit 0 ) || exit 1 exit 0 Index: kitsh/buildsrc/kitsh-0.0/installvfs.tcl ================================================================== --- kitsh/buildsrc/kitsh-0.0/installvfs.tcl +++ kitsh/buildsrc/kitsh-0.0/installvfs.tcl @@ -1,20 +1,21 @@ #! /usr/bin/env tclsh # Parse arguments -set opt_compression 1 -if {[llength $argv] < 2} { - puts stderr "Usage: installvfs.tcl \[\]" +if {[llength $argv] != 4} { + puts stderr "Usage: installvfs.tcl " exit 1 } set kitfile [lindex $argv 0] set vfsdir [lindex $argv 1] -if {[lindex $argv 2] != ""} { - set opt_compression [lindex $argv 2] +set opt_compression [lindex $argv 2] +if {$opt_compression == ""} { + set opt_compression 1 } +set outfile [lindex $argv 3] # Determine what storage mechanism is being used set fd [open Makefile.common r] set data [read $fd] close $fd @@ -69,10 +70,12 @@ } # Update the kit, based on what kind of kit this is switch -- $tclKitStorage { "mk4" { + file copy $kitfile $outfile + if {[catch { # Try as if a pre-existing Tclkit, or a tclsh package require vfs::mk4 }]} { # Try as if uninitialized Tclkit @@ -85,18 +88,20 @@ source [file join $vfsdir lib/vfs/mk4vfs.tcl] } } set mk4vfs::compress $opt_compression - set handle [vfs::mk4::Mount $kitfile /kit -nocommit] + set handle [vfs::mk4::Mount $outfile /kit -nocommit] recursive_copy $vfsdir /kit vfs::unmount /kit } "zip" { - set kitfd [open $kitfile a+] + file copy $kitfile $outfile + + set kitfd [open $outfile a+] fconfigure $kitfd -translation binary cd $vfsdir if {$tcl_platform(platform) eq "windows"} { set null NUL @@ -116,8 +121,8 @@ exit 1 } } "cvfs" { - # No-op + file copy $kitfile $outfile } }