-
Notifications
You must be signed in to change notification settings - Fork 16
/
install-centos.sh
342 lines (255 loc) · 9.42 KB
/
install-centos.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
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
#!/bin/bash/bin/bash
set -o nounset
set -o errexit
echo
echo " created by Daniel Schwarz/[email protected]"
echo " released under Creative Commons/CC-BY"
echo " Attribution"
echo
echo " if the script doesn't finish properly"
echo " (i.e. it doesn't print \"script finished\" at the end)"
echo " please email me the content of the logs folder"
echo
echo
echo " - script started - `date`"
## dest base path
TOOLS_PATH="$PWD"
## paths for the tools
TOOLS_BIN_PATH="$TOOLS_PATH/bin"
TOOLS_INC_PATH="$TOOLS_PATH/include"
TOOLS_LIB_PATH="$TOOLS_PATH/lib"
TOOLS_SRC_PATH="$TOOLS_PATH/src"
TOOLS_LOG_PATH="$TOOLS_PATH/logs"
TOOLS_PATCHED_PATH="$TOOLS_PATH/patched_files"
## get sys vars
ARCH=`uname -m`
CORES=`grep -c processor /proc/cpuinfo`
## loacal dest paths
if [ "$ARCH" = "i686" ]; then
LIB_PATH="/lib"
fi
if [ "$ARCH" = "x86_64" ]; then
LIB_PATH="/lib64"
fi
INC_PATH="/usr/local/include"
## source paths
BUNDLER_PATH="$TOOLS_SRC_PATH/bundler"
CMVS_PATH="$TOOLS_SRC_PATH/cmvs"
PMVS_PATH="$TOOLS_SRC_PATH/pmvs"
CLAPACK_PATH="$TOOLS_SRC_PATH/clapack"
VLFEAT_PATH="$TOOLS_SRC_PATH/vlfeat"
PARALLEL_PATH="$TOOLS_SRC_PATH/parallel"
PSR_PATH="$TOOLS_SRC_PATH/PoissonRecon"
GRACLUS_PATH="$TOOLS_SRC_PATH/graclus"
## executables
EXTRACT_FOCAL="$TOOLS_BIN_PATH/extract_focal.pl"
MATCHKEYS="$TOOLS_BIN_PATH/KeyMatch"
MATCHKEYSFULL="$TOOLS_BIN_PATH/KeyMatchFull"
BUNDLER="$TOOLS_BIN_PATH/bundler"
BUNDLE2PVMS="$TOOLS_BIN_PATH/Bundle2PMVS"
CMVS="$TOOLS_BIN_PATH/cmvs"
PMVS="$TOOLS_BIN_PATH/pmvs2"
GENOPTION="$TOOLS_BIN_PATH/genOption"
VLSIFT="$TOOLS_BIN_PATH/vlsift"
PARALLEL="$TOOLS_BIN_PATH/parallel"
PSR="$TOOLS_BIN_PATH/PoissonRecon"
VLSIFT_TO_LOWESIFT="$TOOLS_BIN_PATH/convert_vlsift_to_lowesift.pl"
## prevents different (localized) output
LC_ALL=C
## removing old stuff
sudo rm -Rf "$TOOLS_BIN_PATH"
sudo rm -Rf "$TOOLS_INC_PATH"
sudo rm -Rf "$TOOLS_LIB_PATH"
sudo rm -Rf "$TOOLS_SRC_PATH"
sudo rm -Rf "$TOOLS_LOG_PATH"
## create needed directories
mkdir -p "$TOOLS_BIN_PATH"
mkdir -p "$TOOLS_INC_PATH"
mkdir -p "$TOOLS_LIB_PATH"
mkdir -p "$TOOLS_SRC_PATH"
mkdir -p "$TOOLS_LOG_PATH"
## output sys info
echo "System info:" > "$TOOLS_LOG_PATH/sysinfo.txt"
uname -a > "$TOOLS_LOG_PATH/sysinfo.txt"
## install packages
echo
echo " > installing required packages"
echo " - updating"
sudo yum update -y > "$TOOLS_LOG_PATH/apt-get_get.log" 2>&1
echo " - installing"
yum install -y \
cmake gcc gcc-c++ compat-gcc-32 compat-gcc-32-c++ gcc-gfortran perl ruby rubygems git \
curl wget \
unzip \
ImageMagick jhead \
libjpeg-devel boost-devel gsl-devel libX11-devel libXext-devel lapack-devel blas-devel \
zlib-devel \
opencv-devel \
> "$TOOLS_LOG_PATH/apt-get_install.log" 2>&1
sudo gem install parallel > /dev/null 2>&1
echo " < done - `date`"
## downloading sources
echo
echo " > getting the sources"
## getting all archives if not already present; save them to .tmp and rename them after download
while read target source
do
if [ ! -f "$target" ] ; then
echo " - getting $source"
curl --progress-bar --insecure --location -o "$target.tmp" "$source"
mv "$target.tmp" "$target"
echo " - finished $target"
echo
else
echo " - already downloaded $source"
fi
done <<EOF
parallel.tar.bz2 http://ftp.gnu.org/gnu/parallel/parallel-20100922.tar.bz2
clapack.tgz http://www.netlib.org/clapack/clapack-3.2.1-CMAKE.tgz
bundler.zip http://phototour.cs.washington.edu/bundler/distr/bundler-v0.4-source.zip
PoissonRecon.zip http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version2/PoissonRecon.zip
vlfeat.tar.gz http://www.vlfeat.org/download/vlfeat-0.9.13-bin.tar.gz
cmvs.tar.gz http://www.di.ens.fr/cmvs/cmvs-fix2.tar.gz
graclus.tar.gz https://www.topoi.hu-berlin.de/graclus1.2.tar.gz
EOF
echo " < done - `date`"
## unzipping sources
echo
echo " - unzipping sources"
for i in *.tar.bz2 ; do
tar xjf "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
done
for i in *.tgz *.tar.gz ; do
tar xzf "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
done
for i in *.zip ; do
unzip "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
done
wait
mv -f graclus1.2 "$GRACLUS_PATH"
mv -f clapack-3.2.1-CMAKE "$CLAPACK_PATH"
mv -f vlfeat-0.9.13 "$VLFEAT_PATH"
mv -f bundler-v0.4-source "$BUNDLER_PATH"
mv -f parallel-20100922 "$PARALLEL_PATH"
mv -f PoissonRecon "$PSR_PATH"
mv -f cmvs "$CMVS_PATH"
echo " < done - `date`"
## copying patches
echo
echo " - copying patches"
echo
for file in `find $TOOLS_PATCHED_PATH -type f -print` ; do
cp $file $TOOLS_PATH/${file/$TOOLS_PATCHED_PATH/.}
done
echo " < done - `date`"
# building
echo
echo " - building"
echo
sudo chown -R `id -u`:`id -g` *
sudo chmod -R 777 *
echo " > graclus"
cd "$GRACLUS_PATH"
if [ "$ARCH" = "i686" ]; then
sed -i "$GRACLUS_PATH/Makefile.in" -e "11c\COPTIONS = -DNUMBITS=32"
fi
if [ "$ARCH" = "x86_64" ]; then
sed -i "$GRACLUS_PATH/Makefile.in" -e "11c\COPTIONS = -DNUMBITS=64"
fi
echo " - cleaning graclus"
make clean > "$TOOLS_LOG_PATH/graclus_1_clean.log" 2>&1
echo " - building graclus"
make -j > "$TOOLS_LOG_PATH/graclus_2_build.log" 2>&1
mkdir "$TOOLS_INC_PATH/metisLib"
cp -f "$GRACLUS_PATH/metisLib/"*.h "$TOOLS_INC_PATH/metisLib/"
cp -f lib* "$TOOLS_LIB_PATH/"
echo " < done - `date`"
echo
echo " > poisson surface reconstruction "
cd "$PSR_PATH"
sed -i "$PSR_PATH/Makefile" -e "21c\BIN = ./"
echo " - building poisson surface reconstruction"
make -j > "$TOOLS_LOG_PATH/poisson_1_build.log" 2>&1
cp -f "$PSR_PATH/PoissonRecon" "$TOOLS_BIN_PATH/PoissonRecon"
echo " < done - `date`"
echo
echo " > parallel"
cd "$PARALLEL_PATH"
echo " - configuring parallel"
./configure > "$TOOLS_LOG_PATH/parallel_1_build.log" 2>&1
echo " - building paralel"
make -j > "$TOOLS_LOG_PATH/parallel_2_build.log" 2>&1
cp -f src/parallel "$TOOLS_BIN_PATH/"
echo " < done - `date`"
echo
echo " > clapack"
cd "$CLAPACK_PATH"
cp make.inc.example make.inc
set +e
echo " - building clapack"
make all -j > "$TOOLS_LOG_PATH/clapack_1_build.log" 2>&1
set -e
echo " - installing clapack"
make lapack_install > "$TOOLS_LOG_PATH/clapack_2_install.log" 2>&1
cp -Rf INCLUDE "$INC_PATH/clapack"
echo " < done - `date`"
echo
echo " > vlfeat"
cd "$VLFEAT_PATH"
echo " - installing vlfeat"
if [ "$ARCH" = "i686" ]; then
cp -f "$VLFEAT_PATH/bin/glnx86/sift" "$TOOLS_BIN_PATH/vlsift"
cp -f "$VLFEAT_PATH/bin/glnx86/libvl.so" "$TOOLS_LIB_PATH/"
fi
if [ "$ARCH" = "x86_64" ]; then
cp -f "$VLFEAT_PATH/bin/glnxa64/sift" "$TOOLS_BIN_PATH/vlsift"
cp -f "$VLFEAT_PATH/bin/glnxa64/libvl.so" "$TOOLS_LIB_PATH/"
fi
echo " < done - `date`"
echo
echo " > cmvs"
cd "$CMVS_PATH/program/main"
sed -i "$CMVS_PATH/program/main/genOption.cc" -e "5c\#include <stdlib.h>\n"
sed -i "$CMVS_PATH/program/base/cmvs/bundle.cc" -e "3c\#include <numeric>\n"
sed -i "$CMVS_PATH/program/main/Makefile" -e "10c\#Your INCLUDE path (e.g., -I\/usr\/include)"
sed -i "$CMVS_PATH/program/main/Makefile" -e "11c\YOUR_INCLUDE_PATH =-I$INC_PATH -I$TOOLS_INC_PATH"
sed -i "$CMVS_PATH/program/main/Makefile" -e "13c\#Your metis directory (contains header files under graclus1.2/metisLib/)"
sed -i "$CMVS_PATH/program/main/Makefile" -e "14c\YOUR_INCLUDE_METIS_PATH = -I$TOOLS_INC_PATH/metisLib/"
sed -i "$CMVS_PATH/program/main/Makefile" -e "16c\#Your LDLIBRARY path (e.g., -L/usr/lib)"
sed -i "$CMVS_PATH/program/main/Makefile" -e "17c\YOUR_LDLIB_PATH = -L$LIB_PATH -L$TOOLS_LIB_PATH"
if [ "$ARCH" = "i686" ]; then
sed -i "$CMVS_PATH/program/main/Makefile" -e "22c\CXXFLAGS_CMVS = -O2 -Wall -Wno-deprecated -DNUMBITS=32 \\\\"
sed -i "$CMVS_PATH/program/main/Makefile" -e '24c\ -fopenmp -DNUMBITS=32 ${OPENMP_FLAG}'
fi
if [ "$ARCH" = "x86_64" ]; then
sed -i "$CMVS_PATH/program/main/Makefile" -e "22c\CXXFLAGS_CMVS = -O2 -Wall -Wno-deprecated -DNUMBITS=64 \\\\"
sed -i "$CMVS_PATH/program/main/Makefile" -e '24c\ -fopenmp -DNUMBITS=64 ${OPENMP_FLAG}'
fi
echo " - cleaning cmvs"
make clean > "$TOOLS_LOG_PATH/cmvs_1_clean.log" 2>&1
echo " - building cmvs"
make -j > "$TOOLS_LOG_PATH/cmvs_2_build.log" 2>&1
echo " - make depend cmvs"
sudo make depend > "$TOOLS_LOG_PATH/cmvs_3_depend.log" 2>&1
cp -f "$CMVS_PATH/program/main/cmvs" "$CMVS_PATH/program/main/pmvs2" "$CMVS_PATH/program/main/genOption" "$TOOLS_BIN_PATH/"
cp -f "$CMVS_PATH/program/main/"*so* "$TOOLS_LIB_PATH/"
echo " < done - `date`"
echo
echo " > bundler"
cd "$BUNDLER_PATH"
sed -i "$BUNDLER_PATH/src/BundlerApp.h" -e "620c\ BundlerApp();"
echo " - cleaning bundler"
make clean > "$TOOLS_LOG_PATH/bundler_1_clean.log" 2>&1
echo " - building bundler"
make -j > "$TOOLS_LOG_PATH/bundler_2_build.log" 2>&1
cp -f "$BUNDLER_PATH/bin/Bundle2PMVS" "$BUNDLER_PATH/bin/Bundle2Vis" "$BUNDLER_PATH/bin/KeyMatchFull" "$BUNDLER_PATH/bin/KeyMatch" "$BUNDLER_PATH/bin/bundler" "$BUNDLER_PATH/bin/RadialUndistort" "$TOOLS_BIN_PATH/"
cp -f "$BUNDLER_PATH/lib/libANN_char.so" "$TOOLS_LIB_PATH/"
echo " < done - `date`"
echo
cd "$TOOLS_PATH"
sudo install -o `id -u` -g `id -g` -m 644 -t "$LIB_PATH" lib/*.so
sudo /sbin/ldconfig -v > "$TOOLS_LOG_PATH/ldconfig.log" 2>&1
sudo chown -R `id -u`:`id -g` *
sudo chmod -R 777 *
echo " - script finished - `date`"
exit