Check-in [683995c0ec]
Overview
Comment:Updated to always copy to a new file
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | winNoRunKit
Files: files | file ages | folders
SHA1:683995c0ececffa57c90dce3a4ef3708cb5de7b3
User & Date: rkeene on 2015-03-30 21:59:55
Other Links: manifest | tags
Context
2015-03-31
03:32
Update the 'installvfs.tcl' tool to always copy to a new file before making any modifications. check-in: d720e221c4 user: mistachkin tags: trunk
2015-03-30
21:59
Updated to always copy to a new file Closed-Leaf check-in: 683995c0ec user: rkeene tags: winNoRunKit
2015-03-26
04:40
On Windows, stop trying to run 'kit.exe' before it has a functional VFS. check-in: 1fafbabd1a user: mistachkin tags: winNoRunKit
Changes

Modified kitsh/build.sh from [9efdfb74a1] to [b037ed5b3c].

   191    191   
   192    192   	# Intall VFS onto kit
   193    193   	## Determine if we have a Tclkit to do this work
   194    194   	TCLKIT="${TCLKIT:-tclkit}"
   195    195   	if echo 'exit 0' | "${TCLKIT}" >/dev/null 2>/dev/null; then
   196    196   		## Install using existing Tclkit
   197    197   		### Call installer
   198         -		echo "Running: \"${TCLKIT}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\""
   199         -		"${TCLKIT}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" || exit 1
          198  +		echo "Running: \"${TCLKIT}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\" \"${KITTARGET_NAME}.new\""
          199  +		"${TCLKIT}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" "${KITTARGET_NAME}.new" || exit 1
   200    200   	else
   201         -		if [ ! -f ./kit.exe ]; then
   202         -			if echo 'exit 0' | ./kit >/dev/null 2>/dev/null; then
   203         -				## Bootstrap (cannot cross-compile)
   204         -				### Call installer
   205         -				cp kit runkit
   206         -				echo "set argv [list {${KITTARGET_NAME}} starpack.vfs {${ENABLECOMPRESSION}}]" > setup.tcl
   207         -				echo 'if {[catch { clock seconds }]} { proc clock args { return 0 } }' >> setup.tcl
   208         -				echo 'source installvfs.tcl' >> setup.tcl
          201  +		if echo 'exit 0' | ./kit >/dev/null 2>/dev/null; then
          202  +			## Bootstrap (cannot cross-compile)
          203  +			### Call installer
          204  +			echo "set argv [list {${KITTARGET_NAME}} starpack.vfs {${ENABLECOMPRESSION}} {${KITTARGET_NAME}.new}]" > setup.tcl
          205  +			echo 'if {[catch { clock seconds }]} { proc clock args { return 0 } }' >> setup.tcl
          206  +			echo 'source installvfs.tcl' >> setup.tcl
   209    207   
   210         -				echo 'Running: echo | ./runkit setup.tcl'
   211         -				echo | ./runkit setup.tcl || exit 1
   212         -			else
   213         -				## Install using Tclsh, which may work if we're not using Metakit
   214         -				### Call installer
   215         -				echo "Running: \"${TCLSH_NATIVE}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\""
   216         -				"${TCLSH_NATIVE}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" || exit 1
   217         -			fi
          208  +			echo 'Running: echo | ./kit setup.tcl'
          209  +			echo | ./kit setup.tcl || exit 1
   218    210   		else
   219    211   			## Install using Tclsh, which may work if we're not using Metakit
   220    212   			### Call installer
   221         -			echo "Running: \"${TCLSH_NATIVE}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\""
   222         -			"${TCLSH_NATIVE}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" || exit 1
          213  +			echo "Running: \"${TCLSH_NATIVE}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\" \"${KITTARGET_NAME}.new\""
          214  +			"${TCLSH_NATIVE}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" "${KITTARGET_NAME}.new" || exit 1
   223    215   		fi
   224    216   	fi
          217  +
          218  +	cat "${KITTARGET_NAME}.new" > "${KITTARGET_NAME}" || exit 1
          219  +	rm -f "${KITTARGET_NAME}.new"
   225    220   
   226    221   	# Cleanup
   227    222   	if [ "${KITTARGET}" = "kitdll" ]; then
   228    223   		## Remove built interpreters if we are building KitDLL --
   229    224   		## they're just tiny stubs anyway
   230         -		rm -f kit runkit
          225  +		rm -f kit
   231    226   	fi
   232    227   
   233    228   	exit 0
   234    229   ) || exit 1
   235    230   
   236    231   exit 0

