-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfetch_sources.sh
More file actions
executable file
·404 lines (359 loc) · 9.98 KB
/
Copy pathfetch_sources.sh
File metadata and controls
executable file
·404 lines (359 loc) · 9.98 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#!/bin/sh
#-------------------------------------------------------------------------------
# Script to fetch sources for the tools and utilities
#-------------------------------------------------------------------------------
rep_list=""
upd_list=""
count=0
# get host out of our .git/config file
#GITHOST=git@github.com:AquaticEcoDynamics/
HOST=`grep 'url = ' .git/config | sed -e 's/url = //' | sed -e 's/AquaticEcoDynamics/\n/' | head -1`
PLUS=`grep 'url = ' .git/config | sed -e 's/url = //' | sed -e 's/AquaticEcoDynamics/\n/' | tail -1`
if [ "$PLUS" = "/AED_Tools_Private" ] ; then
PLUS="true"
else
PLUS=false
fi
GITHOST="$HOST/AquaticEcoDynamics/"
GET_GLM="false"
GET_AED="false"
GETAED2="false"
GETPLOT="false"
GETUTIL="false"
GETPLUS="$PLUS"
GET_ELC="false"
GETAEDFV="false"
GET_EGS="false"
GETFABM="false"
GET_TFV="false"
GETGOTM="false"
GET_SWN="false"
GET_PHQ="false"
GET_SHZ="false"
GETMODF="false"
GETTELM="false"
GET_D3D="false"
if [ $# -eq 0 ] ; then
# The default case is to just update
upd_list="libaed-api libaed-water libaed-benthic libaed-riparian libaed-demo libaed-dev libaed-light libplot libutil libaed-fv libaed2 libaed2-plus GLM ELCOM"
fi
#-------------------------------------------------------------------------------
while [ $# -gt 0 ] ; do
#echo $# : $1
case $1 in
all)
GET_GLM="true"
GET_AED="true"
GETPLOT="true"
GETUTIL="true"
GETAEDFV="true"
if [ "$PLUS" = "true" ] ; then GETPLUS="true" ; fi
GET_ELC="true"
;;
GLM|glm)
GET_GLM="true"
GET_AED="true"
GETPLOT="true"
GETUTIL="true"
;;
aed-fv)
GETAEDFV="true"
GET_AED="true"
;;
libaed)
GET_AED="true"
;;
libaed2)
GETAED2="true"
;;
libplot)
GETPLOT="true"
;;
libutil)
GETUTIL="true"
;;
plus)
GETPLUS="true"
GET_PHQ="true"
;;
ELCOM|elcom)
GET_ELC="true"
;;
aed2)
GETAED2="true"
;;
examples)
GET_EGS="true"
;;
TUFLOWFV|tuflowfv)
GET_TFV="true"
GETGOTM="true"
GETAEDFV="true"
GET_AED="true"
GET_SWN="true"
;;
gotm)
GETGOTM="true"
;;
fabm)
GETFABM="true"
;;
swan)
GET_SWN="true"
;;
schism)
GET_SHZ="true"
;;
modflow)
GETMODF="true"
;;
phreeqcrm)
GET_PHQ="true"
;;
telemac)
GETTELM="true"
;;
delft3d)
GET_D3D="true"
;;
# -g|--githost)
# GITHOST="$2"
# shift # skip argument
# ;;
*)
echo "Unknown option \"$1\""
exit 1
;;
esac
shift # next
done
if [ "$GET_GLM" = "true" ] ; then rep_list="$rep_list GLM" ; fi
if [ "$GETAEDFV" = "true" ] ; then rep_list="$rep_list libaed-fv" ; fi
if [ "$GET_AED" = "true" ] ; then rep_list="$rep_list libaed-api libaed-water libaed-benthic libaed-demo" ; fi
if [ "$GETPLUS" = "true" ] ; then rep_list="$rep_list libaed-riparian libaed-dev libaed-light libplot libutil" ; fi
if [ "$GETAED2" = "true" ] ; then
echo "Warning: libaed2 is now deprecated"
rep_list="$rep_list libaed2"
if [ "$GETPLUS" = "true" ] ; then rep_list="$rep_list libaed2-plus" ; fi
fi
if [ "$GETPLOT" = "true" ] ; then rep_list="$rep_list libplot" ; fi
if [ "$GETUTIL" = "true" ] ; then rep_list="$rep_list libutil" ; fi
if [ "$GET_ELC" = "true" ] ; then rep_list="$rep_list ELCOM" ; fi
if [ "$GET_EGS" = "true" ] ; then rep_list="$rep_list GLM_Examples" ; fi
#-------------------------------------------------------------------------------
fetch_it () {
src=$1
dst=$2
echo "===================================================="
if [ "$dst" = "" ] ; then
dst=$src
fi
if [ -d $dst ] ; then
echo "Updating $dst from " `grep -w url $dst/.git/config`
cd $dst
BRANCH=`git branch | grep '*' | cut -f2 -d\ `
git pull origin $BRANCH
git fetch --all --prune
cd ..
else
echo "fetching $src from ${GITHOST}$src $dst"
git clone ${GITHOST}$src $dst
fi
}
#-------------------------------------------------------------------------------
fetch_3rd () {
srcdir=$1
dstdir=$2
if [ "${dstdir}" = "" ] ; then dstdir=$srcdir ; fi
# glog=`cat third-party/gitlog-${dstdir}`
if [ -f ${dstdir}-aed/gitlog-${dstdir} ] ; then
glog=`cat ${dstdir}-aed/gitlog-${dstdir}`
elif [ -f third-party/gitlog-${dstdir} ] ; then
glog=`cat third-party/gitlog-${dstdir}`
else
glog=""
fi
echo "===================================================="
if [ -d ${dstdir} ] ; then
echo "Updating ${dstdir} from " `grep -w url ${dstdir}/.git/config`
cd ${dstdir}
DETACHED=`git status | grep 'HEAD detached at'`
git checkout .
if [ "$DETACHED" != "" ] ; then git switch - ; fi
git pull
git fetch --all --prune
cd ..
else
echo "fetching $srcdir from ${GITHOST}${srcdir} ${dstdir}"
git clone --recurse-submodules ${GITHOST}${srcdir} ${dstdir}
fi
if [ -d ${dstdir} ] ; then
if [ "${glog}" != "" ] ; then
cd ${dstdir}
git checkout $glog
cd ..
fi
fi
if [ -d ${dstdir} ] ; then
if [ -f ${dstdir}-aed/aed-${dstdir}.xdiff ] ; then
patchf="${dstdir}-aed/aed-${dstdir}.xdiff"
elif [ -f third-party/aed-${dstdir}.xdiff ] ; then
patchf="third-party/aed-${dstdir}.xdiff"
else
patchf=""
fi
if [ "$patchf" != "" ] ; then
if [ -L a ] ; then /bin/rm a ; fi
ln -s ${dstdir} a
patch -p0 < ${patchf}
/bin/rm a
fi
fi
}
#-------------------------------------------------------------------------------
if [ "$upd_list" != "" ] ; then
echo "Updating . from " `grep -w url .git/config`
git pull
for src in $upd_list ; do
if [ -d $src ] ; then
count=$((count+1))
echo "Updating $src from " `grep -w url $src/.git/config`
cd $src
BRANCH=`git branch | grep '*' | cut -f2 -d\ `
git pull origin $BRANCH
git fetch --all --prune
cd ..
fi
done
elif [ "$rep_list" != "" ] ; then
# echo list = $rep_list
if [ "$GITHOST" = "" ] ; then
REPOS=`grep -w url .git/config | cut -d\ -f3`
NWORDS=`echo $REPOS | cut -d: -f2 | sed 's:/: :g' | wc -w`
if [ "`echo $REPOS | grep '@'`" != "" ] ; then
if [ $NWORDS = 1 ] ; then #
GITHOST=`echo $REPOS | cut -d: -f1`:
else
NWORDS=`expr $NWORDS - 1`
GITHOST=`echo $REPOS | cut -d\/ -f-$NWORDS`/
fi
else
NWORDS=`expr $NWORDS + 1`
GITHOST=`echo $REPOS | cut -d\/ -f-$NWORDS`/
fi
fi
# echo GITHOST is $GITHOST
for src in $rep_list ; do
count=$((count+1))
fetch_it $src
done
fi
#-------------------------------------------------------------------------------
if [ "$GETFABM" = "true" ] ; then
count=$((count+1))
GITHOST=https://github.com/fabm-model/
fetch_3rd fabm.git fabm-git
fi
if [ "$GETGOTM" = "true" ] ; then
count=$((count+1))
GITHOST=https://github.com/gotm-model/
fetch_3rd code gotm-git
fi
if [ "$GET_SWN" = "true" ] ; then
count=$((count+1))
GITHOST=https://gitlab.tudelft.nl/citg/wavemodels/
fetch_3rd swan
fi
if [ "$GET_PHQ" = "true" ] ; then
count=$((count+1))
GITHOST=https://github.com/usgs-coupled/
fetch_3rd phreeqcrm
fi
if [ "$GET_SHZ" = "true" ] ; then
count=$((count+1))
GITHOST=https://github.com/schism-dev/
fetch_3rd schism
if [ -d schism ] ; then
if [ ! -e schism/src/AED ] ; then
cd schism/src
ln -s ../../schism-aed/src/AED .
cd ../..
fi
fi
fi
if [ "$GETMODF" = "true" ] ; then
count=$((count+1))
GITHOST=https://github.com/MODFLOW-ORG/
fetch_3rd modflow6
fi
if [ "$GETTELM" = "true" ] ; then
count=$((count+1))
GITHOST=https://gitlab.pam-retd.fr/otm/
fetch_3rd telemac-mascaret telemac
fi
if [ "$GET_D3D" = "true" ] ; then
count=$((count+1))
GITHOST=https://github.com/Deltares/
fetch_3rd Delft3D delft3d
fi
#-------------------------------------------------------------------------------
if [ "$GET_TFV" = "true" ] ; then
count=$((count+1))
# ME=`hostname -f`
# WHEREAMI=`echo $ME | cut -d. -f2-`
# if [ "$WHEREAMI" != "aed-net.science.uwa.edu.au" ] ; then
# echo "It looks like you are not in the aed network, you probably can't get tuflowfv sources"
# fi
if [ -d tuflowfv-lib ] ; then
src='tuflowfv-lib'
echo "Updating $src from " `grep -w url $src/.git/config`
cd tuflowfv-lib
git pull
cd ..
else
GITHOST=git@githost.aed-net.science.uwa.edu.au:
fetch_it tuflowfv-lib
fi
# This may need tweaking
if [ "`hostname`" = "phyto" ] ; then
if [ -d tuflowfv ] ; then
src='tuflowfv'
echo "Updating $src from " `grep -w url $src/.git/config`
cd tuflowfv
git pull
git fetch --all --prune
cd ..
else
GITHOST=git@githost.aed-net.science.uwa.edu.au:
fetch_it tuflowfv-aed tuflowfv
fi
fi
fi
#-------------------------------------------------------------------------------
if [ $count -eq 0 ] ; then
echo "There do not seem to be any repositories requested or present"
echo "Usage : "
echo " fetch_sources.sh [-g <githost>] <repo>"
echo
echo "where <repo> can be one or more of :"
echo " glm : get glm [and it's dependancies]"
echo " elcom : fetch the ELCOM sources"
echo " libaed : fetch the libaed-\* sources"
echo " libplot : fetch the libplot sources"
echo " libutil : fetch the libutil sources"
echo " plus : fetch the libaed-\* plus sources (private repository)"
echo " aed-fv : fetch the libaed-fv sources"
echo
echo " schism : fetch the schism source"
echo " swan : fetch the swan sources from delftU"
echo " phreeqcrm : fetch the phreeqcrm sources from water.usgs.gov"
echo " modflow6 : fetch the modflow source"
echo " delft3d : fetch the 'delft3d 4' and 'delft3d fm' sources"
echo " telemac : fetch the telemac-mascaret source"
echo
echo " all : fetch all of glm, elcom aed-fv and their requirements"
# echo
# echo " -g|--githost <githost> : allows you to specify a different githost"
# echo " The default is https://github.com/AquaticEcoDynamics/"
fi
exit 0