forked from cvmfs/cvmfs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.sh
executable file
·277 lines (240 loc) · 7.37 KB
/
bootstrap.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
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
#!/bin/sh
set -e
SSL_VERSION=3.1.2
CARES_VERSION=1.16.1
CURL_VERSION=7.71.1
PACPARSER_VERSION=1.3.5
ZLIB_VERSION=1.2.8
SPARSEHASH_VERSION=1.12
LEVELDB_VERSION=1.18
GOOGLETEST_VERSION=1.8.0
IPADDRESS_VERSION=1.0.22
MAXMINDDB_VERSION=1.4.0
PROTOBUF_VERSION=2.6.1
RAPIDCHECK_VERSION=0.0
LIBARCHIVE_VERSION=3.3.2
if [ x"$EXTERNALS_LIB_LOCATION" = x"" ]; then
echo "Bootstrap - Missing environment variable: EXTERNALS_LIB_LOCATION"
exit 1;
fi
if [ x"$EXTERNALS_BUILD_LOCATION" = x"" ]; then
echo "Bootstrap - Missing environment variable: EXTERNALS_BUILD_LOCATION"
exit 1;
fi
if [ x"$EXTERNALS_INSTALL_LOCATION" = x"" ]; then
echo "Bootstrap - Missing environment variable: EXTERNALS_INSTALL_LOCATION"
exit 1;
fi
echo "Bootstrap - Externals lib location: $EXTERNALS_LIB_LOCATION"
echo "Bootstrap - Externals build location: $EXTERNALS_BUILD_LOCATION"
echo "Bootstrap - Externals install location: $EXTERNALS_INSTALL_LOCATION"
echo "Bootstrap - Base CVMFS C flags: $CVMFS_BASE_C_FLAGS"
echo "Bootstrap - Base CVMFS C++ flags: $CVMFS_BASE_CXX_FLAGS"
externals_lib_dir=$EXTERNALS_LIB_LOCATION
externals_build_dir=$EXTERNALS_BUILD_LOCATION
externals_install_dir=$EXTERNALS_INSTALL_LOCATION
repo_root=$(pwd)
print_hint() {
local msg="$1"
echo "--> $msg"
}
get_destination_dir() {
local library_name="$1"
echo "$externals_build_dir/build_$library_name"
}
do_extract() {
local library_name="$1"
local library_archive="$2"
local archive_format=$(echo "$library_archive" | sed 's/.*\(\.tar\.[^\.]*\)$/\1/')
local library_dir="$externals_lib_dir/$library_name"
local dest_dir=$(get_destination_dir $library_name)
local cdir=$(pwd)
local library_decompressed_dir=$(basename $library_archive $archive_format)
print_hint "Extracting $library_archive"
cd $externals_build_dir
if [ $archive_format = ".tar.bz2" ]; then
tar xvfj "$library_dir/$library_archive"
else
tar xvfz "$library_dir/$library_archive"
fi
mv $library_decompressed_dir $dest_dir
cd $cdir
cp -r $library_dir/src/* $dest_dir
}
do_copy() {
local library_name="$1"
local library_dir="$externals_lib_dir/$library_name"
local dest_dir=$(get_destination_dir $library_name)
print_hint "Copying $library_name"
mkdir -p $dest_dir
cp -r $library_dir/src/* $dest_dir
}
do_build() {
local library_name="$1"
local library_src_dir="$externals_lib_dir/$library_name"
local library_build_dir=$(get_destination_dir $library_name)
print_hint "Building $library_name"
local save_dir=$(pwd)
cd $library_build_dir
sh configureHook.sh
sh makeHook.sh
cd $save_dir
}
patch_external() {
local library_name="$1"
shift 1
local cdir=$(pwd)
print_hint "Patching $library_name"
cd $(get_destination_dir $library_name)
while [ $# -gt 0 ]; do
patch -p0 < $1
shift 1
done
cd $cdir
}
replace_in_external() {
local library_name="$1"
local src="$2"
local dst="$3"
local cdir=$(pwd)
print_hint "Replacing $src with $dst in $library_name"
cd $(get_destination_dir $library_name)
mv "$dst" "${dst}.orig"
cp "$src" "$dst"
cd $cdir
}
build_lib() {
local lib_name=$1
rm -rf $externals_build_dir/build_${lib_name}
case ${lib_name} in
libcurl)
# (only on Mac)
if [ x"$(uname)" = x"Darwin" ]; then
rm -rf $externals_build_dir/build_ssl
do_extract "ssl" "libressl-${SSL_VERSION}.tar.gz"
do_build "ssl"
fi
rm -rf $externals_build_dir/build_c-ares
do_extract "c-ares" "c-ares-${CARES_VERSION}.tar.gz"
do_build "c-ares"
do_extract "libcurl" "curl-${CURL_VERSION}.tar.gz"
patch_external "libcurl" "reenable_poll_darwin.patch"
do_build "libcurl"
;;
pacparser)
do_extract "pacparser" "pacparser-${PACPARSER_VERSION}.tar.gz"
patch_external "pacparser" "fix_find_proxy_ex.patch" \
"fix_cflags.patch" \
"fix_python.patch"
do_build "pacparser"
;;
zlib)
do_extract "zlib" "zlib-${ZLIB_VERSION}.tar.gz"
do_build "zlib"
;;
sparsehash)
do_extract "sparsehash" "sparsehash-${SPARSEHASH_VERSION}.tar.gz"
patch_external "sparsehash" "fix_sl4_compilation.patch" \
"fix_warning_gcc48.patch"
replace_in_external "sparsehash" "config.guess.latest" "config.guess"
replace_in_external "sparsehash" "config.sub.latest" "config.sub"
do_build "sparsehash"
;;
leveldb)
do_extract "leveldb" "leveldb-${LEVELDB_VERSION}.tar.gz"
patch_external "leveldb" "dont_search_snappy.patch" \
"dont_search_tcmalloc.patch" \
"arm64_memory_barrier.patch"
do_build "leveldb"
;;
googletest)
do_extract "googletest" "googletest-release-${GOOGLETEST_VERSION}.tar.gz"
patch_external "googletest" "cmake_compatibility.patch"
do_build "googletest"
;;
ipaddress)
if [ x"$BUILD_SERVER" != x ] && [ x"$BUILD_GEOAPI" != x ]; then
do_extract "ipaddress" "ipaddress-${IPADDRESS_VERSION}.tar.gz"
do_build "ipaddress"
fi
;;
maxminddb)
if [ x"$BUILD_SERVER" != x ] && [ x"$BUILD_GEOAPI" != x ]; then
do_extract "maxminddb" "MaxMind-DB-Reader-python-${MAXMINDDB_VERSION}.tar.gz"
do_build "maxminddb"
fi
;;
protobuf)
do_extract "protobuf" "protobuf-${PROTOBUF_VERSION}.tar.bz2"
do_build "protobuf"
;;
googlebench)
if [ x"$BUILD_UBENCHMARKS" != x"" ]; then
do_copy "googlebench"
do_build "googlebench"
fi
;;
sqlite3)
do_copy "sqlite3"
do_build "sqlite3"
;;
vjson)
do_copy "vjson"
patch_external "vjson" "missing_include.patch"
do_build "vjson"
;;
sha2)
do_copy "sha2"
do_build "sha2"
;;
sha3)
do_copy "sha3"
do_build "sha3"
;;
rapidcheck)
if [ x"$BUILD_QC_TESTS" != x"" ]; then
do_extract "rapidcheck" "rapidcheck-${RAPIDCHECK_VERSION}.tar.gz"
do_build "rapidcheck"
fi
;;
libarchive)
do_extract "libarchive" "libarchive-${LIBARCHIVE_VERSION}.tar.gz"
do_build "libarchive"
;;
*)
echo "Unknown library name. Exiting."
exit 1
esac
echo $l >> $externals_install_dir/.bootstrapDone
}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Build a list of libs that need to be built
missing_libs="libcurl pacparser zlib sparsehash leveldb googletest ipaddress maxminddb protobuf googlebench sqlite3 vjson sha2 sha3 libarchive"
if [ x"$BUILD_QC_TESTS" != x"" ]; then
missing_libs="$missing_libs rapidcheck"
fi
if [ -f $externals_install_dir/.bootstrapDone ]; then
existing_libs=$(cat $externals_install_dir/.bootstrapDone)
for l in $existing_libs; do
if [ x"$l" != x ]; then
echo "Bootstrap - found $l"
missing_libs=$(echo $missing_libs | sed -e "s/$l//")
fi
done
else
echo "Bootstrap - clean build"
fi
mkdir -p $externals_build_dir
mkdir -p $externals_install_dir/include
mkdir -p $externals_install_dir/lib
rm -f $externals_install_dir/.bootstrapDone
for l in $existing_libs; do
echo $l >> $externals_install_dir/.bootstrapDone
done
if [ x"$missing_libs" != x ]; then
echo "Building libraries: $missing_libs"
fi
for l in $missing_libs; do
build_lib $l
done
## Done!