-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathhyrax_build.sh
executable file
·250 lines (212 loc) · 5.61 KB
/
hyrax_build.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
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
#!/bin/bash
#
# Build all of Hyrax given a fresh checkout from git.
# This is fairly rough...
function help {
echo "Usage: $0 [options] where options are:"
echo "-h: help; this message"
echo "-v: verbose"
echo "-n: print what would be done"
echo "-2: DAP2 build"
echo "-c: run make clean before the builds"
echo "-d: run the distcheck targets for the C++ code"
echo "-D: Do not build thehyrax-dependencies package"
echo "-N: If the dependencies are present, build the <all-static-rpm> target"
echo "-p prefix: use <prefix> as the build/install prefix"
}
# Hack jhrg 1/8/24
jobs=-j20
args=`getopt hvn2cdDNp: $*`
if test $? != 0
then
help
exit 2
fi
set -- $args
# Not sure about this way of handling prefix... Should we make it
# easier to build and install to /usr/local?
export prefix=${prefix:-$PWD/build}
if echo $PATH | grep $prefix > /dev/null
then
echo "PATH Already set"
else
export PATH=$prefix/bin:$prefix/deps/bin:$PATH
fi
# This is needed for the linux builds; if using the deps libraries
# on linux, those directories also need to be on LD_LIBRARY_PATH.
# I'm not sure this is true... jhrg 1/2/13
# We do need this for icu-3.6 on AWS EC2 instances. jhrg 3/5/13
if echo $LD_LIBRARY_PATH | grep $prefix/lib:$prefix/deps/lib > /dev/null
then
echo "LD_LIBRARY_PATH already set"
else
export LD_LIBRARY_PATH=$prefix/lib:$prefix/deps/lib:$LD_LIBRARY_PATH
fi
# Set verbose and dry_run to false
verbose=""
dry_run="no"
dap2="no"
clean=""
distcheck=""
build_hyrax_deps="yes"
for_nasa_rpm=""
for i in $*
do
case "$i"
in
-h)
help
exit 0;;
-v)
verbose="--verbose"
shift;;
-n)
dry_run="yes"
shift;;
-2)
dap2="yes"
shift;;
-c)
clean="yes"
shift;;
-d)
distcheck="yes"
shift;;
-D)
build_hyrax_deps="no"
shift;;
-N)
for_nasa_rpm="for-static-rpm"
shift;;
-p)
prefix=$2
shift; shift;;
--)
shift; break;;
esac
done
function verbose {
if test -n "$verbose"
then
echo "$*"
fi
}
function do_command {
if test "$dry_run" = "yes"
then
echo "$*"
else
verbose "$*"
$*
fi
}
# Two args "do_make_build <thing> <configure options>"
function do_make_build {
verbose "Building in $1"
# in a sub-shell
(
if cd $1
then
# shift first arg off so $* holds the remaining args
shift
if test ! -x configure
then
do_command "autoreconf --force --install $verbose"
fi
if test ! -x configure -a -z "$dry_run"
then
echo "Could not find or build configure script"
exit 1
fi
do_command "./configure $*"
verbose "%%% configure status: $?"
if test -n "$clean"
then
do_command "make clean"
fi
do_command "make $jobs"
verbose "%%% make status: $?"
# some of the bes/handler tests fail w/parallel builds
do_command "make check -k"
verbose "%%% check status: $?"
do_command "make install"
verbose "%%% install status: $?"
if test -n "$distcheck"
then
do_command "make distcheck $jobs"
verbose "%%% distcheck status: $?"
fi
fi
)
}
# Two args "do_build <thing> <configure options>"
function do_ant_build {
verbose "Building in $1"
# in a sub-shell
(
if cd $1
then
# shift first arg off so $* holds the remaining args
shift
if test ! -f build.xml
then
echo "Could not find build.xml script"
exit 1
fi
do_command "ant server $*"
verbose "%%% make status: $? (ant server $*)"
if test -d $tomcat_webapps
then
do_command "cp build/dist/opendap.war $tomcat_webapps"
verbose "%%% install status: $?"
else
echo "Could not find $tomcat_webapps"
verbose "%%% install status: 2"
fi
do_command "ant check $*"
verbose "%%% check status: $? (ant check $*)"
fi
)
}
if test -d hyrax-dependencies -a x$build_hyrax_deps = xyes
then
(
verbose "Building the local dependencies"
cd hyrax-dependencies
# $for_nasa_rpm will contain the magic needed to make just the stuff
# we need for the BES rpm for NASA (with static HDF4/hdfeos2, ...).
# NB: The -N option of this script will build the static version of
# these dependencies; without -N you get all the deps as dynamic libraries.
do_command "make $jobs $for_nasa_rpm"
# The above unpacks, builds and installs each dependency. It uses lots
# of space. This removes the source build directories, saving almost
# 2GB of disk. jhrg 10/24/19
do_command "make really-clean"
# figure out the apache tomcat dir name based on the rev of tomcat's
# tar file in the 'extra_downloads' dir and replace if needed. This
# tests if the versions are not the same, not if one is newer than the
# other.
deps_tomcat_ver=`ls -1 extra_downloads/apache-tomcat-7.*.*.tar.gz | sed 's@.*\([0-9]\.[0-9]*\.[0-9]*\)\.tar.gz@\1@'`
if test ! -d $prefix/apache-tomcat-$deps_tomcat_ver
then
verbose "Replacing tomcat with version $dep_tomcat_ver"
# remove previous tomcat; add the new one
rm $prefix/apache-tomcat-*
do_command "tar -xzf extra_downloads/apache-tomcat-7.*.*.tar.gz -C $prefix"
fi
)
# deps is used later with the BES build. If hyrax-dependencies is not
# here, then assume the third-party packages are otherwise available.
deps="--with-dependencies=$prefix/deps"
fi
prefix_arg=--prefix=$prefix
if test "$dap2" == "yes"
then
libdap="libdap"
else
libdap="libdap4"
fi
do_make_build $libdap $prefix_arg --enable-developer 2>&1 | tee $libdap.log
do_make_build bes $prefix_arg $deps --enable-developer 2>&1 | tee bes.log
tomcat_webapps=$prefix/apache-tomcat-9.*.*/webapps
do_ant_build olfs 2>&1 | tee olfs.log