Differences From Artifact [848dac55a9]:
- File
kitsh/buildsrc/kitsh-0.0/installvfs.tcl
— part of check-in
[2203d001cd]
at
2010-09-26 04:39:48
on branch trunk
— Enabled Mk4vfs compression
Added appropriate licensing information.
Updated README (user: rkeene, size: 1332) [annotate] [blame] [check-ins using]
To Artifact [3a059dfee8]:
- File
kitsh/buildsrc/kitsh-0.0/installvfs.tcl
— part of check-in
[66535d6924]
at
2010-09-26 04:43:48
on branch trunk
— KitCreator 0.3.0.x
Added support for using ZIP archives if MK4 fails to build
Removed support for pure-Tcl MK4 (it didn't work) (user: rkeene, size: 2185) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#! /usr/bin/env tclsh
set opt_compression 1
if {[llength $argv] < 2} {
puts stderr "Usage: installvfs.tcl <kitfile> <vfsdir> \[<enable_compression>\]"
exit 1
}
set kitfile [lindex $argv 0]
set vfsdir [lindex $argv 1]
if {[lindex $argv 2] != ""} {
set opt_compression [lindex $argv 2]
}
| > < | < | > | | > | | | | | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#! /usr/bin/env tclsh
# Parse arguments
set opt_compression 1
if {[llength $argv] < 2} {
puts stderr "Usage: installvfs.tcl <kitfile> <vfsdir> \[<enable_compression>\]"
exit 1
}
set kitfile [lindex $argv 0]
set vfsdir [lindex $argv 1]
if {[lindex $argv 2] != ""} {
set opt_compression [lindex $argv 2]
}
# Determine what storage mechanism is being used
## This logic must be duplicated from "kitInit.c"
set fd [open Makefile r]
set data [read $fd]
close $fd
if {[string match "*KIT_INCLUDES_MK4TCL*" $data]} {
set tclKitStorage mk4
} else {
set tclKitStorage zip
}
# Define procedures
proc copy_file {srcfile destfile} {
switch -glob -- $srcfile {
"*.tcl" - "*.txt" {
set ifd [open $srcfile r]
set ofd [open $destfile w]
set ret [fcopy $ifd $ofd]
|
| ︙ | ︙ | |||
61 62 63 64 65 66 67 |
copy_file $file $destfile
} err]} {
puts stderr "Failed to copy: $file: $err"
}
}
}
| > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > | 61 62 63 64 65 66 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 105 106 107 108 109 110 111 112 |
copy_file $file $destfile
} err]} {
puts stderr "Failed to copy: $file: $err"
}
}
}
# Update the kit, based on what kind of kit this is
switch -- $tclKitStorage {
"mk4" {
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]
recursive_copy $vfsdir /kit
vfs::unmount /kit
}
"zip" {
set kitfd [open $kitfile a+]
fconfigure $kitfd -translation binary
cd $vfsdir
set zipfd [open "|zip -r - [glob *] 2> /dev/null"]
fconfigure $zipfd -translation binary
fcopy $zipfd $kitfd
close $kitfd
if {[catch {
close $zipfd
} err]} {
puts stderr "Error while updating executable: $err"
exit 1
}
}
}
|