Updated 2014-06-02 20:35:48 by dkf

qstarpack is a quick script I wrote for those that claim wrapping single files into a starpack is hard. Well, as for difficult code, compare that to an ant XML file :-)
  package require mk4vfs
  
  set args {binaryName scriptName outFile}
  
  if {[llength $args] != [llength $argv]} {
      puts stderr "Usage: [info script] $args"
      exit 1
  }
  
  foreach $args $argv break
  
  file copy -force $binaryName $outFile
  
  vfs::mk4::Mount $outFile $outFile
  
  set fh [open [file join $outFile main.tcl] w]
  fconfigure $fh -translation lf
  puts $fh "package require starkit\nstarkit::startup\npackage require app"
  close $fh
  
  file mkdir [file join $outFile lib]
  file mkdir [file join $outFile lib app]
  
  set fh [open [file join $outFile lib app pkgIndex.tcl] w]
  fconfigure $fh -translation lf
  puts $fh {package ifneeded app 1.0 [list source [file join $dir app.tcl]]}
  close $fh
  
  set fh [open [file join $outFile lib app app.tcl] w]
  fconfigure $fh -translation lf
  puts $fh {package provide app 1.0}
  
  set sfh [open $scriptName r]
  puts $fh [read $sfh]
  close $sfh
  
  close $fh
  
  vfs::unmount $outFile
  
  exit 0

see also StarPack helper made by JR