diff options
author | hypnotoad <yoda@etoyoc.com> | 2018-11-21 13:06:52 (GMT) |
---|---|---|
committer | hypnotoad <yoda@etoyoc.com> | 2018-11-21 13:06:52 (GMT) |
commit | 3c7c613ec1163e0f1c2d1c2db69382b34a467473 (patch) | |
tree | 11a94176a7e1c7ed52dbdc8803ae99b01a415153 /tools/installVfs.tcl | |
parent | 3a4b0be0b1835791115d8aeabeffc2ea302f1e98 (diff) | |
download | tcl-3c7c613ec1163e0f1c2d1c2db69382b34a467473.zip tcl-3c7c613ec1163e0f1c2d1c2db69382b34a467473.tar.gz tcl-3c7c613ec1163e0f1c2d1c2db69382b34a467473.tar.bz2 |
Added a wrapper script for native builds to utilize Tcl to generate a VFS to attach
to executables or dynamic libraries
Diffstat (limited to 'tools/installVfs.tcl')
-rw-r--r-- | tools/installVfs.tcl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/installVfs.tcl b/tools/installVfs.tcl new file mode 100644 index 0000000..ad1f5c7 --- /dev/null +++ b/tools/installVfs.tcl @@ -0,0 +1,54 @@ +#!/bin/sh +#\ +exec tclsh "$0" ${1+"$@"} + +#---------------------------------------------------------------------- +# +# installVfs.tcl -- +# +# This file wraps the /library file system around a binary +# +#---------------------------------------------------------------------- +# +# Copyright (c) 2018 by Sean Woods. All rights reserved. +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +#---------------------------------------------------------------------- + +proc mapDir {resultvar prefix filepath} { + upvar 1 $resultvar result + if {![info exists result]} { + set result {} + } + set queue [list $prefix $filepath] + while {[llength $queue]} { + set queue [lassign $queue qprefix qpath] + foreach ftail [glob -directory $qpath -nocomplain -tails *] { + set f [file join $qpath $ftail] + if {[file isdirectory $f]} { + if {$ftail eq "CVS"} continue + lappend queue [file join $qprefix $ftail] $f + } elseif {[file isfile $f]} { + if {$ftail eq "pkgIndex.tcl"} continue + if {$ftail eq "manifest.txt"} { + lappend result $f [file join $qprefix pkgIndex.tcl] + } else { + lappend result $f [file join $qprefix $ftail] + } + } + } + } +} +if {[llength $argv]<4} { + error "Usage: [file tail [info script]] IMG_OUTPUT IMG_INPUT PREFIX FILE_SYSTEM ?PREFIX FILE_SYSTEM?..." +} + +set paths [lassign $argv DLL_OUTPUT DLL_INPUT] +foreach {prefix fpath} $paths { + mapDir files $prefix [file normalize $fpath] +} +if {$DLL_INPUT != {}} { + zipfs lmkzip $DLL_OUTPUT $files +} else { + zipfs lmkimg $DLL_OUTPUT $files {} $DLL_INPUT +} |