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 | if {![file exists $targetdir]} { |
---|
43 | puts "making directory $targetdir..." |
---|
44 | file mkdir $targetdir |
---|
45 | } |
---|
46 | |
---|
47 | set origdir [pwd] |
---|
48 | foreach context {. ../gui} { |
---|
49 | cd $context |
---|
50 | |
---|
51 | foreach file [find .] { |
---|
52 | set target [file join $targetdir $file] |
---|
53 | if {[file isdirectory $file]} { |
---|
54 | puts "making directory $target..." |
---|
55 | catch {file mkdir $target} |
---|
56 | file attributes $target -permissions ugo+rx |
---|
57 | } else { |
---|
58 | puts "installing $target..." |
---|
59 | file copy -force $file $target |
---|
60 | file attributes $target -permissions ugo+r |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | cd .. |
---|
66 | catch {file mkdir [file join $targetdir lib]} |
---|
67 | foreach file [find ./lib] { |
---|
68 | set target [file join $targetdir $file] |
---|
69 | if {[file isdirectory $file]} { |
---|
70 | puts "making directory $target..." |
---|
71 | catch {file mkdir $target} |
---|
72 | file attributes $target -permissions ugo+rx |
---|
73 | } else { |
---|
74 | puts "installing $target..." |
---|
75 | file copy -force $file $target |
---|
76 | file attributes $target -permissions ugo+r |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | cd $origdir |
---|
81 | |
---|
82 | set fid [open [file join $targetdir pkgIndex.tcl] w] |
---|
83 | puts $fid "# Tcl package index file" |
---|
84 | puts $fid "package ifneeded $package $version \"" |
---|
85 | puts $fid " \[list lappend auto_path \[file join \$dir scripts\]\]" |
---|
86 | puts $fid " namespace eval Rappture \[list variable installdir \$dir\]" |
---|
87 | puts $fid " package provide $package $version" |
---|
88 | puts $fid "\"" |
---|
89 | close $fid |
---|
90 | |
---|
91 | mkindex [file join $targetdir scripts] |
---|
92 | |
---|
93 | puts "== $package-$version INSTALLED" |
---|