Modified kitsh/buildsrc/kitsh-0.0/installvfs.tcl from [5bb6ad9ccb] to [1bbb6d2733].

     1      1   #! /usr/bin/env tclsh
     2      2   
     3      3   # Parse arguments
     4         -set opt_compression 1
     5         -if {[llength $argv] < 2} {
     6         -	puts stderr "Usage: installvfs.tcl <kitfile> <vfsdir> \[<enable_compression>\]"
            4  +if {[llength $argv] != 4} {
            5  +	puts stderr "Usage: installvfs.tcl <kitfile> <vfsdir> <enable_compression> <outfile>"
     7      6   
     8      7   	exit 1
     9      8   }
    10      9   
    11     10   set kitfile [lindex $argv 0]
    12     11   set vfsdir [lindex $argv 1]
    13         -if {[lindex $argv 2] != ""} {
    14         -	set opt_compression [lindex $argv 2]
           12  +set opt_compression [lindex $argv 2]
           13  +if {$opt_compression == ""} {
           14  +	set opt_compression 1
    15     15   }
           16  +set outfile [lindex $argv 3]
    16     17   
    17     18   # Determine what storage mechanism is being used
    18     19   set fd [open Makefile.common r]
    19     20   set data [read $fd]
    20     21   close $fd
    21     22   
    22     23   if {[string match "*KIT_STORAGE_ZIP*" $data]} {
................................................................................
    67     68   		}
    68     69   	}
    69     70   }
    70     71   
    71     72   # Update the kit, based on what kind of kit this is
    72     73   switch -- $tclKitStorage {
    73     74   	"mk4" {
           75  +		file copy $kitfile $outfile
           76  +
    74     77   		if {[catch {
    75     78   			# Try as if a pre-existing Tclkit, or a tclsh
    76     79   			package require vfs::mk4
    77     80   		}]} {
    78     81   			# Try as if uninitialized Tclkit
    79     82   			catch {
    80     83   				load "" vfs
................................................................................
    83     86   				source [file join $vfsdir lib/vfs/vfsUtils.tcl]
    84     87   				source [file join $vfsdir lib/vfs/vfslib.tcl]
    85     88   				source [file join $vfsdir lib/vfs/mk4vfs.tcl]
    86     89   			}
    87     90   		}
    88     91   		set mk4vfs::compress $opt_compression
    89     92   
    90         -		set handle [vfs::mk4::Mount $kitfile /kit -nocommit]
           93  +		set handle [vfs::mk4::Mount $outfile /kit -nocommit]
    91     94   
    92     95   		recursive_copy $vfsdir /kit
    93     96   
    94     97   		vfs::unmount /kit
    95     98   	}
    96     99   	"zip" {
    97         -		set kitfd [open $kitfile a+]
          100  +		file copy $kitfile $outfile
          101  +
          102  +		set kitfd [open $outfile a+]
    98    103   		fconfigure $kitfd -translation binary
    99    104   
   100    105   		cd $vfsdir
   101    106   		if {$tcl_platform(platform) eq "windows"} {
   102    107   			set null NUL
   103    108   		} else {
   104    109   			set null /dev/null
................................................................................
   114    119   		} err]} {
   115    120   			puts stderr "Error while updating executable: $err"
   116    121   
   117    122   			exit 1
   118    123   		}
   119    124   	}
   120    125   	"cvfs" {
   121         -		# No-op
          126  +		file copy $kitfile $outfile
   122    127   	}
   123    128   }