Check-in [d720e221c4]
Overview
Comment:Update the 'installvfs.tcl' tool to always copy to a new file before making any modifications.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d720e221c4707f1088a7327334ded30fcee6c4b5
User & Date: mistachkin on 2015-03-31 03:32:45
Other Links: manifest | tags
Context
2015-03-31
03:33
Updated to work with compilers that add ".exe" to output files check-in: 7ca49930e2 user: rkeene tags: trunk
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
03:31
Upgrade the Thread package to version 2.7.2. check-in: d698723d21 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
Changes

Modified kitsh/build.sh from [0e6a9ba02e] 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
   200         -	elif echo 'exit 0' | ./kit >/dev/null 2>/dev/null; then
   201         -		## Bootstrap (cannot cross-compile)
   202         -		### Call installer
   203         -		cp kit runkit
   204         -		echo "set argv [list {${KITTARGET_NAME}} starpack.vfs {${ENABLECOMPRESSION}}]" > setup.tcl
   205         -		echo 'if {[catch { clock seconds }]} { proc clock args { return 0 } }' >> setup.tcl
   206         -		echo 'source installvfs.tcl' >> setup.tcl
          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  +	else
          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
   207    207   
   208         -		echo 'Running: echo | ./runkit setup.tcl'
   209         -		echo | ./runkit setup.tcl || exit 1
   210         -	else
   211         -		## Install using Tclsh, which may work if we're not using Metakit
   212         -		### Call installer
   213         -		echo "Running: \"${TCLSH_NATIVE}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\""
   214         -		"${TCLSH_NATIVE}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" || exit 1
   215         -		
          208  +			echo 'Running: echo | ./kit setup.tcl'
          209  +			echo | ./kit setup.tcl || exit 1
          210  +		else
          211  +			## Install using Tclsh, which may work if we're not using Metakit
          212  +			### Call installer
          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
          215  +		fi
   216    216   	fi
          217  +
          218  +	cat "${KITTARGET_NAME}.new" > "${KITTARGET_NAME}" || exit 1
          219  +	rm -f "${KITTARGET_NAME}.new"
   217    220   
   218    221   	# Cleanup
   219    222   	if [ "${KITTARGET}" = "kitdll" ]; then
   220    223   		## Remove built interpreters if we are building KitDLL --
   221    224   		## they're just tiny stubs anyway
   222         -		rm -f kit runkit
          225  +		rm -f kit
   223    226   	fi
   224    227   
   225    228   	exit 0
   226    229   ) || exit 1
   227    230   
   228    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   }