2993614 [rkeene@sledge /home/rkeene/projects/vtcl]$ cat -n starpack-vtcl.sh
  1 #! /bin/bash
  2 
  3 # Setup paths
  4 WORKDIR="${TMPDIR:-/tmp}/starpack-vtcl-$$${RANDOM}${RANDOM}${RANDOM}${RANDOM}"
  5 STARTDIR="$(readlink -f "$(pwd)")"
  6 
  7 # Process script arguments and expand to fully qualified names where appropriate
  8 TCLKIT="$(readlink -f "$1" 2>/dev/null)"
  9 SDXPATH="$(readlink -f "$2" 2>/dev/null)"
 10 SRCTARBALL="$(readlink -f "$3" 2>/dev/null)"
 11 OUTPUT="$4"
 12 DESTTCLKIT="$(readlink -f "$5" 2>/dev/null)"
 13 if [ ! -x "${TCLKIT}" ]; then
 14     echo 'TCLKIT specified is not executable.' >&2
 15     TCLKIT=""
 16 fi
 17 if [ ! -f "${SRCTARBALL}" ]; then
 18     echo 'SRCTARBALL is not a regular file' >&2
 19     SRCTARBALL=""
 20 fi
 21 if [ -n "${DESTTCLKIT}" -a \( ! -e "${DESTTCLKIT}" -o "${DESTTCLKIT}" = "${TCLKIT}" \) ]; then
 22     DESTTCLKIT=""
 23 fi
 24 if [ -z "${TCLKIT}" -o -z "${SDXPATH}" -o -z "${SRCTARBALL}" -o -z "${OUTPUT}" ]; then
 25     echo 'Usage: starpack-vtcl.sh <local_tclkit> <sdx> <srctarball> <output> [<dest_tclkit>]' >&2
 26 
 27     exit 1
 28 fi
 29 
 30 # Abort on failure of any command
 31 set -e
 32 
 33 # Create working area
 34 mkdir -p "${WORKDIR}"
 35 chmod 700 "${WORKDIR}"
 36 cd "${WORKDIR}"
 37 
 38 # Extract source tarball and rename to Starpack appropriate name
 39 tar -zxf "${SRCTARBALL}"
 40 SRCDIR=$(ls -1  2>/dev/null | tail -n 1)
 41 mv "${SRCDIR}" vtcl.vfs
 42 
 43 # Enter Starpack directory
 44 cd vtcl.vfs
 45 
 46 # Remove empty freewrap directory, it might conflict later
 47 rm -rf freewrap
 48 
 49 # Fixup "vtcl.tcl"
 50 (
 51     echo '#! /usr/bin/env tclsh'
 52     echo ''
 53     echo 'package require Tk'
 54 
 55     fromdos < vtcl.tcl | sed '1,3 s@^.*$@@'
 56 ) > vtcl.tcl.new
 57 cat vtcl.tcl.new > vtcl.tcl
 58 rm -f vtcl.tcl.new
 59 
 60 # Create "main.tcl"
 61 cat <<\__EOF__ > main.tcl
 62 #! /usr/bin/env tclsh
 63 
 64 package require starkit
 65 starkit::startup
 66 
 67 set mytopdir $starkit::topdir
 68 source $mytopdir/vtcl.tcl
 69 __EOF__
 70 
 71 # Return to work directory
 72 cd ../
 73 
 74 # Create temporary Tclkit if needed
 75 if [ -z "${DESTTCLKIT}" ]; then
 76     DESTTCLKIT="${WORKDIR}/copykit"
 77     cp "${TCLKIT}" "${DESTTCLKIT}"
 78 fi
 79 
 80 # Determine platform of destination starpack
 81 DESTPLATFORM_FILE=$(file "${DESTTCLKIT}" | sed 's@^[^:]*: *@@')
 82 DESTOS="Unknown"
 83 case "${DESTPLATFORM_FILE}" in
 84     Mach-O\ *|compiled\ Java\ class\ data,\ version\ 2.0)
 85         DESTOS="MacOS"
 86         ;;
 87     ELF\ 32-bit\ *\ version\ 1\ \(SYSV\),\ *)
 88         DESTOS="Linux"
 89         ;;
 90     ELF\ 32-bit\ *\ version\ 1\ \(FreeBSD\),\ *)
 91         DESTOS="FreeBSD"
 92         ;;
 93     MS-DOS\ executable\ *)
 94         DESTOS="Windows"
 95         ;;
 96 esac
 97 
 98 # Enable generic fix-ups
 99 fromdos < vtcl.vfs/lib/propmgr.tcl | sed 's@global vTcl \$variable options specialOpts propmgrLabels$@global vTcl
	options specialOpts propmgrLabels; if {[string match "*(*)" $variable]} { global [lindex [split $variable (] 0] }@' >
	vtcl.vfs/lib/propmgr.tcl.new
100 cat vtcl.vfs/lib/propmgr.tcl.new > vtcl.vfs/lib/propmgr.tcl
101 rm -f vtcl.vfs/lib/propmgr.tcl.new
102 
103 # Enable platform-specific fix-ups (pre-wrap)
104 case "${DESTOS}" in
105     Windows)
106         wget -O freewrap-6.2-windows.zip http://easynews.dl.sourceforge.net/sourceforge/freewrap/freewrapPLUS62.zip
107         unzip freewrap-6.2-windows.zip
108         mkdir -p vtcl.vfs/Freewrap/Windows/bin
109 
110         mv freewrapPLUS.exe vtcl.vfs/Freewrap/Windows/bin/freewrap.exe
111 
112         # ** NOTE ** Currently we disable images since Freewrap doesn't
113         #            appear to be able to access files inside the vTcl
114         #            VFS
115         fromdos < vtcl.vfs/lib/file.tcl | sed 's@exec \$freewrap \$file -f \$filelist$@file delete -force -- [file join
	$env(TEMP) freewrap.exe]; file copy -force -- $freewrap [file join $env(TEMP) freewrap.exe]; catch { exec [file join
	$env(TEMP) freewrap.exe] $file -f $filelist -forcewrap }; file delete -force -- [file join $env(TEMP)
	freewrap.exe]@;s@puts \$listID \[join \[vTcl:image:get_files_list\] \\n\]$@@' > vtcl.vfs/lib/file.tcl.new
