-
Notifications
You must be signed in to change notification settings - Fork 8
/
updatebuild.sh
executable file
·199 lines (171 loc) · 6.79 KB
/
updatebuild.sh
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
#!/bin/bash
# Default parameter
build='new';
URLBase='https://www.phenix.bnl.gov/WWW/publish/phnxbld/EIC/Singularity';
sysname='gcc-8.3'
DownloadBase='cvmfs/eic.opensciencegrid.org';
CleanDownload=false
# Parse input parameter
for i in "$@"
do
case $i in
-b=*|--build=*)
build="${i#*=}"
shift # past argument=value
;;
--sysname=*)
sysname="${i#*=}"
shift # past argument=value
;;
-s=*|--source=*)
URLBase="${i#*=}"
shift # past argument=value
;;
-t=*|--target=*)
DownloadBase="${i#*=}"
shift # past argument=value
;;
-c|--clean)
CleanDownload=true
shift # past argument=value
;;
--help|-h|*)
echo "Usage: $0 [--build=<new>] [--sysname=<x8664_sl7|gcc-8.3>] [--source=URL] [--target=directory] [--clean]";
exit;
shift # past argument with no value
;;
esac
done
echo "This macro download/update EIC ${build} build to $DownloadBase"
echo "Source is at $URLBase"
echo ""
echo "******************************************************************"
echo "Important: you are now using the c++17 distribution (--sysname=gcc-8.3) by default"
echo "The previous default (x8664_sl7) is available but will not be updated anymore"
echo "If you have been using --sysname=gcc-8.3 up to now, nothing changes"
echo "For everyone else - you need to recompile your code"
echo "GEANT4 has been upgraded to 10.06.02"
echo "ROOT has been upgraded to 6.22.02"
echo "******************************************************************"
echo ""
echo "If you have CVMFS file system directly mounted on your computer,"
echo "you can skip this download and mount /cvmfs/eic.opensciencegrid.org to the singularity container directly."
#cache check function
md5_check ()
{
local target_file=$1
local md5_cache=$2
#echo "target_file $target_file"
local new_md5=`curl -H 'Cache-Control: no-cache' -ks $target_file`
#echo "new_md5 : $new_md5 ..."
# echo "searching for $md5_cache ..."
if [ -f $md5_cache ]; then
# echo "verifying $md5_cache ..."
local md5_cache=`cat $md5_cache`
if [ "$md5_cache" = "$new_md5" ]; then
# echo "$target_file has not changed since the last download"
return 0;
fi
fi
return 1;
}
if [ $CleanDownload = true ]; then
echo "--------------------------------------------------------"
echo "Clean up older download"
echo "--------------------------------------------------------"
if [ -d "$DownloadBase" ]; then
echo "First, wiping out previous download at $DownloadBase ..."
chmod -R +w $DownloadBase # our boost headers are read only, need chmod to remove them
/bin/rm -rf $DownloadBase
else
echo "Previous download folder is empty: $DownloadBase"
fi
fi
echo "--------------------------------------------------------"
echo "Singularity image"
echo "--------------------------------------------------------"
#echo "${URLBase}/rhic_sl7_ext.sif -> ${DownloadBase}/singularity/"
mkdir -p ${DownloadBase}/singularity
md5_check ${URLBase}/rhic_sl7_ext.sif.md5 ${DownloadBase}/singularity/rhic_sl7_ext.sif.md5
if [ $? != 0 ]; then
echo "Downloading ${URLBase}/rhic_sl7_ext.sif -> ${DownloadBase}/singularity/ ..."
curl -H 'Cache-Control: no-cache' -k ${URLBase}/rhic_sl7_ext.sif > ${DownloadBase}/singularity/rhic_sl7_ext.sif
curl -H 'Cache-Control: no-cache' -ks ${URLBase}/rhic_sl7_ext.sif.md5 > ${DownloadBase}/singularity/rhic_sl7_ext.sif.md5
else
echo "${URLBase}/rhic_sl7_ext.sif has not changed since the last download"
echo "- Its md5 sum is ${DownloadBase}/singularity/rhic_sl7_ext.sif.md5 : " `cat ${DownloadBase}/singularity/rhic_sl7_ext.sif.md5`
fi
echo "--------------------------------------------------------"
echo "Monte Carlos"
echo "--------------------------------------------------------"
md5_check ${URLBase}/MCEG.tar.bz2.md5 ${DownloadBase}/singularity/MCEG.tar.bz2.md5
if [ $? != 0 ]; then
if [ -d ${DownloadBase}/${sysname}/MCEG ]; then
echo "deleting old Monte Carlos"
rm -rf ${DownloadBase}/${sysname}/MCEG
fi
echo "Downloading ${URLBase}/MCEG.tar.bz2 -> ${DownloadBase}/singularity/ ..."
curl -H 'Cache-Control: no-cache' -k ${URLBase}/MCEG.tar.bz2 | tar xjf -
curl -H 'Cache-Control: no-cache' -ks ${URLBase}/MCEG.tar.bz2.md5 > ${DownloadBase}/singularity/MCEG.tar.bz2.md5
else
echo "${URLBase}/MCEG.tar.bz2 has not changed since the last download"
echo "- Its md5 sum is ${DownloadBase}/singularity/MCEG.tar.bz2.md5 : " `cat ${DownloadBase}/singularity/MCEG.tar.bz2.md5`
fi
echo "--------------------------------------------------------"
echo "EIC build images"
echo "--------------------------------------------------------"
declare -a images=("opt.tar.bz2" "offline_main.tar.bz2" "utils.tar.bz2")
mkdir -p ${DownloadBase}/${sysname}/.md5/${build}/
## now loop through the above array
for tarball in "${images[@]}"
do
# echo "Downloading and decompress ${URLBase}/${build}/${tarball} ..."
md5file="${DownloadBase}/${sysname}/.md5/${build}/${tarball}.md5";
md5_check ${URLBase}/${sysname}/${build}/${tarball}.md5 ${md5file}
if [ $? != 0 ]; then
# clean up existing installation if it exists
case "$tarball" in
opt*)
deldir=${DownloadBase}/${sysname}/opt/fun4all/core
if [ -d ${deldir} ]; then
echo "Cleaning ${deldir}"
rm -rf ${deldir}
fi
;;
offline*)
# first remove the ${build} symlink if it exists
if [ -e ${DownloadBase}/${sysname}/release/${build} ]; then
rm ${DownloadBase}/${sysname}/release/${build}
fi
deldir=${DownloadBase}/${sysname}/release/release_${build}
if [ -d ${deldir} ]; then
echo "cleaning $deldir"
chmod -R 755 ${deldir}
rm -rf ${deldir}
fi
;;
utils*)
deldir=${DownloadBase}/${sysname}/opt/fun4all/utils
if [ -d ${deldir} ]; then
echo "Cleaning ${deldir}"
rm -rf ${deldir}
fi
;;
esac
echo "Downloading ${URLBase}/${sysname}/${build}/${tarball} -> ${DownloadBase} ..."
curl -H 'Cache-Control: no-cache' -k ${URLBase}/${sysname}/${build}/${tarball} | tar xjf -
curl -H 'Cache-Control: no-cache' -ks ${URLBase}/${sysname}/${build}/${tarball}.md5 > ${md5file}
else
echo "${URLBase}/${sysname}/${build}/${tarball} has not changed since the last download"
echo "- Its md5 sum is ${md5file} : " `cat ${md5file}`
fi
done
echo "--------------------------------------------------------"
echo "Done! To run the EIC container in shell mode:"
echo ""
echo "singularity shell -B cvmfs:/cvmfs cvmfs/eic.opensciencegrid.org/singularity/rhic_sl7_ext.sif"
echo "source /cvmfs/eic.opensciencegrid.org/$sysname/opt/fun4all/core/bin/eic_setup.sh -n $build"
echo ""
echo "More on singularity tutorials: https://www.sylabs.io/docs/"
echo "More on directly mounting cvmfs instead of downloading: https://github.com/eic/Singularity"
echo "--------------------------------------------------------"