11#! /bin/bash
2-
3- # Ensure the DEBIAN_FRONTEND environment variable is set for apt-get calls
4- APT_GET=" env DEBIAN_FRONTEND=noninteractive $( command -v apt-get) "
5-
6- check_version (){
7- UBUNTU_VERSION=$( lsb_release -r)
8- case " $UBUNTU_VERSION " in
9- * " 20.04" * |* " 21.04" * |* " 24.04" * )
10- echo " Ubuntu: $UBUNTU_VERSION , good!"
11- ;;
12- * " 18.04" * |* " 16.04" * )
13- echo " ODM 2.1 has upgraded to Ubuntu 21.04, but you're on $UBUNTU_VERSION "
14- echo " * The last version of ODM that supports Ubuntu 16.04 is v1.0.2."
15- echo " * The last version of ODM that supports Ubuntu 18.04 is v2.0.0."
16- echo " We recommend you to upgrade, or better yet, use docker."
17- exit 1
18- ;;
19- * )
20- echo " You are not on Ubuntu 21.04 (detected: $UBUNTU_VERSION )"
21- echo " It might be possible to run ODM on a newer version of Ubuntu, however, you cannot rely on this script."
22- exit 1
23- ;;
24- esac
25- }
26-
27- if [[ $2 =~ ^[0-9]+$ ]] ; then
28- processes=$2
29- else
30- processes=$( nproc)
31- fi
32-
33- ensure_prereqs () {
34- export DEBIAN_FRONTEND=noninteractive
35-
36- if ! command -v sudo & > /dev/null; then
37- echo " Installing sudo"
38- $APT_GET update
39- $APT_GET install -y -qq --no-install-recommends sudo
40- else
41- sudo $APT_GET update
42- fi
43-
44- if ! command -v lsb_release & > /dev/null; then
45- echo " Installing lsb_release"
46- sudo $APT_GET install -y -qq --no-install-recommends lsb-release
47- fi
48-
49- if ! command -v pkg-config & > /dev/null; then
50- echo " Installing pkg-config"
51- sudo $APT_GET install -y -qq --no-install-recommends pkg-config
52- fi
53-
54- echo " Installing tzdata"
55- sudo $APT_GET install -y -qq tzdata
56-
57- UBUNTU_VERSION=$( lsb_release -r)
58- if [[ " $UBUNTU_VERSION " == * " 20.04" * ]]; then
59- echo " Enabling PPA for Ubuntu GIS"
60- sudo $APT_GET install -y -qq --no-install-recommends software-properties-common
61- sudo add-apt-repository ppa:ubuntugis/ppa
62- sudo $APT_GET update
63- elif [[ " $UBUNTU_VERSION " == * " 24.04" * ]]; then
64- echo " Enabling ubuntugis-unstable PPA for Ubuntu 24.04"
65- sudo $APT_GET install -y -qq --no-install-recommends software-properties-common
66- sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
67- sudo $APT_GET update
68- fi
69-
70- echo " Installing Python PIP"
71- sudo $APT_GET install -y -qq --no-install-recommends \
72- python3-pip \
73- python3-setuptools \
74- python3-venv
75- python3 -m venv venv --system-site-packages
76- venv/bin/pip3 install -U pip
77- venv/bin/pip3 install -U shyaml
78- }
79-
80- # Save all dependencies in snapcraft.yaml to maintain a single source of truth.
81- # Maintaining multiple lists will otherwise be painful.
82- installdepsfromsnapcraft () {
83- section=" $2 "
84- case " $1 " in
85- build) key=build-packages; ;;
86- runtime) key=stage-packages; ;;
87- * ) key=build-packages; ;; # shouldn't be needed, but it's here just in case
88- esac
89-
90- UBUNTU_VERSION=$( lsb_release -r)
91- SNAPCRAFT_FILE=" snapcraft.yaml"
92- if [[ " $UBUNTU_VERSION " == * " 21.04" * ]]; then
93- SNAPCRAFT_FILE=" snapcraft21.yaml"
94- elif [[ " $UBUNTU_VERSION " == * " 24.04" * ]]; then
95- SNAPCRAFT_FILE=" snapcraft24.yaml"
96- fi
97-
98- cat snap/$SNAPCRAFT_FILE | \
99- venv/bin/shyaml get-values-0 parts.$section .$key | \
100- xargs -0 sudo $APT_GET install -y -qq --no-install-recommends
101- }
102-
103- installruntimedepsonly () {
104- echo " Installing runtime dependencies"
105- ensure_prereqs
106- check_version
107-
108- echo " Installing Required Requisites"
109- installdepsfromsnapcraft runtime prereqs
110- echo " Installing OpenCV Dependencies"
111- installdepsfromsnapcraft runtime opencv
112- echo " Installing OpenSfM Dependencies"
113- installdepsfromsnapcraft runtime opensfm
114- echo " Installing OpenMVS Dependencies"
115- installdepsfromsnapcraft runtime openmvs
116- }
117-
118- installreqs () {
119- cd /code
120-
121- # # Set up library paths
122- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH :$RUNPATH /SuperBuild/install/lib
123-
124- # # Before installing
125- echo " Updating the system"
126- ensure_prereqs
127- check_version
128-
129- echo " Installing Required Requisites"
130- installdepsfromsnapcraft build prereqs
131- echo " Installing OpenCV Dependencies"
132- installdepsfromsnapcraft build opencv
133- echo " Installing OpenSfM Dependencies"
134- installdepsfromsnapcraft build opensfm
135- echo " Installing OpenMVS Dependencies"
136- installdepsfromsnapcraft build openmvs
137-
138- set -e
139-
140- # edt requires numpy to build
141- venv/bin/pip install numpy==2.3.2
142- venv/bin/pip install -r requirements.txt --ignore-installed
143- # if [ ! -z "$GPU_INSTALL" ]; then
144- # fi
145- set +e
146- }
2+ ROOT_SCRIPT_DIR=$( dirname " $( readlink -f " $0 " ) " )
3+ source " ${ROOT_SCRIPT_DIR} /scripts/linux/build.sh"
4+ source " ${ROOT_SCRIPT_DIR} /scripts/linux/prepare_develop.sh"
5+ source " ${ROOT_SCRIPT_DIR} /scripts/linux/prepare_runtime.sh"
1476
1487install () {
1498 installreqs
150-
151- if [ ! -z " $PORTABLE_INSTALL " ]; then
152- echo " Replacing g++ and gcc with our scripts for portability..."
153- if [ ! -e /usr/bin/gcc_real ]; then
154- sudo mv -v /usr/bin/gcc /usr/bin/gcc_real
155- sudo cp -v ./docker/gcc /usr/bin/gcc
156- fi
157- if [ ! -e /usr/bin/g++_real ]; then
158- sudo mv -v /usr/bin/g++ /usr/bin/g++_real
159- sudo cp -v ./docker/g++ /usr/bin/g++
160- fi
161- fi
162-
163- set -eo pipefail
164-
165- echo " Compiling SuperBuild"
166- cd ${RUNPATH} /SuperBuild
167- mkdir -p build && cd build
168- cmake .. && make -j$processes
169-
170- echo " Configuration Finished"
9+ build
10+ echo " Configuration Finished"
17111}
17212
17313uninstall () {
@@ -200,7 +40,7 @@ clean() {
20040
20141usage () {
20242 echo " Usage:"
203- echo " bash configure.sh <install|update| uninstall|installreqs|help > [nproc]"
43+ echo " bash configure.sh <install|installruntimedepsonly|reinstall| uninstall|installreqs|clean|build > [nproc]"
20444 echo " Subcommands:"
20545 echo " install"
20646 echo " Installs all dependencies and modules for running OpenDroneMap"
@@ -214,12 +54,14 @@ usage() {
21454 echo " Only installs the requirements (does not build SuperBuild)"
21555 echo " clean"
21656 echo " Cleans the SuperBuild directory by removing temporary files. "
57+ echo " build"
58+ echo " Builds the SuperBuild modules (assumes requirements are already installed)"
21759 echo " help"
21860 echo " Displays this message"
21961 echo " [nproc] is an optional argument that can set the number of processes for the make -j tag. By default it uses $( nproc) "
22062}
22163
222- if [[ $1 =~ ^(install| installruntimedepsonly| reinstall| uninstall| installreqs| clean)$ ]]; then
64+ if [[ $1 =~ ^(install| installruntimedepsonly| reinstall| uninstall| installreqs| clean| build )$ ]]; then
22365 RUNPATH=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
22466 " $1 "
22567else
0 commit comments