Hai Vu
Hai Vu

Reputation: 40773

How to Create Installation Script for Tcl Package

I have a Tcl package which consists of a couple modules, unit tests, and samples; which I am looking to distribute. I have searched, but not found any easy/simple way to create installation script for it. I looked at other packages such as Tclx and looks like they use autotools--an untouched territory for me. So, is autotools the only way? My target platforms are mostly Macs and Linux, but might expand to Windows in the future.

Upvotes: 2

Views: 189

Answers (1)

Hai Vu
Hai Vu

Reputation: 40773

It seems I have to create my own setup script. Right now, it is very crude: copy files to a location. It works for me now. I will continue to enhance my setup script to fix bugs and add features as the need arise. Here is my setup.tcl

#!/usr/bin/tclsh

# Crude setup script for my package

# ====================================================================== 
# Configurable items
# ====================================================================== 

# Install dir: $destLib/$packagename 
set destLib [file join ~ Library Tcl]
set packageName tcl_tools

# List of source/dest to install
set filesList {
    argparser.tcl
    dateutils.tcl
    htmlutils.tcl
    listutils.tcl
    pkgIndex.tcl

    samples/common.tcl
    samples/dateutils_sample.tcl
    samples/httputils_sample.tcl
    samples/parse_by_example_demo_missing_parameter.tcl
    samples/parse_by_example_demo.tcl
    samples/parse_simple_demo.tcl
}


# ====================================================================== 
# Determine the destination lib dir
# ====================================================================== 
if {[llength $::argv] == 1} {
    set destLib [lindex $::argv 0]
}

if {[lsearch $auto_path $destLib] == -1} {
    puts "ERROR: Invalid directory to install. Must be one of these:"
    puts "[join $auto_path \n]"
    exit 1
}

set destLib [file join $destLib $packageName]
file mkdir $destLib

# ====================================================================== 
# Install
# ====================================================================== 

foreach source $filesList {
    set dest [file join $destLib $source]
    puts "Installing $dest"

    # Create destination dir if needed
    set destDir [file dirname $dest]
    if {![file isdirectory $destDir]} { file mkdir $destDir }

    # Copy
    file copy $source $dest
}

puts "Done"

Upvotes: 1

Related Questions