forked from doblerone/QA-DKRZ_FPSCONV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·890 lines (744 loc) · 24.7 KB
/
install
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
#! /bin/bash
package=QA-DKRZ
export CONDA_CMOR_CHANNELS='-c,conda-forge,-c,pcmdi'
export CONDA_QA_CHANNELS='-c,conda-forge,-c,h-dh'
#export CONDA_QA_CHANNELS='-c,birdhouse,-c,conda-forge,--channel birdhouse/label/dev'
export CONDA_QA_ENV
export CONDA_CMOR_ENV
export CONDA_QA_NAME=qa-dkrz
export CONDA_CMOR_NAME=cmor
# overruled by conda installation
hdf5=hdf5-1.8.17
netcdf=netcdf-4.4.1
zlib=zlib-1.2.8
udunits=udunits-2.2.20
valid_projects=( CF CORDEX CMIP5 CMIP6 HAPPI )
# options with auto-update feature (option: --auto-up_feature)
# CMOR_LLNL: the CMOR checker (D. Nadeau, LLNL)
# GIT_QA: all QA updates touching write-protected locations
# QA_SRC: QA sources; disabled for conda-installed QA-DKRZ
# PROJECT_TABLES: Project related tables and programs; PROJECT substituted by
# current projects name(s).
descript()
{
echo "Usage: install [options] [projects[s]]"
echo "Purpose: Install/update 'the DKRZ Quality Control Software Package'"
echo "for checking climate simulation meta-data provided in netCDF format."
echo "Details at https://readthedocs.org/projects/qa-dkrz"
echo ''
echo "Options:"
echo " -B Unconditionally re-make all QA executables."
echo " -d Execute 'make' with debugging information."
echo " -h Display usage and exit."
echo " --auto-up[=expr] Control automatic updates from the repository at the"
echo " beginning of a run. Valid expressions for enabling:"
echo " enable, e, t. Suspending: disable, d, suspend, s."
echo " --build Download and build required libraries."
echo " --conda-cmor-path=path Alias: --ccp=path"
echo " If a separate conda is neither in PATH nor aliased."
echo " --config-file=path HOME/.qa-dkrz/config.txt by default"
echo " --compile Force recompilation, even for a conda repository."
echo " --debug[=script] Display execution commands. If the name of a script"
echo " is assigned, then debug only this one."
echo " --force Force update of the given project."
echo " --help Display usage and exit."
echo " --home=path Same as --qa-tables."
echo " --lcf=path Location of .qa-dkrz/config.txt [~]."
echo " --link=path Hard links of external NetCDF installations from the"
echo " directories in 'your-path/${package}/local'."
echo " Shared by all hdf, netcdf, udunits and zlib."
echo " --link_type=path Same as for 'link' but just for type=netcdf, hdf, zlib, or udunits"
echo " --make-read-only prevent any updating by cp config-file --> QA_SRC."
echo " --net=no Disable internet access."
echo " --qa-tables=path Location of the projects tables and external programs."
echo " Also for user-modified QA tables."
echo " --ship=/path Prepare the current QA-DKRZ installation for shipping."
echo " --show-inst Display properties of the current installation."
echo " --
See ReadTheDocs:installation."
echo " --up[date] Update external packages/tables from respective repository."
echo " Note: not for netCDF, HDF5, udunits2 or zlib."
echo " --up Update the qa-dkrz package when installed by conda."
echo " --update-frequency=num"
echo " --uf and any --uXXX_FYYY is valid; num in days with default [1]"
echo ""
echo ' projects-name(s) At present CF, CMIP5/6, [CORDEX] and HAPPI.'
return
}
freeze()
{
if [ ${UPDATE} ] ; then
if [ ${UPDATE} != "${CFG_UPDATE}" ] ; then
if [ ${isForce} ] ; then
. $QA_SRC/scripts/parseConfigFile UPDATE=${UPDATE}
elif [ "${CFG_UPDATE}" != frozen ] ; then
. $QA_SRC/scripts/parseConfigFile UPDATE=${UPDATE}
fi
fi
else
test ${isForce} && . $QA_SRC/scripts/parseConfigFile UPDATE=frozen
fi
test ${isForce} && return
test "${CFG_UPDATE}" != frozen && return
test "${UPDATE}" != freeze && return
exit 0
}
getSrcPath()
{
local i items p
declare -a items
p=$0
while [ -h $p ] ; do
# resolve symbolic links: cumbersome but robust,
items=( $(ls -l $p) )
i=$((${#items[*]}-1))
p=${items[i]}
done
# only the directory
p=${p%/*}
# resolve relative path
if [ ${p:0:1} != '/' ] ; then
cd $p &> /dev/null
p=$(pwd)
cd - &> /dev/null
fi
export QA_SRC=$p
return
}
log()
{
if [ ${isContinueLog:-f} = f ] ; then
isContinueLog=t
local logTxt="\n$(date +'%F_%T'):"
echo -e "${logTxt} install $*" >> install.log
fi
return
}
progress_wheel()
{
trap progress_wheel_term TERM
progress_wheel_term()
{
echo -n -e "\r \r"
exit 0
}
item=( '-' '\\' '|' '/' '-' '\\' '|' )
while : ; do
for itm in ${item[*]} ; do
echo -n -e "\r$itm"
sleep 0.1
done
done
}
saveAsCycle()
{
for f in $* ; do
if [ ! \( -f $f -o -d $f \) ] ; then
echo "install.saveAsCycle: no such file or directory $f"
return
fi
local ext val x
local maxVal fs fx
maxVal=0
fs=( $(ls -d $f.* 2> /dev/null) )
for fx in ${fs[*]} ; do
ext=${fx##*.}
if val=$(expr match $ext '\([[:digit:]]\+$\)' 2> /dev/null) ; then
test ${val:-0} -gt ${maxVal} && maxVal=${val}
fi
done
mv $f ${f}.$((++maxVal)) 2> /dev/null
done
}
ship()
{
local pth=$1
if [ ! ${pth} ] ; then
echo "--ship requires a path"
exit 41
fi
if ! mkdir -p $pth ; then
echo "--ship=${pth}: could not mkdir/open path"
exit 41
fi
if [ ${pth} ] ; then
test -f $QA_SRC/.ship-qa-config.tx && \rm -f $QA_SRC/.ship-qa-config.txt
. $QA_SRC/scripts/parseConfigFile --ship
# conda or github repo
if [ ${CONDA_QA_PATH} ] ; then
local bp=${CONDA_QA_PATH%/bin/conda}
cd ${bp%/*} &> /dev/null
echo "tar cf ${pth}/QA-DKRZ.tar ${bp##*/} "
progress_wheel &
job_id=$!
tar cf ${pth}/QA-DKRZ.tar ${bp##*/}
kill -TERM $job_id
else
cd ${QA_SRC%/*} &> /dev/null
echo -e "\rtar cf ${pth}/QA-DKRZ.tar QA-DKRZ "
progress_wheel &
job_id=$!
tar cf ${pth}/QA-DKRZ.tar QA-DKRZ
kill -TERM $job_id
fi
. $QA_SRC/scripts/parseConfigFile QA_TABLES
cd ${QA_TABLES%/*} &> /dev/null
echo -e "\rtar cf ${pth}/QA-DKRZ.tar $QA_TABLES "
progress_wheel &
job_id=$!
tar rf ${pth}/QA-DKRZ.tar $QA_TABLES
kill -TERM $job_id
if . $QA_SRC/scripts/parseConfigFile PrePARE ; then
local bp=${PrePARE%/envs/cmor/bin/PrePARE}
cd ${bp%/*} &> /dev/null
echo -e "\rtar rf ${pth}/QA-DKRZ.tar PrePARE-package"
progress_wheel &
job_id=$!
if [ CONDA_QA_PATH} ] ; then
tar rf ${pth}/QA-DKRZ.tar ${bp##*/}
else
tar --exclude="${bp##*/}/envs/qa-dkrz" --exclude="${bp##*/}/qa-dkrz*" \
rf ${pth}/QA-DKRZ.tar ${bp##*/}
fi
tar rf ${pth}/QA-DKRZ.tar ${bp##*/}
kill -TERM $job_id
fi
else
echo "please, provide a destination path with option --ship=DEST"
fi
return
}
tr_option()
{
local line="${!1}"
local i pref
# test "${line:0:1}" != '-' && return
for(( i=0 ; i < ${#line} ; ++i )) ; do
if [ ${line:i:1} != - ] ; then
line=${line:i}
break
fi
done
local sz
sz=${#line}
for((i=0 ; i < sz ; ++i )) ; do
test "${line:i:1}" = '=' && break
done
if [ ${i} -eq ${sz} ] ; then
if [ ${i} -gt 1 ] ; then
line=$( echo "${line/% /}" | tr "[:lower:]" "[:upper:]" )
line=$( echo "${line}" | tr "-" "_" )
fi
else
local tmp0="${line:0:i}"
tmp0="${tmp0//QC/QA}"
tmp0=$( echo "${tmp0/% /}" | tr "[:lower:]" "[:upper:]" )
tmp0=$( echo "${tmp0}" | tr "-" "_" )
line="${tmp0}""${line:i}"
fi
eval ${1}=\${line}
return
}
unship()
{
test $PWD != $QA_SRC && cd $QA_SRC &> /dev/null
# find the root of a conda based tree
local j k base_path x_itm
x_itm=( ${PWD//\// } )
for((j=0 ; j < ${#x_itm[*]} ; ++j )) ; do
if [ ${x_itm[j]} = 'envs' ] ; then
if [ ${x_itm[$((j+2))]} = 'opt' ] ; then
j=$((j-1))
break
fi
fi
done
if [ $j -eq ${#x_itm[*]} ] ; then
# GitHub based
base_path=${PWD%/*}
else
# conda built
for((k=0 ; k < j ; ++k )) ; do
base_path="${base_path}/${x_itm[k]}"
done
fi
local line
mkdir ~/.qa-dkrz 2> /dev/null
echo -n '' > ~/.qa-dkrz/config.txt
while read line ; do
echo ${line//SUBST/${base_path}} >> ~/.qa-dkrz/config.txt
done < .ship-qa-config.txt
\rm -f .ship-qa-config.txt
return
}
update()
{
local prj
if [ ${isForce:-f} = f ] ; then
for prj in $* ; do
if ! . ${QA_SRC}/scripts/inqRunEnv ${prj} ; then
isForce=t # search updates
break
fi
done
test ${DEBUG} && end_of_inq=t # just a mark
fi
# search updates after a specified number of days; default: once a day
if [ ${CONDA_QA_PATH} ] ; then
test ! ${CONDA_QA_ENV} && \
. ${QA_SRC}/scripts/parseConfigFile CONDA_QA_ENV
if [ ${isForce:-f} = t ] || \
! . ${QA_SRC}/scripts/parseConfigFile NEXT_QA_UPDATE --inquire
then
if update_CONDA "${CONDA_QA_NAME}" "${CONDA_QA_CHANNELS}" \
"${CONDA_QA_PATH}" "${CONDA_QA_ENV:-qa-dkrz}" ; then
. ${QA_SRC}/scripts/parseConfigFile NEXT_QA_UPDATE ${isForce:+--force}
. ${QA_SRC}/scripts/parseConfigFile CONDA_QA_ENV=${CONDA_QA_ENV:-qa.dkrz}
# updates the QA_CONDA_REVISION entry in the config-file
$QA_SRC/scripts/getVersion --force ${DEBUG} &> /dev/null
fi
fi
elif [ -d ${QA_SRC}/.git ] ; then
test ${isForce} && \
$QA_SRC/scripts/getVersion --force ${DEBUG} &> /dev/null
test -w ${QA_SRC} && update_QA_SRC
fi
# now for project related tables and programs
for prj in $* ; do
if ! update_external $prj ; then
return $?
fi
done
if ! mkdir -p ${QA_TABLES}/tables ; then
echo "failure: mkdir -p ${QA_TABLES}/tables"
exit 1
fi
# note that QA_TABLES points to .qa-dkrz wherever it is located
rsync -auz --exclude '*~' $QA_SRC/tables ${QA_TABLES} &> /dev/null
return 0
}
update_CONDA()
{
local conda_name=$1 # is always defined
local conda_channels=$2 # is always defined
local conda_path=$3 # is always defined
local conda_env=$4 # could be empty
local action=$5 # could be empty
test ${conda_env:-none} = none && conda_env=cmor
test ! ${action} && action=update
test ${INTERNET:-t} = f && return
test "${conda_env}" = '-n ' && conda_env=
if [ ! -w "${QA_SRC}" ] ; then
return
#echo "no write-permission for ${QA_SRC}"
#exit 1
elif [ ${action} = update ] ; then
# look for a new conda-built package
echo "searching ${conda_name} updates" > ${TTY}
progress_wheel &
job_id=$!
set -f
${conda_path} ${action} ${conda_env:+-n ${conda_env}} \
${conda_channels//,/ } \
${conda_name} &> /dev/null << EOF
y
EOF
kill -TERM $job_id
set +f
else
# only CMOR could here be created
${conda_path} ${action} ${conda_env:+-n ${conda_env}} \
${CONDA_CMOR_CHANNELS//,/ } ${CONDA_CMOR_NAME} > ${TTY}
if [ $? -eq 0 ] ; then
if [ ${CONDA_CMOR_ENV} ] ; then
PrePARE=${conda_path}/envs/${CONDA_CMOR_ENV}/bin/PrePARE
. $QA_SRC/scripts/parseConfigFile CONDA_CMOR_ENV=${conda_env}
else
PrePARE=${conda_path}/bin/PrePARE
. $QA_SRC/scripts/parseConfigFile CONDA_CMOR_ENV=none
fi
. $QA_SRC/scripts/parseConfigFile \
PrePARE=${conda_path}/envs/cmor/bin/PrePARE
echo "Please, note that activation/deactivation is not required in this place." > $TTY
fi
fi
return 0
}
update_external()
{
test ${INTERNET:-t} = f && return 0
local prj=$1
test ${PROJECT_VIRT} && prj=${PROJECT_VIRT}
# check it here in order to prevent an update of the config-file in case
# that the installation failed or was terminated.
if [ ${isForce:-f} = t ] || \
! . ${QA_SRC}/scripts/parseConfigFile NEXT_${prj}_UPDATE --inquire
then
. ${QA_SRC}/scripts/get_externalSources \
-P $prj --qa-src=${QA_SRC} \
--qa-tables=${QA_TABLES} --config_file=${CONFIG_FILE} \
${isUpdate:+--update} ${isForce:+--force-update}
test $? -gt 0 && exit 1
local nextUpdate
eval nextUpdate=\$NEXT_${prj}_UPDATE
. ${QA_SRC}/scripts/parseConfigFile NEXT_${prj}_UPDATE ${isForce:+--force}
fi
return 0
}
update_QA_SRC()
{
if [ ${INTERNET:-t} = t ] ; then
if [ ${isForce:-f} = t ] || \
! . ${QA_SRC}/scripts/parseConfigFile NEXT_QA_UPDATE --inquire
then
if [ ! -f ${QA_SRC}/.ignore_GitHub ] ; then
cd ${QA_SRC}
local md5_0_inst
md5_0_inst=$( md5sum ${QA_SRC}/install | awk '{print $1}' )
local md5_0_inq
md5_0_inq=$( md5sum ${QA_SRC}/scripts/inqRunEnv | awk '{print $1}' )
# is qa-dkrz going to change?
local date_i=$(ls -l \
--time-style=+'%s' ${QA_SRC}/install \
| awk '{print $6}' 2> /dev/null )
local date_inq=$(ls -l \
--time-style=+'%s' ${QA_SRC}/scripts/inqRunEnv \
| awk '{print $6}' 2> /dev/null )
# always from master
local branch=$( ${QA_SRC}/scripts/getVersion ${DEBUG} \
--get-branch \
--config-file=$CONFIG_FILE )
# test "${branch}" != master && git checkout master &> /dev/null
git fetch && git reset --hard origin/${branch} &> /dev/null
# git pull --no-edit -q origin master &> /dev/null
if [ $? -gt 0 ] ; then
echo "git-ting QA-DKRZ failed"
return 1
fi
local isRestart=0
if [ ${date_i} != $( ls -l \
--time-style=+'%s' ${QA_SRC}/install \
| awk '{print $6}' 2> /dev/null ) ] ; then
isRestart=1
elif [ ${date_inq} != $( ls -l \
--time-style=+'%s' ${QA_SRC}/scripts/inqRunEnv \
| awk '{print $6}' 2> /dev/null ) ] ; then
isRestart=1
fi
test ${isRestart} -eq 1 && exec ${QA_SRC}/install ${initialArgs[*]}
. ${QA_SRC}/scripts/parseConfigFile NEXT_QA_UPDATE ${isForce:+--force}
# update of the QA_GitHub_REVISION entry in the config-file
$QA_SRC/scripts/getVersion --config-file=$CONFIG_FILE --force ${DEBUG} \
&> /dev/null
. ${QA_SRC}/scripts/parseConfigFile --read
fi
fi
fi
return 0
}
# ----- main ------
zeroArg=$0
initialArgs=($*)
# resolve symbolic links and realtive paths
getSrcPath
if [ $# -gt 0 ] ; then
# safe arguments
sArgs=($*)
# higher priority options
for(( i=0 ; i < ${#sArgs[*]} ; ++i )) ; do
# some args are accepted without '--'
A="${sArgs[i]}"
# tr_option A
A=$( echo "${A/% /}" | tr "[:lower:]" "[:upper:]" )
if [ "${A:0:5}" = AUTO_ ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A:0:5}" = DEBUG ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A}" = FORCE ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A:0:6}" = FREEZE ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A:0:4}" = HELP ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A:0:4}" = LINK ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A:0:6}" = ONLY-Q ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A:0:4}" = SHIP ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A:0:3}" = SRC ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A:0:2}" = UP ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A}" = UNFREEZE ] ; then
sArgs[${i}]=--${sArgs[${i}]}
fi
if [ "${A%=*}" = 'DEBUG' ] ; then
test ${A} = 'DEBUG' -o ${A#*=} = ${0##*/} && set -x
fi
done
fi
while getopts BdhT:-: option ${sArgs[*]}
do
UOPTARG="${OPTARG}"
tr_option UOPTARG
case $option in
-) OPTVAL=${OPTARG#*=}
OPTNAME=${UOPTARG%%=*}
test ${OPTVAL} = ${OPTARG%%=*} && OPTVAL=
if [ "${OPTNAME}" = CONFIG_FILE ] ; then
CONFIG_FILE=${OPTVAL}
elif [ "${OPTNAME}" = CF ] ; then
CONFIG_FILE=${OPTVAL}
elif [ ${UOPTARG:0:5} = DEBUG -o ${UOPTARG} = 'DEBUG=INSTALL' ] ; then
export DEBUG='--debug'
set -x
elif [ "${OPTNAME}" = HOME ] ; then
export QA_TABLES=${OPTVAL}
elif [ "${OPTNAME}" = QA_TABLES ] ; then
export QA_TABLES=${OPTVAL}
elif [ "${OPTNAME}" = WORK ] ; then
export QA_RESULTS=${OPTVAL}
fi
;;
\?) ;;
esac
done
if ! . $QA_SRC/scripts/getConfigFile ; then
isFreeze=t
fi
# is it in a conda built?
. ${QA_SRC}/scripts/getCondaPath
# convert AUTO_UPDATE --> UPDATE=daily
if . ${QA_SRC}/scripts/parseConfigFile AUTO_UPDATE ; then
. ${QA_SRC}/scripts/parseConfigFile AUTO_UPDATE=delete
. ${QA_SRC}/scripts/parseConfigFile UPDATE=daily
fi
# delete obsolete config-options
. ${QA_SRC}/scripts/parseConfigFile QA_REVISION=delete
. ${QA_SRC}/scripts/parseConfigFile DEFAULT_PROJECT=delete
if ! . ${QA_SRC}/scripts/parseConfigFile UPDATE ; then
# after the first installation or when UPDATE is missing
isFreeze=t
isForce=t
fi
CFG_UPDATE=$UPDATE
UPDATE=
OPTIND=
while getopts BdhT:-: option ${sArgs[*]}
do
UOPTARG="${OPTARG}"
tr_option UOPTARG
case $option in
B) coll[${#coll[*]}]=-B ;;
d) coll[${#coll[*]}]=-d ;;
h) descript
exit 41 ;;
T) TTY="${OPTARG}" ;;
-) OPTVAL=${OPTARG#*=}
OPTNAME=${UOPTARG%%=*}
test ${OPTARG/=/} = ${OPTARG} && OPTVAL=''
if [ "${OPTNAME}" = BUILD ] ; then
isBuild=t
elif [ "${OPTNAME}" = COMPILE ] ; then
FORCE_COMPILE=-B
isForce=t
elif [ "${OPTNAME}" = CONDA_BUILD ] ; then
isCondaBuild=t
elif [ "${OPTNAME}" = CONDA_CMOR_ENV -o "${OPTNAME}" = CCE ] ; then
export CONDA_CMOR_ENV=${OPTVAL}
. ${QA_SRC}/scripts/parseConfigFile CONDA_CMOR_ENV=${OPTVAL}
elif [ "${OPTNAME}" = CONDA_CMOR_PATH -o "${OPTNAME}" = CCP ] ; then
export CONDA_CMOR_PATH=${OPTVAL}
. ${QA_SRC}/scripts/parseConfigFile CONDA_CMOR_PATH=${OPTVAL}
elif [ "${OPTNAME}" = CONDA_QA_ENV -o "${OPTNAME}" = CQE ] ; then
export CONDA_QA_ENV=${OPTVAL}
. ${QA_SRC}/scripts/parseConfigFile CONDA_QA_ENV=${OPTVAL}
elif [ "${OPTNAME}" = CONDA_QA_PATH -o "${OPTNAME}" = CQP ] ; then
export CONDA_QA_PATH=${OPTVAL}
. ${QA_SRC}/scripts/parseConfigFile CONDA_QA_PATH=${OPTVAL}
elif [ "${OPTNAME}" = FORCE ] ; then
isForce=t
elif [ "${OPTNAME}" = FREEZE ] ; then
isFreeze=t
elif [ "${OPTNAME}" = HELP ] ; then
descript
exit 41
elif [ "${OPTNAME}" = HOME ] ; then
continue
elif [ "${UOPTARG:0:4}" = LINK ] ; then
isLink=t
elif [ "${OPTNAME}" = NET ] ; then
test ! ${OPTVAL} && OPTVAL='E'
OPTVAL=$( echo "${OPTVAL}" | tr "[:lower:]" "[:upper:]" )
if [ ${OPTVAL:0:1} = Y -o ${OPTVAL:0:1} = E -o ${OPTVAL:0:1} = T ] ; then
OPTVAL=t
elif [ ${OPTVAL:0:1} = N -o ${OPTVAL:0:1} = D -o ${OPTVAL:0:1} = F \
-o ${OPTVAL:0:1} = S ] ; then
OPTVAL=f
fi
INTERNET=f
# . ${QA_SRC}/scripts/parseConfigFile INTERNET=${OPTVAL}
elif [ "${OPTNAME:0:6}" = ONLY_Q ] ; then
: # for backward compatibilty
elif [ "${OPTNAME}" = PROJECT -a ${#OPTVAL} -gt 0 ] ; then
projects[${#projects[*]}]="${OPTVAL}"
elif [ "${OPTNAME}" = QA_SRC ] ; then
export QA_SRC=${OPTVAL}
elif [ "${OPTNAME}" = QA_TABLES ] ; then
continue
# elif [ "${OPTNAME}" = SET_DEFAULT_PROJECT ] ; then
# test "${OPTVAL}" && . ${QA_SRC}/scripts/parseConfigFile DEFAULT_PROJECT=${OPTVAL}
# continue
elif [ "${OPTNAME}" = SHIP ] ; then
shipOpt=${OPTVAL}
isShip=t
elif [ "${OPTNAME}" = SRC ] ; then
: # for backward compatibilty
elif [ "${OPTNAME}" = UNFREEZE ] ; then
isFreeze=
isUnfreeze=t
elif [ "${OPTNAME}" = UNSHIP ] ; then
unship # function
. ${QA_SRC}/scripts/parseConfigFile UPDATE=frozen
exit 0
elif [ "${OPTNAME:0:2}" = UP ] ; then
if [ "${OPTVAL}" = FREEZE ] ; then
isFreeze=t
else
isUpdate=t
if [ "${OPTVAL}" ] ; then
. ${QA_SRC}/scripts/parseConfigFile UPDATE=${OPTVAL}
UPDATE=${OPTVAL}
fi
fi
continue
elif [ "${OPTNAME:0:1}" = U ] ; then
name_0=${OPTNAME%%_*}
name_1=${OPTNAME#*_}
if [ "${OPTNAME:0:2}" = UF \
-o \( "${name_0:0:1}" = U -a "${name_1:0:1}" = F \) ] ; then
next_update_cycle=( ${next_update_cycle[*]} ${OPTVAL//,/ } )
continue
fi
elif [ "${OPTNAME}" = WORK ] ; then
continue
elif [ "${OPTNAME}" = HDF5 ] ; then
hdf5=${OPTVAL}
elif [ "${OPTNAME}" = NETCDF ] ; then
netcdf=${OPTVAL}
elif [ "${OPTNAME}" = ZLIB ] ; then
zlib=${OPTVAL}
elif [ "${OPTNAME}" = UDUNITS ] ; then
udunits=${OPTVAL}
fi
# collect options, which have not been processed above
coll[${#coll[*]}]=--${UOPTARG}
;;
\?) descript
echo $*
exit 1 ;;
esac
done
shift $(( $OPTIND - 1 ))
if [ ${isUnfreeze} ] ; then
test ${UPDATE} = frozen && UPDATE=daily
# could be empty for a single update
test ${UPDATE} && . $QA_SRC/scripts/parseConfigFile UPDATE=$UPDATE
fi
if [ "${CFG_UPDATE}" = frozen ] ; then
if [ ! \( ${isForce:-f} = f -o ${isShip:-f} = f \) ] ; then
echo "currently frozen; use install --unfreeze to re-enable updates unconditionally"
echo " or with --force for a single update, but keeping frozen enabled."
exit 1
fi
elif [ ${isUpdate:-f} = f -a ${CFG_UPDATE:-f} != f ] ; then
isUpdate
UPDATE=${CFG_UPDATE}
fi
if [ ! "${TTY}" ] ; then
if tty -s ; then TTY=$(tty) ; fi
fi
for pck in $* ; do
PCK="${pck}"
tr_option PCK
if [ ${PCK:0:4} = ZLIB ] ; then
zlib=${pck}
elif [ ${PCK:0:4} = HDF5 ] ; then
hdf5=${pck}
elif [ ${PCK:0:6} = NETCDF ] ; then
netcdf=${pck}
elif [ ${PCK:0:7} = UDUNITS ] ; then
udunits=${pck}
elif [ ${PCK:0:7} = QA_TABLES ] ; then
QA_TABLES=${PCK:8}
else
# collect projects names
prj=
for p in ${valid_projects[*]} ; do
if [ $p = $pck ] ; then
prj=$pck
break
fi
done
if [ ${prj} ] ; then
coll[${#coll[*]}]=$prj
projects[${#projects[*]}]=$prj
fi
fi
done
# make all by default
test ${#projects[*]} -eq 0 && projects=( ${valid_projects[*]} )
if ! . ${QA_SRC}/scripts/getTablesPath ; then
exit 1
fi
if [ ${isUpdate} ] ; then
# also ensures that all names in the config.files are defined in this program
if [ ! ${isCondaBuild} ] ; then
if [ ! ${isBuild} ] ; then
update ${projects[*]}
fi
if [ ${#next_update_cycle[*]} -gt 0 ] ; then
NEXT_U_CYCLE=(QA CONDA_CMOR)
for(( i=0 ; i < ${#projects[*]} ; ++i )) ; do
NEXT_U_CYCLE[${#NEXT_U_CYCLE[*]}]=${projects[i]}
done
if [ ${#next_update_cycle[*]} = 1 -a ${next_update_cycle[0]} = ${next_update_cycle[0]//=/} ] ; then
for nv in ${NEXT_U_CYCLE[*]} ; do
# apply to all
. ${QA_SRC}/scripts/parseConfigFile NEXT_${nv}_UPDATE --set_frequency=${next_update_cycle[0]}
done
else
# individual settings
for dn in ${next_update_cycle[*]} ; do
for nv in ${NEXT_U_CYCLE[*]} ; do
if [ ${dn%=*} = ${nv} ] ; then
. ${QA_SRC}/scripts/parseConfigFile NEXT_${nv}_UPDATE --set_frequency=${dn#*=}
fi
done
done
fi
fi
fi
fi
if [ ${isShip} ] ; then
ship ${shipOpt}
exit 41
fi
if [ ${isBuild:-f} = t -a ${isLink:-f} = t ] ; then
echo "scripts/install.sh: options --build and --link exclude each other"
exit 1
elif [ ${isBuild:-f} = t -o ${isLink:-f} = t ] ; then
pcks="--zlib=$zlib --hdf5=$hdf5 --netcdf=$netcdf --udunits=$udunits"
log ${initialArgs[*]}
else
pcks=
fi
freeze
if [ ${#projects[*]} -eq 0 ] ; then
echo "$0 ${initialArgs[*]}: at least one PROJECT name is required"
exit 1
fi
exec ${QA_SRC}/scripts/install.sh ${debug} --pack=${package} \
${isContinueLog:+--continue_log} ${pcks} \
--qa-src=${QA_SRC} ${FORCE_COMPILE} ${coll[*]}