116         cat vtcl.vfs/lib/file.tcl.new > vtcl.vfs/lib/file.tcl
117         rm -f vtcl.vfs/lib/file.tcl.new
118         ;;
119 esac
120 
121 # Create starpack
122 "${TCLKIT}" "${SDXPATH}" wrap vtcl -runtime "${DESTTCLKIT}"
123 
124 # Enable platform-specific fix-ups (post-wrap)
125 case "${DESTOS}" in
126     MacOS)
127         mkdir -p vtcl.app/Contents/MacOS
128         mv vtcl vtcl.app/Contents/MacOS
129         zip -r vtcl.zip vtcl.app
130         mv vtcl.zip vtcl
131         ;;
132 esac
133 
134 
135 # Copy starpack to output
136 STARPACKFILE="$(readlink -f vtcl 2>/dev/null)"
137 if [ -z "${STARPACKFILE}" ]; then
138     echo 'Failed to create starpack, leaving temporary directory intact for inspection.' >&2
139     exit 1
140 fi
141 cd "${STARTDIR}"
142 cp -a "${STARPACKFILE}" "${OUTPUT}"
143 
144 # Cleanup
145 rm -rf "${WORKDIR}"

starpack-vtcl.sh is the shell script used to generate these starpacks from the unmodified vTcl source code.
2993615 [rkeene@sledge /home/rkeene/projects/vtcl]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2007-08-26 11:43:43