-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.tcl
executable file
·154 lines (126 loc) · 3.74 KB
/
install.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# install.tcl --
# Install PLplot
#
# exitInstall --
# Quit the installation - with a message
#
# Arguments:
# None
#
# Side effects:
# Simply quit the program after displaying a message
#
proc exitInstall {} {
tk_messageBox -icon info -message "Installation cancelled" -type ok -title "PLplot installation"
exit
}
# replaceInstallDir --
# Replace the string "INSTALLDIR" in the given file
#
# Arguments:
# filename Name of the file to be treated
#
# Side effects:
# Replace the string
#
proc replaceInstallDir {filename} {
global dir
set infile [open $filename]
set content [read $infile]
close $infile
set outfile [open $filename w]
puts $outfile [string map [list INSTALLDIR $dir] $content]
close $outfile
}
# selectInstallDir --
# Select the installation directory
#
# Arguments:
# None
#
# Side effects:
# Sets variable dir
#
proc selectInstallDir {} {
global dir
set newdir [tk_chooseDirectory -initialdir $dir -title "Select installation directory"]
if { $newdir != "" } {
set dir $newdir
}
}
# installPLplot --
# Start the installation
#
# Arguments:
# None
#
# Side effects:
# Creates the installation directory (if necessary) and copies the files
# then adjusts the two batch files.
#
proc installPLplot {} {
global scriptdir
global dir
console show
#set appdir [file join $scriptdir ".." ".." "plplot"]
set appdir $scriptdir
set installdir [file normalize $dir]
if { ! [file exists $installdir] } {
file mkdir $installdir
}
set contents [glob -nocomplain [file join $installdir *]]
if { [llength $contents] == 0 } {
set dummyfile [open [file join $installdir dummy] "w"]
close $dummyfile
}
foreach file [glob [file join $installdir *]] {
puts "Deleting: $file"
file delete -force $file
}
foreach file [glob [file join $appdir *]] {
puts "Copying: $file"
file copy -force $file $installdir
}
cd $installdir
replaceInstallDir "plplot_vars.bat"
replaceInstallDir "bin/fortpl.bat"
tk_messageBox -icon info -message "Installation completed" -type ok -title "PLplot installation"
exit
}
#
# Store the directory containing the script for later use
#
set scriptdir [file dirname [info script]]
#
# Set up the main (and only window)
#
set dir "c:\\plplot"
wm title . "PLplot - installation for Fortran"
grid [text .t -yscrollcommand ".y set"] [::ttk::scrollbar .y -orient vertical -command ".t yview"] -sticky news
grid [label .inbetween -text " "] -
frame .f1
frame .f2
grid [::ttk::label .f1.label -text "Installation directory:"] \
[::ttk::entry .f1.dir -textvariable dir] \
[::ttk::button .f1.select -text "Select" -command selectInstallDir] \
-padx 4 -pady 4 -sticky news
grid columnconfigure .f1 1 -weight 1
grid [::ttk::label .f2.label1 -text " "] \
[::ttk::button .f2.install -text Install -command installPLplot -width 10] \
[::ttk::label .f2.label2 -text " "] \
[::ttk::button .f2.cancel -text Cancel -command exitInstall -width 10] \
[::ttk::label .f2.label3 -text " "] -padx 10 -pady 4 -sticky news
grid columnconfigure .f2 0 -weight 1
grid columnconfigure .f2 2 -weight 1
grid columnconfigure .f2 4 -weight 1
grid .f1 - -sticky news
grid .f2 - -sticky news
grid columnconfigure . 0 -weight 1
grid columnconfigure . 1 -weight 0
grid rowconfigure . 1 -weight 0
grid rowconfigure . 2 -weight 0
set infile [open "readme.txt"]
set content [read $infile]
close $infile
.t insert end $content
.t configure -state disabled