-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.sh
More file actions
executable file
·272 lines (237 loc) · 6.82 KB
/
configure.sh
File metadata and controls
executable file
·272 lines (237 loc) · 6.82 KB
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
#!/bin/bash
# Ensure the DEBIAN_FRONTEND environment variable is set for apt-get calls
APT_GET="env DEBIAN_FRONTEND=noninteractive $(command -v apt-get)"
check_version(){
UBUNTU_VERSION=$(lsb_release -r)
case "$UBUNTU_VERSION" in
*"24.04"*)
echo "Ubuntu: $UBUNTU_VERSION, good!"
;;
*)
echo "You are not on a supported Ubuntu version (detected: $UBUNTU_VERSION)"
echo "It might be possible to run ODX on a newer version of Ubuntu, however, you cannot rely on this script."
exit 1
;;
esac
}
if [[ $2 =~ ^[0-9]+$ ]] ; then
processes=$2
else
processes=$(nproc)
fi
ensure_prereqs() {
export DEBIAN_FRONTEND=noninteractive
if ! command -v sudo &> /dev/null; then
echo "Installing sudo"
apt-get update
apt-get install -y --no-install-recommends sudo
else
sudo apt-get update
fi
if ! command -v lsb_release &> /dev/null; then
echo "Installing lsb_release"
sudo apt-get install -y --no-install-recommends lsb-release
fi
if ! command -v pkg-config &> /dev/null; then
echo "Installing pkg-config"
sudo apt-get install -y --no-install-recommends pkg-config
fi
echo "Installing tzdata"
sudo apt-get install -y tzdata
# UBUNTU_VERSION=$(lsb_release -r)
# if [[ "$UBUNTU_VERSION" == *"24.04"* ]]; then
# echo "Enabling PPA for Ubuntu GIS"
# sudo apt-get install -y --no-install-recommends software-properties-common
# sudo add-apt-repository ppa:ubuntugis/ppa
# sudo apt-get update
# fi
echo "Installing Python PIP"
sudo apt-get install -y --no-install-recommends \
python3-pip \
python3-setuptools
sudo pip3 install -U pip
}
installruntimedeps() {
echo "Installing runtime dependencies"
ensure_prereqs
check_version
for i in {1..20}; do
sudo apt-get install -y --no-install-recommends \
gdal-bin \
libgdal34t64 \
libgeotiff5 \
libjsoncpp25 \
libspqr4 \
libssl3t64 \
libusb-1.0-0 \
proj-data \
procps \
python3 \
python3-gdal \
python3-pkg-resources \
python3-requests \
python3-setuptools \
libavcodec60 \
libavformat60 \
libflann1.9 \
libgtk2.0-0 \
libjpeg-turbo8 \
libopenjpip7 \
liblapack3 \
libpng16-16 \
libproj25 \
libswscale7 \
libtbb12 \
libtiff6 \
libwebpdemux2 \
libxext6 \
libamd3 \
libcamd3 \
libccolamd3 \
libcholmod5 \
libcolamd3 \
libcxsparse4 \
libgoogle-glog0v6t64 \
libsuitesparseconfig7 \
libboost-program-options1.83.0 \
libboost-iostreams1.83.0 \
libboost-serialization1.83.0 \
libboost-system1.83.0 \
libgoogle-perftools4t64
break
echo "Attempt $i failed, sleeping..."
sleep 30
done
}
installbuilddeps(){
echo "Installing build dependencies"
for i in {1..20}; do
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
gdal-bin \
gfortran \
git \
libgdal-dev \
libgeotiff-dev \
libjsoncpp-dev \
libssl-dev \
libusb-1.0-0-dev \
ninja-build \
pkg-config \
python3-dev \
python3-gdal \
python3-pip \
python3-setuptools \
python3-wheel \
rsync \
swig3.0 \
libavcodec-dev \
libavformat-dev \
libeigen3-dev \
libflann-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libopenjpip7 \
libpng-dev \
libproj-dev \
libswscale-dev \
libtbb-dev \
libtiff-dev \
libxext-dev \
proj-bin \
libgoogle-glog-dev \
libsuitesparse-dev \
libcgal-dev \
libboost-program-options-dev \
libboost-iostreams-dev \
libboost-serialization-dev \
libboost-system-dev \
libgoogle-perftools-dev
break
echo "Attempt $i failed, sleeping..."
sleep 30
done
}
installreqs() {
cd /code
## Set up library paths
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RUNPATH/SuperBuild/install/lib
## Before installing
echo "Updating"
ensure_prereqs
check_version
ensure_prereqs
check_version
installbuilddeps
set -e
# edt requires numpy to build
pip install --ignore-installed numpy==2.3.2 --break-system-packages
pip install --ignore-installed -r requirements.txt --break-system-packages
set +e
}
install() {
installreqs
if [ ! -z "$PORTABLE_INSTALL" ]; then
echo "Replacing g++ and gcc with our scripts for portability..."
if [ ! -e /usr/bin/gcc_real ]; then
sudo mv -v /usr/bin/gcc /usr/bin/gcc_real
sudo cp -v ./docker/gcc /usr/bin/gcc
fi
if [ ! -e /usr/bin/g++_real ]; then
sudo mv -v /usr/bin/g++ /usr/bin/g++_real
sudo cp -v ./docker/g++ /usr/bin/g++
fi
fi
set -eo pipefail
echo "Compiling SuperBuild"
cd ${RUNPATH}/SuperBuild
mkdir -p build && cd build
cmake .. && make -j$(nproc)
echo "Configuration Finished"
}
uninstall() {
check_version
echo "Removing SuperBuild and build directories"
cd ${RUNPATH}/SuperBuild
rm -rfv build src download install
cd ../
rm -rfv build
}
reinstall() {
check_version
echo "Reinstalling"
uninstall
install
}
clean() {
rm -rf \
${RUNPATH}/SuperBuild/build \
${RUNPATH}/SuperBuild/download \
${RUNPATH}/SuperBuild/src \
${RUNPATH}/SuperBuild/install/bin/opensfm/.git \
${RUNPATH}/SuperBuild/install/bin/opensfm/opensfm/src/third_party/pybind11/.git
# find in /code and delete static libraries and intermediate object files
find ${RUNPATH} -type f -name "*.a" -delete -or -type f -name "*.o" -delete
}
usage() {
echo "Usage:"
echo "bash configure.sh <install|update|uninstall|installreqs|help> [nproc]"
echo "Commands:"
echo " install"
echo " installruntimedeps"
echo " reinstall"
echo " uninstall"
echo " installreqs"
echo " clean"
echo " help"
}
if [[ $1 =~ ^(install|installruntimedeps|reinstall|uninstall|installreqs|clean)$ ]]; then
RUNPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
"$1"
else
echo "Invalid command"
usage
exit 1
fi