[1] | 1 | #!/bin/sh |
---|
| 2 | # ---------------------------------------------------------------------- |
---|
| 3 | # USAGE: tclsh install |
---|
| 4 | # |
---|
| 5 | # Use this script to install the Rappture toolkit into an existing |
---|
| 6 | # Tcl installation. |
---|
| 7 | # ====================================================================== |
---|
| 8 | # AUTHOR: Michael McLennan, Purdue University |
---|
| 9 | # Copyright (c) 2004 Purdue Research Foundation, West Lafayette, IN |
---|
| 10 | # ====================================================================== |
---|
| 11 | #\ |
---|
| 12 | exec tclsh "$0" "$*" |
---|
| 13 | # ---------------------------------------------------------------------- |
---|
| 14 | # tclsh executes everything from here on... |
---|
| 15 | |
---|
| 16 | # run this script from directory containing it |
---|
| 17 | cd [file dirname [info script]] |
---|
| 18 | |
---|
| 19 | set package "Rappture" |
---|
| 20 | set version "0.9" |
---|
| 21 | |
---|
| 22 | proc find {dir} { |
---|
| 23 | set flist "" |
---|
| 24 | foreach name [glob [file join $dir *]] { |
---|
| 25 | lappend flist $name |
---|
| 26 | if {[file isdirectory $name]} { |
---|
| 27 | eval lappend flist [find $name] |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | return $flist |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | proc mkindex {dir} { |
---|
| 34 | package require Itcl ;# index Itcl files too! |
---|
| 35 | auto_mkindex $dir *.tcl |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | set dir [file dirname [info library]] |
---|
| 40 | set targetdir [file join $dir $package$version] |
---|
| 41 | |
---|
| 42 | mkindex scripts |
---|
| 43 | |
---|
| 44 | if {![file exists $targetdir]} { |
---|
| 45 | puts "making directory $targetdir..." |
---|
| 46 | file mkdir $targetdir |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | foreach file [find .] { |
---|
| 50 | set target [file join $targetdir $file] |
---|
| 51 | if {[file isdirectory $file]} { |
---|
| 52 | puts "making directory $target..." |
---|
| 53 | catch {file mkdir $target} |
---|
| 54 | file attributes $target -permissions ugo+rx |
---|
| 55 | } else { |
---|
| 56 | puts "installing $target..." |
---|
| 57 | file copy -force $file $target |
---|
| 58 | file attributes $target -permissions ugo+r |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | set fid [open [file join $targetdir pkgIndex.tcl] w] |
---|
| 63 | puts $fid "# Tcl package index file" |
---|
| 64 | puts $fid "package ifneeded $package $version \"" |
---|
| 65 | puts $fid " \[list lappend auto_path \[file join \$dir scripts\]\]" |
---|
| 66 | puts $fid " namespace eval Rappture \[list variable installdir \$dir\]" |
---|
| 67 | puts $fid " package provide $package $version" |
---|
| 68 | puts $fid "\"" |
---|
| 69 | close $fid |
---|
| 70 | |
---|
| 71 | puts "== $package-$version INSTALLED" |
---|