forked from h-dh/QA-DKRZ
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall
executable file
·771 lines (640 loc) · 20.5 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
#! /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 tables (if any) 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[=str] Update external packages/tables from respective repositories"
echo " with str of comma-separated-values:"
echo " tables: only tables [by default],"
echo " QA: the QA-DKRZ package from GitHUB,"
echo " CMOR: the CMOR conda packages for project CMIP6,"
echo " force: QA,CMOR,tables."
echo " Note: conda itself has to be updated manually."
echo " Note: missing write-permission is silently caught."
echo " Note: not for netCDF, HDF5, udunits2 or zlib."
echo ""
echo ' projects-name(s) At present CF, CMIP5/6, [CORDEX] and HAPPI.'
return
}
getSrcPath()
{
local name p p0 pth
p0=$0
pth=$PWD
while : ; do
name=${p0##*/}
p0=${p0%/*}/
if [ ${p0} = '/' ] ; then
echo "there is something wrong with ${p0}"
exit 1
elif [ ${p0:0:1} = '/' ] ; then
pth=${p0%/}
else
# please, mind the trailing '/'
if [ ${p0:0:2} = '..' ] ; then
p0=${pth%/*}/${p0#*/}
elif [ ${p0:0:1} = '.' ] ; then
p0=${pth}/${p0#*/}
else
# relative path, whatever
p0=${pth}/$p0
fi
p0=${p0}${name}
fi
if [ -h $p0 ] ; then
# resolve symbolic links
p0=$( ls -l $p0 2> /dev/null | awk '{print $11}')
if [ ${p0:0:1} = '/'} ] ; then
pth=${p0%/*}
continue
fi
else
break
fi
done
# only the directory
p0=${p0%/*}
test ${p0##*/} = 'script' && p0=${p0%/script}
if [ -f ${p0}/scripts/qa-dkrz ] ; then
export QA_SRC=$p0
fi
# export QA_SRC=${p0}QA-DKRZ
# export QA_SRC=${p0%QA-DKRZ*}QA-DKRZ
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 [ ${isCondaInstance} ] ; then
local bp=${CONDA_PATH_QA%/bin/conda}
cd ${bp%/*} &> /dev/null
echo "tar cf ${pth}/QA-DKRZ.tar ${bp##*/} "
if [ ! ${isNoPW} ] ; then
progress_wheel &
job_id=$!
fi
tar cf ${pth}/QA-DKRZ.tar ${bp##*/}
test ! ${isNoPW} && kill -TERM $job_id
else
cd ${QA_SRC%/*} &> /dev/null
echo -e "\rtar cf ${pth}/QA-DKRZ.tar QA-DKRZ "
if [ ! ${isNoPW} ] ; then
progress_wheel &
job_id=$!
fi
tar cf ${pth}/QA-DKRZ.tar QA-DKRZ
test ! ${isNoPW} && 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 "
if [ ! ${isNoPW} ] ; then
progress_wheel &
job_id=$!
fi
tar rf ${pth}/QA-DKRZ.tar $QA_TABLES
test ! ${isNoPW} && 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"
if [ ! ${isNoPW} ] ; then
progress_wheel &
job_id=$!
fi
if [ ${isCondaInstance} ] ; 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##*/}
test ! ${isNoPW} && kill -TERM $job_id
fi
else
echo "please, provide a destination path with option --ship=DEST"
fi
return
}
syncTables()
{
if [ ${w_perm} ] ; then
if ! mkdir -p ${QA_TABLES}/tables ; then
echo "failure: mkdir -p ${QA_TABLES}/tables"
exit 1
fi
rsync -auz --exclude '*~' $QA_SRC/tables ${QA_TABLES} &> /dev/null
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()
{
test ! ${update_arg} && return
local prj
local prjs
declare -a prjs
prjs=( $* )
if [ ${update_arg} ] && [ ${w_perm} ] ; then
if [ "${update_arg/QA/}" != "${update_arg}" ] ; then
if [ -d ${QA_SRC}/.git ] ; then
update_QA_SRC
fi
fi
fi
# if [ ${update_arg} != QA ] ; then
# # now for project related tables and programs
# for prj in $* ; do
# update_external $prj ${update_arg:+--update=${update_arg}} \
# ${w_perm:+--no-w-perm}
# done
# fi
return 0
}
update_external()
{
test ! ${NET} && return 0
local prj=$1
shift
test ${PROJECT_VIRT} && prj=${PROJECT_VIRT}
. ${QA_SRC}/scripts/get_externalSources \
-P $prj --qa-src=${QA_SRC} \
--qa-tables=${QA_TABLES} --config_file=${CONFIG_FILE} \
$*
if [ $? -gt 0 ] ; then
echo "could not make install.update_external for $prj"
exit 1
fi
local v=$( python ${QA_SRC}/python/qa-dkrz/qa_version.py -P $prj )
. ${QA_SRC}/scripts/parseConfigFile ${prj}_VERSION=$v
return 0
}
update_QA_SRC()
{
if [ ${NET} ] ; 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}' )
# is qa-dkrz going to change?
local date_inst=$(ls -l \
--time-style=+'%s' ${QA_SRC}/install \
| awk '{print $6}' 2> /dev/null )
# always from master
local branch=$( python ${QA_SRC}/python/qa-dkrz/qa_version.py --qa 2> /dev/null )
branch=${branch#*,}
branch=${branch%-*}
# test "${branch}" != master && git checkout master &> /dev/null
git fetch && git reset --hard origin/${branch:-master} &> /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 md5_1_inst
md5_1_inst=$( md5sum ${QA_SRC}/install | awk '{print $1}' )
if [ ${md5_0_inst} != ${md5_1_inst} ] ; then
. ${QA_SRC}/scripts/parseConfigFile LAST_QA_UPDATE=$(date '+%Y%m%d')
QA_VERSION=$( python ${QA_SRC}/python/qa-dkrz/qa_version.py --qa )
. ${QA_SRC}/scripts/parseConfigFile QA_VERSION=$QA_VERSION
exec ${QA_SRC}/install ${initialArgs[*]}
fi
fi
fi
return 0
}
# ----- main ------
zeroArg=$0
initialArgs=($*)
for arg in ${initialArgs[*]} ; do
if [ ${arg} = '--debug' ] ; then
set -x
break
elif [ ${arg} = '--dis-void' -o ${arg} = '--disable-void' ] ; then
dis_void=t
fi
done
# 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}" = DEBUG ] ; then
sArgs[${i}]=--${sArgs[${i}]}
elif [ "${A}" = FORCE ] ; 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}]}
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 -o "${OPTNAME}" = CF ] ; then
CONFIG_FILE=${OPTVAL}
elif [ ${UOPTARG:0:5} = DEBUG -o ${UOPTARG} = 'DEBUG=INSTALL' ] ; then
export DEBUG='--debug'
export isDebug=t
# set -x # already set before
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
. ${QA_SRC}/scripts/getConfigFile
# is it in a conda built?
. ${QA_SRC}/scripts/getCondaPath
. ${QA_SRC}/scripts/parseConfigFile --read-all
if [ -w $QA_SRC ] ; then
w_perm=t
# delete obsolete config-options
obsolete_conf=( QA_REVISION DEFAULT_PROJECT )
obsolete_conf+=( $( grep NEXT_ ${CONFIG_FILE} ) )
for oc in ${obsolete_conf[*]} ; do
. ${QA_SRC}/scripts/parseConfigFile ${oc%%=*}=delete
done
fi
# unset for command-line usage
UPDATE=
NET=t
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
elif [ "${OPTNAME}" = CONDA_BUILD ] ; then
isCondaBuild=t
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_PATH_QA -o "${OPTNAME}" = CQP ] ; then
export CONDA_PATH_QA=${OPTVAL}
. ${QA_SRC}/scripts/parseConfigFile CONDA_PATH_QA=${OPTVAL}
elif [ "${OPTNAME}" = CONFIG_FILE ] ; then
: # previously set
elif [ "${OPTNAME}" = FORCE ] ; then
isForce=t
update_arg="${update_arg:+${update_arg},}force"
elif [ "${OPTNAME}" = HELP ] ; then
descript
exit 41
elif [ "${OPTNAME}" = HOME ] ; then
: # previously set
elif [ "${UOPTARG:0:4}" = LINK ] ; then
isLink=t
elif [ "${OPTNAME}" = NET ] ; then
OPTVAL=$( echo "${OPTVAL}" | tr "[:lower:]" "[:upper:]" )
if [ "${OPTVAL:0:1}" = 'N' ] ; then
isNoNet=f
unset NET
fi
elif [ "${OPTNAME}" = NO_PROGRESS_WHEEL ] ; then
isNoPW=t
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
: # previously set
elif [ "${OPTNAME}" = SHIP ] ; then
shipOpt=${OPTVAL}
isShip=t
elif [ "${OPTNAME}" = SRC ] ; then
: # for backward compatibilty
elif [ "${OPTNAME}" = UNSHIP ] ; then
unship # function
exit 0
elif [ "${OPTNAME:0:2}" = UP ] ; then
test "${OPTVAL}" = t && OPTVAL=tables
update_arg="${update_arg:+${update_arg},}${OPTVAL}"
elif [ "${OPTNAME}" = WORK ] ; then
: # previously set
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}
;;
\?) echo "unknown option $option"
exit 1;;
esac
done
shift $(( $OPTIND - 1 ))
#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 projects by default
if [ ${#projects[*]} -eq 0 ] ; then
projects=( ${valid_projects[*]} )
coll[${#coll[*]}]="${projects[*]}"
fi
if [ ! ${isCondaBuild} ] ; then
if . ${QA_SRC}/scripts/getTablesPath ; then
# else: exit 41
syncTables
fi
fi
# check correct settings in HOME/.qa-dkrz/config.txt depending on projects
if [ ! ${isCondaBuild} ] && [ ! ${isBuild} ] ; then
. ${QA_SRC}/scripts/check_configuration \
${isForce:+--force} ${update_arg:+--up=${update_arg}} ${projects[*]}
update ${projects[*]}
if [ -f $HOME/.qa-dkrz/config.txt ] ; then
if [ -f $QA_SRC/.qa-dkrz/config.txt ] ; then
md5_0=$( md5sum ${QA_SRC}/.qa-dkrz/config.txt | awk '{print $1}' )
md5_1=$( md5sum ${HOME}/.qa-dkrz/config.txt | awk '{print $1}' )
test ${md5_0} != ${md5_1} &&
cp ${HOME}/.qa-dkrz/config.txt ${QA_SRC}/.qa-dkrz
else
if ! mkdir -p ${QA_SRC}/.qa-dkrz 2> /dev/null ; then
echo "could not mkdir ${QA_SRC}/.qa-dkrz; missing permission?"
exit 41
fi
cp ${HOME}/.qa-dkrz/config.txt ${QA_SRC}/.qa-dkrz
fi
fi
fi
if [ ${isShip} ] ; then
# store for alien users
if [ ! -f ${QA_SRC}/.qa-dkrz/config.txt -a ${isCondaBuild:-f} = f ] ; then
mkdir ${QA_SRC}/.qa-dkrz
# sed -n "${QA_SRC//\//\\\/}/,/^[:space]*$/ p" ~/.qa-dkrz/config.txt \
echo "${QA_SRC}:" > ${QA_SRC}/.qa-dkrz/config.txt
line_num=$( grep -n ${QA_SRC}: ~/.qa-dkrz/config.txt )
line_num=$(( ${line_num%%:*} + 1 ))
sed -n "${line_num},/^[:space]*$/ p" ~/.qa-dkrz/config.txt \
>> ${QA_SRC}/.qa-dkrz/config.txt
chmod -R o-w ${QA_SRC}/.qa-dkrz
chmod -R o+r ${QA_SRC}/.qa-dkrz
fi
ship ${shipOpt}
exit 41
fi
test ! ${w_perm} && exit 0
# conda ?
test ${zeroArg/\/envs\/qa-dkrz\/opt\//} != ${zeroArg} && exit 0
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
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[*]}