3280
|
1 #!/bin/sh |
|
2 # |
|
3 # install-ocst -- install/update Octave Controls Toolbox (OCST) |
|
4 # of A. Scottedward Hodel <A.S.Hodel@Eng.Auburn.EDU> |
|
5 # |
|
6 # This script uses chunks of "install-octave" |
|
7 # from John W. Eaton <jwe@bevo.che.wisc.edu> |
|
8 # |
|
9 # Kai P Mueller <mueller@ifr.ing.tu-bs.-de>, TU Braunschweig |
|
10 # 11/22/97 initial version |
|
11 # |
|
12 |
|
13 if [ $# -ne 1 ] |
|
14 then |
|
15 echo |
|
16 echo " usage: $0 (help | all | select)" |
|
17 echo |
|
18 exit 1 |
|
19 fi |
|
20 |
|
21 case $1 in |
|
22 |
|
23 help) |
|
24 cat << EOF |
|
25 ========================================================================== |
|
26 install-ocst attempts to install (or update) the OCST (Octave controls |
|
27 toolbox) of your version of Octave. |
|
28 |
|
29 The files in the subdirectories "general", "linear-algebra", |
|
30 "strings", "plot", and "control" will be copied to the Octave data |
|
31 directories with proper permissions. |
|
32 |
|
33 If the file "obsolete.files" exists this script file fill |
|
34 ask if the files listed in "obsolete.files" should be removed. |
|
35 |
|
36 The install and update procedures differ in the way they perform the |
|
37 copy of the files in this OCST version. |
|
38 |
|
39 o all Copy all files to the Octave data directories assuming that |
|
40 this version is newer. Install does not ask any questions. |
|
41 This modfe is best if you are the system administrator you |
|
42 just want to install the control stuff. |
|
43 |
|
44 o select Copy all files but ask before replacing an existing file |
|
45 which differs from the one in this distribution. The update |
|
46 mode is appropriate for developers. New files will be |
|
47 copied without confirmation. |
|
48 Note: it can be very annoying to confirm the replacements. |
|
49 ========================================================================== |
|
50 EOF |
|
51 exit 0 |
|
52 ;; |
|
53 |
|
54 all) |
|
55 ask=no |
|
56 ;; |
|
57 |
|
58 select) |
|
59 ask=yes |
|
60 ;; |
|
61 |
|
62 *) |
|
63 echo |
|
64 echo " usage: $0 (help | all | select)" |
|
65 echo |
|
66 exit 1 |
|
67 ;; |
|
68 esac |
|
69 |
|
70 if [ `whoami` != root ] |
|
71 then |
|
72 echo -n " * You should execute install-ocst as root, continue anyway? [n]: " |
|
73 read ans |
|
74 case "$ans" in |
|
75 y | Y | yes | YES) |
|
76 ;; |
|
77 *) |
|
78 exit 1 |
|
79 ;; |
|
80 esac |
|
81 fi |
|
82 |
|
83 # change location of the distribution file here: |
|
84 ocst_version=1.2 |
|
85 datadir=/usr/local/share |
|
86 oct_version=2.0.12 |
|
87 |
|
88 echo |
|
89 echo " - This is the OCST V$ocst_version update procedure -" |
|
90 |
|
91 # change everything below at your own risk. |
|
92 # check data directory |
|
93 echo |
|
94 echo -n " * Octave data dir is $datadir/octave; is that correct? [y]: " |
|
95 read ans |
|
96 case "$ans" in |
|
97 n | N | no | NO) |
|
98 echo -n " * Enter Octave data dir (without /octave/...): " |
|
99 read datadir |
|
100 ;; |
|
101 esac |
|
102 if [ ! -d "$datadir/octave" ] |
|
103 then |
|
104 echo "install-ocst: Octave dir ($datadir/octave) does not exist - Goodbye." |
|
105 exit 1 |
|
106 fi |
|
107 |
|
108 # check Octave version |
|
109 echo |
|
110 echo -n " * Octave version is $oct_version; is that correct? [y]: " |
|
111 read ans |
|
112 case "$ans" in |
|
113 n | N | no | NO) |
|
114 echo -n " * Enter Octave version: " |
|
115 read oct_version |
|
116 ;; |
|
117 esac |
|
118 toplevel=$datadir/octave/$oct_version/m |
|
119 if [ ! -d $toplevel ] |
|
120 then |
|
121 echo "install-ocst: toplevel dir ($toplevel) does not exist - Goodbye." |
|
122 exit 1 |
|
123 fi |
|
124 |
|
125 # perform installation |
|
126 echo |
|
127 echo -n " * This is your last chance to quit, continue installation? [y]: " |
|
128 read ans |
|
129 case "$ans" in |
|
130 n | N | no | NO) |
|
131 echo "install-ocst aborted." |
|
132 exit 0 |
|
133 ;; |
|
134 esac |
|
135 |
|
136 echo |
|
137 distdir=`pwd` |
|
138 for dd in general linear-algebra strings plot control |
|
139 do |
|
140 if [ -d "$dd" ] |
|
141 then |
|
142 echo " o installing files in $dd..." |
|
143 cd $dd |
|
144 for ff in `ls` |
|
145 do |
|
146 if [ $ask = yes ] |
|
147 then |
|
148 if [ -e "$toplevel/$dd/$ff" ] |
|
149 then |
|
150 diff $ff "$toplevel/$dd/$ff" > /dev/null |
|
151 if [ "$?" = 0 ] |
|
152 then |
|
153 # files are identical; do not copy |
|
154 echo "---> $ff (same version does already exist, no replacement)" |
|
155 else |
|
156 # file already exit, our version is (possible) newer |
|
157 echo -n " * Replace existing $ff? [y]: " |
|
158 read ans |
|
159 case "$ans" in |
|
160 n | N | no | NO) |
|
161 echo "---> $ff skipped." |
|
162 ;; |
|
163 *) |
|
164 cp $ff $toplevel/$dd |
|
165 chmod 644 $toplevel/$dd/$ff |
|
166 ;; |
|
167 esac |
|
168 fi |
|
169 else |
|
170 echo "---> $ff (new file)" |
|
171 cp $ff $toplevel/$dd |
|
172 chmod 644 $toplevel/$dd/$ff |
|
173 fi |
|
174 else |
|
175 # copy everything without asking |
|
176 cp $ff $toplevel/$dd |
|
177 chmod 644 $toplevel/$dd/$ff |
|
178 fi |
|
179 done |
|
180 echo " ...files in $dd installed." |
|
181 fi |
|
182 cd $distdir |
|
183 done |
|
184 |
|
185 # check for "obsolete.files" |
|
186 if [ ! -r obsolete.files ] |
|
187 then |
|
188 echo " o No obsolete files." |
|
189 else |
|
190 echo " o removing obsolete files..." |
|
191 flist=`cat obsolete.files` |
|
192 for ff in $flist |
|
193 do |
|
194 dfile=$toplevel/$ff |
|
195 if [ ! -e "$dfile" ] |
|
196 then |
|
197 echo " * no obsolete file: $ff" |
|
198 else |
|
199 echo -n " * remove $ff? [n]: " |
|
200 read ans |
|
201 case "$ans" in |
|
202 y | Y | yes | YES) |
|
203 rm $dfile |
|
204 ;; |
|
205 esac |
|
206 fi |
|
207 done |
|
208 fi |
|
209 |
|
210 echo |
|
211 echo " All files have been installed. Now to the final question:" |
|
212 echo |
|
213 |
|
214 echo -n " * Replace/create ls-R file? [y]: " |
|
215 read ans |
|
216 case "$ans" in |
|
217 n | N | no | NO) |
|
218 echo "--> no new ls-R file." |
|
219 ;; |
|
220 *) |
|
221 if [ -d "$datadir/libexec" ] |
|
222 then |
|
223 echo "install-ocst: libexec directory found." |
|
224 ls -LR $datadir/octave $libexecdir/octave > $datadir/octave/ls-R |
|
225 else |
|
226 echo "install-ocst: libexec directory not found." |
|
227 echo " (you can safely ingnore this message.)" |
|
228 ls -LR $datadir/octave > $datadir/octave/ls-R |
|
229 fi |
|
230 ;; |
|
231 esac |
|
232 |
|
233 echo "Thank you for using install-ocst." |
|
234 exit 0 |