1 | # ---------------------------------------------------------------------- |
---|
2 | # USAGE: tclsh install.tcl |
---|
3 | # |
---|
4 | # Use this script to install the Rappture toolkit into an existing |
---|
5 | # Tcl installation. |
---|
6 | # ====================================================================== |
---|
7 | # AUTHOR: Michael McLennan, Purdue University |
---|
8 | # Copyright (c) 2004-2005 Purdue Research Foundation |
---|
9 | # |
---|
10 | # See the file "license.terms" for information on usage and |
---|
11 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
12 | # ====================================================================== |
---|
13 | |
---|
14 | # run this script from directory containing it |
---|
15 | cd [file dirname [info script]] |
---|
16 | |
---|
17 | set package "Rappture" |
---|
18 | set version "0.9" |
---|
19 | |
---|
20 | proc find {dir} { |
---|
21 | set flist "" |
---|
22 | foreach name [glob [file join $dir *]] { |
---|
23 | lappend flist $name |
---|
24 | if {[file isdirectory $name]} { |
---|
25 | eval lappend flist [find $name] |
---|
26 | } |
---|
27 | } |
---|
28 | return $flist |
---|
29 | } |
---|
30 | |
---|
31 | proc mkindex {dir} { |
---|
32 | package require Itcl ;# index Itcl files too! |
---|
33 | auto_mkindex $dir *.tcl |
---|
34 | } |
---|
35 | |
---|
36 | proc fixperms {target perms} { |
---|
37 | global tcl_platform |
---|
38 | if {$tcl_platform(platform) == "unix"} { |
---|
39 | file attributes $target -permissions $perms |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | set dir [file dirname [info library]] |
---|
45 | set targetdir [file join $dir $package$version] |
---|
46 | |
---|
47 | if {![file exists $targetdir]} { |
---|
48 | puts "making directory $targetdir..." |
---|
49 | file mkdir $targetdir |
---|
50 | } |
---|
51 | |
---|
52 | set origdir [pwd] |
---|
53 | foreach context {. ../gui} { |
---|
54 | cd $context |
---|
55 | |
---|
56 | foreach file [find .] { |
---|
57 | set target [file join $targetdir $file] |
---|
58 | if {[file isdirectory $file]} { |
---|
59 | puts "making directory $target..." |
---|
60 | catch {file mkdir $target} |
---|
61 | fixperms $target ugo+rx |
---|
62 | } else { |
---|
63 | puts "installing $target..." |
---|
64 | file copy -force $file $target |
---|
65 | fixperms $target ugo+r |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | cd .. |
---|
71 | catch {file mkdir [file join $targetdir lib]} |
---|
72 | foreach file [find ./lib] { |
---|
73 | set target [file join $targetdir $file] |
---|
74 | if {[file isdirectory $file]} { |
---|
75 | puts "making directory $target..." |
---|
76 | catch {file mkdir $target} |
---|
77 | fixperms $target ugo+rx |
---|
78 | } else { |
---|
79 | puts "installing $target..." |
---|
80 | file copy -force $file $target |
---|
81 | fixperms $target ugo+r |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | cd $origdir |
---|
86 | |
---|
87 | set fid [open [file join $targetdir pkgIndex.tcl] w] |
---|
88 | puts $fid "# Tcl package index file" |
---|
89 | puts $fid "package ifneeded $package $version \"" |
---|
90 | puts $fid " \[list lappend auto_path \[file join \$dir scripts\]\]" |
---|
91 | puts $fid " namespace eval \[list Rappture \[list variable installdir \$dir\]\]" |
---|
92 | puts $fid " package provide $package $version" |
---|
93 | puts $fid "\"" |
---|
94 | close $fid |
---|
95 | |
---|
96 | mkindex [file join $targetdir scripts] |
---|
97 | |
---|
98 | if {[string match wish* [file tail [info nameofexecutable]]]} { |
---|
99 | package require Tk |
---|
100 | wm withdraw . |
---|
101 | tk_messageBox -icon info -message "$package-$version INSTALLED" |
---|
102 | } else { |
---|
103 | puts "== $package-$version INSTALLED" |
---|
104 | } |
---|
105 | exit 0 |
---|