Debian Codegraph @

install/unix/preinstall

raw symbols SCIP
1 #! /bin/bash
2 # .TYPE command
3 # .NAME preinstall.sh
4 # .LANGUAGE shell script
5 # .ENVIRONMENT Unix Systems. Executable under Bourne shell
6 # .COMMENTS
7 # Usage: preinstall
8 #
9 # The preinstall command will :
10 #
11 # a) Copy files from:
12 #
13 # $MID_INSTALL/install/unix/systems/<system>
14 # to
15 # $MID_HOME/local
16 #
17 #
18 # .AUTHOR Carlos Guirao
19 # .VERSION 1.1 881023: Implementation
20 # .VERSION 1.3 910424: Removing first argument
21 # .VERSION 2.1 910725: Much easier.
22 # .VERSION 2.2 910917: Much easier yet.
23 # .VERSION 3.2 930727: Using output of uname command.
24 # .VERSION 3.3 021028: Using -a argument for all packages
25 #
26 # 120420 last modif
27
28 echo=echo
29 if [ "$1" != "-a" ]; then
30 if [ "`echo -n`" = "-n" ] ; then
31 SV_NONL="\c"
32 else
33 echo="echo -n"
34 fi
35 fi
36
37 #
38 # First of all, goto the config directory
39 # <dirname> & <basename> commands emulated with <sed>
40 #
41 if [ -z "$MIDASHOME" -o -z "$MIDVERS" ] ; then
42 cd `echo $0 | sed -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'`
43 MID_INSTALL=`pwd`
44 VERSDIR=`echo $MID_INSTALL | sed 's/\/install\/unix$//'`
45 MIDVERS=`echo $VERSDIR | sed -e 's/^.*\///'`
46 MIDASHOME=`echo $VERSDIR | sed -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'`
47 else
48 cd $MIDASHOME/$MIDVERS/install/unix
49 fi
50
51 MID_INSTALL=$MIDASHOME/$MIDVERS/install/unix
52 MID_HOME=$MIDASHOME/$MIDVERS
53
54 if [ ! -d $MID_HOME/local ]; then
55 mkdir $MID_HOME/local
56 fi
57
58 if [ ! -d $MID_HOME/pipeline ]; then
59 mkdir $MID_HOME/pipeline
60 chmod 775 $MID_HOME/pipeline
61 fi
62
63 if [ -f $MID_HOME/local/default.mk ]; then
64 rm -f $MID_HOME/local/default.mk~
65 mv $MID_HOME/local/default.mk $MID_HOME/local/default.mk~
66 fi
67
68 if [ -f $MID_HOME/local/preinstall ]; then
69 mv $MID_HOME/local/preinstall $MID_HOME/local/preinstall~
70 fi
71
72 while :
73 do
74 echo ""
75 echo "Your current definitions:"
76 echo "------------------------"
77 echo "MIDASHOME=$MIDASHOME"
78 echo "MIDVERS=$MIDVERS"
79 echo ""
80 $echo "Do you want to modify these definitions [yn]? (n): " $SV_NONL
81 if [ "$1" != "-a" ]; then
82 read answ
83 fi
84 if [ -z "$answ" ]; then
85 break
86 fi
87 if [ "$answ" = "n" -o "$answ" = "N" ]; then
88 break
89 fi
90 while :
91 do
92 $echo "MIDASHOME: " $SV_NONL
93 read MIDASHOME
94 if [ ! -d $MIDASHOME ]; then
95 echo "No such directory: $MIDASHOME"
96 continue
97 else
98 break
99 fi
100 done
101 while :
102 do
103 $echo "MIDVERS: " $SV_NONL
104 read MIDVERS
105 if [ ! -d $MIDASHOME/$MIDVERS ]; then
106 echo "No such directory: $MIDASHOME/$MIDVERS"
107 continue
108 else
109 break
110 fi
111 done
112 done
113
114 (echo "MIDASHOME=$MIDASHOME"; echo "MIDVERS=$MIDVERS" ) | cat - default_mk \
115 > $MIDASHOME/$MIDVERS/local/default.mk
116 echo "File $MIDASHOME/$MIDVERS/local/default.mk created."
117
118 cd systems
119 uname=`(uname) | sed 's/\//-/g' 2>/dev/null`
120 unode=`(uname -n) 2>/dev/null`
121 urels=`(uname -r) 2>/dev/null`
122 machine=`(uname -m) 2>/dev/null`
123
124 if [ -d "Debian" -a -f "/etc/debian_version" ]; then
125 system="Debian"
126
127 elif [ "$uname" = "Darwin" ]; then
128 system="Darwin"
129
130 elif [ "$machine" = "x86_64" ]; then
131 system="Linux_AMD64"
132
133 elif [ -d "${uname}_$urels" ]; then
134 system="${uname}_$urels"
135
136 elif [ -d "${uname}_$machine" ]; then
137 system="${uname}_$machine"
138
139 elif [ -d "$uname" ]; then
140 system="$uname"
141
142 elif [ -d "$unode" ]; then
143 system="$unode"
144
145 else
146 uname -o 2>/dev/null #not all systems support -o option
147 exitstat=$?
148 if [ $exitstat = 0 ]; then
149 temp=`uname -o`
150 if [ -d "$temp" ]; then
151 system="$temp"
152 fi
153 fi
154 fi
155
156 if [ -z "$system" ]; then
157 echo ""
158 while :
159 do
160 echo "Select your system (or q to QUIT) :"
161 echo ""
162 for i in `ls`
163 do
164 if [ -d $i ]
165 then
166 echo " $i"
167 fi
168 done
169 $echo "System: " $SV_NONL
170 read system
171 if [ "$system" = "q" -o "$system" = "Q" ]; then
172 exit 0
173 fi
174 if [ ! -d "$system" ]; then
175 echo "No such directory: $system"
176 else
177 break
178 fi
179 done
180 else
181 echo system chosen: $system
182 fi
183
184 echo ""
185 echo "All files from the <systems/$system> directory will be copied"
186 echo "into your <$MID_HOME/local> directory"
187 $echo "Do you want to continue [yn]? (y): " $SV_NONL
188 if [ "$1" != "-a" ]; then
189 read answ
190 fi
191 if [ -z "$answ" ]; then
192 answ=y
193 fi
194 if [ "$answ" = "n" -o "$answ" = "N" ]; then
195 exit 0
196 fi
197
198 #
199 # Choose libsrc/ftoc according to $system.
200 #
201 rm -rf $MIDASHOME/$MIDVERS/libsrc/ftoc
202 ln -s $MIDASHOME/$MIDVERS/libsrc/ftoc-new $MIDASHOME/$MIDVERS/libsrc/ftoc
203
204 #
205 # Using the script copy instead of cpio, which not always exists.
206
207 cd $system
208
209 # Option prune does not exist in Ultrix. Anaway SCCS is never included in tape
210 #find . ! \( -name "SCCS" -prune \) -print -exec ../../copy {} \;
211 #find . -print -exec ../../copy {} \;
212 # CG. For some obscure reasons "-print" has to be at the end on IBM6000
213
214 find . -exec ../../copy {} \; -print
215
216 if [ -f "$MID_HOME/local/README" ] ; then
217 cat $MID_HOME/local/README
218 $echo "Type <RETURN> to continue...." $SV_NONL
219 if [ "$1" != "-a" ]; then
220 read key
221 fi
222 fi
223
224 #
225 # CG 15.02.2017 Edit make_options with g77 only if g77 exists
226 #
227 which g77 >/dev/null 2>&1
228 if [ $? -eq 0 ] ; then
229 if [ ! -f $MID_HOME/local/make_options ]; then
230 touch $MID_HOME/local/make_options
231 else
232 G77_F2C_PATH=`g77 -print-libgcc-file-name`
233 G77_F2C_PATH=`dirname $G77_F2C_PATH`
234 echo "F2C_LIBS=-L${G77_F2C_PATH} -lg2c" >> $MID_HOME/local/make_options
235 fi
236 fi
237
238 #
239 # CG 02.05.2011 Edit make_options with gfortran only if gfortran exists
240 #
241 which gfortran >/dev/null 2>&1
242 if [ $? -eq 0 ] ; then
243 if [ ! -f $MID_HOME/local/make_options ]; then
244 touch $MID_HOME/local/make_options
245 else
246 gccversion=`$MID_INSTALL/getvers`
247 if [ "$gccversion" = "gfortran" ] ; then
248 sed -e 's/g77/gfortran/' $MID_HOME/local/make_options > $MID_INSTALL/maky
249 mv $MID_INSTALL/maky $MID_HOME/local/make_options
250 fi
251 fi
252 fi
253
254 echo ""
255 echo "Your MAKE_OPTIONS after pre-install:"
256 echo " <$MID_HOME/local/make_options>"
257 awk -F# '{if ($1 != "") {printf "\t %s\n",$1} }' $MID_HOME/local/make_options
258
259 echo ""
260 echo "Preinstallation of MIDAS completed."
261 $echo "Type <RETURN> to continue...." $SV_NONL
262 if [ "$1" != "-a" ]; then
263 read key
264 fi
265 #
266 # Check if there is a preinstall in the local directory
267 #
268 if [ -f "$MID_HOME/local/preinstall" ] ; then
269 /bin/bash $MID_HOME/local/preinstall
270 fi
271
272 exit