Hello,
I have been working on getting CanAce to the point where it can be
installed anywhere and will find the files that it needs. The
latest commit is at:
https://github.com/LawrenceWoodman/CanAce/commit/c13515135345daf50bc8f6e4c3ddc4d6bcd01443
To do this I have compiled in the canace.tcl file using a method I
have described here:
http://techtinkering.com/2013/02/20/compiling-a-tcl-script-into-an-executable
I have also made use of the XDG base directory specification to
locate the ROM image. A big thanks to Marcos for letting me know
about this as I had never heard of it until you had mentioned this
standard. To make use of this I have created a Tcl module called
xdgbasedir available from:
https://github.com/LawrenceWoodman/xdgbasedir_tcl
Unfortunately this has made CanAce a little more tricky to install
and I'm currently looking at how to simplify this. For the moment
though, you will need to download xdgbasedir from:
https://github.com/LawrenceWoodman/xdgbasedir_tcl/tags
And then, as described in its README, copy the module to a directory
where Tcl would expect to find modules. To simplify this I have
created the script featured near the end of this email, which when
run as root from the base directory of the xdgbasedir_tcl repo, as
follows, will install the module into a sensible location
automatically:
$ tclsh installmodule.tcl xdgbasedir*.tm
You will need to copy and past the following script to a file
called: installmodule.tcl, in the root of the xdgbasedir repo.
#!/usr/bin/env tclsh
# Simple Tcl module install script
# Usage: installmodule <moduleFilename>
#
# Copyright (C) 2013 Lawrence Woodman
#
# Licensed under an MIT licence. Please see LICENCE.md for details.
#
# The script will search the module path for a location where
modules are
# already installed and try to pick the best location to install the
module
# specified. It must be run by a user that has permission to write
to the
# directory.
#
# Get a list of directories in the module search path that are being
used
proc getUsedModuleDirs {} {
set usedModuleDirs {}
set moduleDirs [split [::tcl::tm::path list]]
foreach moduleDir $moduleDirs {
set moduleNames [glob -nocomplain -directory $moduleDir/ *.tm]
if {[llength $moduleNames] >= 1} {
lappend usedModuleDirs $moduleDir/
}
}
return $usedModuleDirs
}
# Get the best directory to put the module in
proc getBestModuleDir {moduleDirs} {
set moduleDirs [getUsedModuleDirs]
if {[llength $moduleDirs] == 0} {
puts "Error: Couldn't find any suitable directories for the
module"
exit
}
return [lindex $moduleDirs end]
}
# Copy moduleFilename to the most suitable module location
proc installModule {moduleFilename} {
set destModuleDir [getBestModuleDir [getUsedModuleDirs]]
if {[catch {file copy -force $moduleFilename $destModuleDir}
copyError]} {
puts "Error: $copyError"
exit
}
puts "Copied $moduleFilename to $destModuleDir"
}
# Outputs a usage suggestion if a single module in current directory
proc makeUsageSuggestion {} {
set possibleModuleNames [glob -nocomplain *-*.*.tm]
if {[llength $possibleModuleNames] == 1} {
puts "Suggestion: installmodule [lindex $possibleModuleNames 0]"
}
}
proc usageError {msg} {
puts "Error: $msg"
puts "Usage: installmodule <moduleFilename>"
makeUsageSuggestion
exit
}
if {$argc != 1} {
usageError "wrong number of arguments"
}
set moduleFilename [lindex $argv 0]
set moduleFilenameRegexp
{([[:alpha:]][:[:alnum:]]*)-([[:digit:]].*)\.tm}
if {![regexp $moduleFilenameRegexp $moduleFilename]} {
usageError "$moduleFilename isn't a valid name for a module"
}
installModule $moduleFilename
# End of File
Let me know how you get on and if there are any problems.
Lorry
--
vLife Systems Ltd
Registered Office: The Meridian, 4 Copthall House, Station Square, Coventry, CV1 2FL
Registered in England and Wales No. 06477649
http://vlifesystems.com