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
192
193
194
195
196
197
198
199
200
201
202






203
204
205
206



207
208
209
210
211
212
213
214
215








216



217
218
219
220
221
222

223
224
225
226
227
228
191
192
193
194
195
196
197





198
199
200
201
202
203




204
205
206
207








208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

225
226
227
228
229
230
231







-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+

-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+

+
+
+





-
+







	# Intall VFS onto kit
	## 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
	elif echo 'exit 0' | ./kit >/dev/null 2>/dev/null; then
		## Bootstrap (cannot cross-compile)
		### Call installer
		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
		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 "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 | ./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
		
			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

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

1
2
3
4
5
6


7
8
9
10
11
12
13
14



15

16
17
18
19
20
21
22
1
2
3



4
5
6
7
8
9
10
11


12
13
14
15
16
17
18
19
20
21
22
23



-
-
-
+
+






-
-
+
+
+

+







#! /usr/bin/env tclsh

# Parse arguments
set opt_compression 1
if {[llength $argv] < 2} {
	puts stderr "Usage: installvfs.tcl <kitfile> <vfsdir> \[<enable_compression>\]"
if {[llength $argv] != 4} {
	puts stderr "Usage: installvfs.tcl <kitfile> <vfsdir> <enable_compression> <outfile>"

	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

if {[string match "*KIT_STORAGE_ZIP*" $data]} {
67
68
69
70
71
72
73


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

91
92
93
94
95
96


97

98
99
100
101
102
103
104
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

93
94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
109







+
+
















-
+






+
+
-
+







		}
	}
}

# 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
			catch {
				load "" vfs
				load "" Mk4tcl

				source [file join $vfsdir lib/vfs/vfsUtils.tcl]
				source [file join $vfsdir lib/vfs/vfslib.tcl]
				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" {
		file copy $kitfile $outfile

		set kitfd [open $kitfile a+]
		set kitfd [open $outfile a+]
		fconfigure $kitfd -translation binary

		cd $vfsdir
		if {$tcl_platform(platform) eq "windows"} {
			set null NUL
		} else {
			set null /dev/null
114
115
116
117
118
119
120
121

122
123
119
120
121
122
123
124
125

126
127
128







-
+


		} err]} {
			puts stderr "Error while updating executable: $err"

			exit 1
		}
	}
	"cvfs" {
		# No-op
		file copy $kitfile $outfile
	}
}