2015-11-16 13:47:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-11-02 18:35:32 +00:00
|
|
|
# Ensure the DEBIAN_FRONTEND environment variable is set for apt-get calls
|
|
|
|
APT_GET="env DEBIAN_FRONTEND=noninteractive $(command -v apt-get)"
|
|
|
|
|
2021-09-02 22:12:18 +00:00
|
|
|
check_version(){
|
2021-09-06 15:17:43 +00:00
|
|
|
UBUNTU_VERSION=$(lsb_release -r)
|
2020-11-05 22:47:49 +00:00
|
|
|
case "$UBUNTU_VERSION" in
|
2021-09-02 22:12:18 +00:00
|
|
|
*"20.04"*|*"21.04"*)
|
2020-11-05 22:47:49 +00:00
|
|
|
echo "Ubuntu: $UBUNTU_VERSION, good!"
|
|
|
|
;;
|
|
|
|
*"18.04"*|*"16.04"*)
|
2021-09-02 22:12:18 +00:00
|
|
|
echo "ODM 2.1 has upgraded to Ubuntu 21.04, but you're on $UBUNTU_VERSION"
|
2020-11-05 22:47:49 +00:00
|
|
|
echo "* The last version of ODM that supports Ubuntu 16.04 is v1.0.2."
|
|
|
|
echo "* The last version of ODM that supports Ubuntu 18.04 is v2.0.0."
|
2020-11-25 18:55:19 +00:00
|
|
|
echo "We recommend you to upgrade, or better yet, use docker."
|
2020-11-05 22:47:49 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
2021-09-02 22:12:18 +00:00
|
|
|
echo "You are not on Ubuntu 21.04 (detected: $UBUNTU_VERSION)"
|
2020-11-05 22:47:49 +00:00
|
|
|
echo "It might be possible to run ODM on a newer version of Ubuntu, however, you cannot rely on this script."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2020-09-08 17:08:57 +00:00
|
|
|
}
|
|
|
|
|
2018-08-24 13:19:40 +00:00
|
|
|
if [[ $2 =~ ^[0-9]+$ ]] ; then
|
|
|
|
processes=$2
|
|
|
|
else
|
|
|
|
processes=$(nproc)
|
|
|
|
fi
|
|
|
|
|
2020-11-02 18:35:32 +00:00
|
|
|
ensure_prereqs() {
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
if ! command -v sudo &> /dev/null; then
|
|
|
|
echo "Installing sudo"
|
|
|
|
$APT_GET update
|
|
|
|
$APT_GET install -y -qq --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 -qq --no-install-recommends lsb-release
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! command -v pkg-config &> /dev/null; then
|
|
|
|
echo "Installing pkg-config"
|
|
|
|
sudo $APT_GET install -y -qq --no-install-recommends pkg-config
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Installing tzdata"
|
|
|
|
sudo $APT_GET install -y -qq tzdata
|
|
|
|
|
2021-09-06 15:17:43 +00:00
|
|
|
UBUNTU_VERSION=$(lsb_release -r)
|
2021-09-02 22:12:18 +00:00
|
|
|
if [[ "$UBUNTU_VERSION" == *"20.04"* ]]; then
|
|
|
|
echo "Enabling PPA for Ubuntu GIS"
|
|
|
|
sudo $APT_GET install -y -qq --no-install-recommends software-properties-common
|
|
|
|
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
|
|
|
|
sudo $APT_GET update
|
|
|
|
fi
|
2020-11-02 18:35:32 +00:00
|
|
|
|
|
|
|
echo "Installing Python PIP"
|
|
|
|
sudo $APT_GET install -y -qq --no-install-recommends \
|
|
|
|
python3-pip \
|
|
|
|
python3-setuptools
|
|
|
|
sudo pip3 install -U pip
|
|
|
|
sudo pip3 install -U shyaml
|
|
|
|
}
|
|
|
|
|
|
|
|
# Save all dependencies in snapcraft.yaml to maintain a single source of truth.
|
|
|
|
# Maintaining multiple lists will otherwise be painful.
|
|
|
|
installdepsfromsnapcraft() {
|
|
|
|
section="$2"
|
|
|
|
case "$1" in
|
|
|
|
build) key=build-packages; ;;
|
|
|
|
runtime) key=stage-packages; ;;
|
|
|
|
*) key=build-packages; ;; # shouldn't be needed, but it's here just in case
|
|
|
|
esac
|
|
|
|
|
2021-09-06 15:17:43 +00:00
|
|
|
UBUNTU_VERSION=$(lsb_release -r)
|
2021-09-02 22:12:18 +00:00
|
|
|
SNAPCRAFT_FILE="snapcraft.yaml"
|
|
|
|
if [[ "$UBUNTU_VERSION" == *"21.04"* ]]; then
|
|
|
|
SNAPCRAFT_FILE="snapcraft21.yaml"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat snap/$SNAPCRAFT_FILE | \
|
2020-11-02 18:35:32 +00:00
|
|
|
shyaml get-values-0 parts.$section.$key | \
|
|
|
|
xargs -0 sudo $APT_GET install -y -qq --no-install-recommends
|
|
|
|
}
|
|
|
|
|
|
|
|
installruntimedepsonly() {
|
|
|
|
echo "Installing runtime dependencies"
|
|
|
|
ensure_prereqs
|
|
|
|
check_version
|
|
|
|
|
|
|
|
echo "Installing Required Requisites"
|
|
|
|
installdepsfromsnapcraft runtime prereqs
|
|
|
|
echo "Installing OpenCV Dependencies"
|
|
|
|
installdepsfromsnapcraft runtime opencv
|
|
|
|
echo "Installing OpenSfM Dependencies"
|
|
|
|
installdepsfromsnapcraft runtime opensfm
|
2020-11-02 21:26:48 +00:00
|
|
|
echo "Installing OpenMVS Dependencies"
|
|
|
|
installdepsfromsnapcraft runtime openmvs
|
|
|
|
|
2020-11-02 18:35:32 +00:00
|
|
|
}
|
2021-06-20 20:54:25 +00:00
|
|
|
|
|
|
|
installreqs() {
|
2020-09-08 17:08:57 +00:00
|
|
|
cd /code
|
|
|
|
|
2017-04-06 16:22:42 +00:00
|
|
|
## Set up library paths
|
|
|
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RUNPATH/SuperBuild/install/lib
|
|
|
|
|
2020-09-08 17:08:57 +00:00
|
|
|
## Before installing
|
2017-04-06 16:22:42 +00:00
|
|
|
echo "Updating the system"
|
2020-11-02 18:35:32 +00:00
|
|
|
ensure_prereqs
|
2020-09-09 16:10:24 +00:00
|
|
|
check_version
|
|
|
|
|
2017-04-06 16:22:42 +00:00
|
|
|
echo "Installing Required Requisites"
|
2020-11-02 18:35:32 +00:00
|
|
|
installdepsfromsnapcraft build prereqs
|
2017-04-06 16:22:42 +00:00
|
|
|
echo "Installing OpenCV Dependencies"
|
2020-11-02 18:35:32 +00:00
|
|
|
installdepsfromsnapcraft build opencv
|
2017-04-06 16:22:42 +00:00
|
|
|
echo "Installing OpenSfM Dependencies"
|
2020-11-02 18:35:32 +00:00
|
|
|
installdepsfromsnapcraft build opensfm
|
2020-11-02 21:26:48 +00:00
|
|
|
echo "Installing OpenMVS Dependencies"
|
|
|
|
installdepsfromsnapcraft build openmvs
|
|
|
|
|
2021-11-17 16:20:34 +00:00
|
|
|
set -e
|
2020-10-22 19:34:43 +00:00
|
|
|
pip install --ignore-installed -r requirements.txt
|
2021-12-17 16:59:03 +00:00
|
|
|
#if [ ! -z "$GPU_INSTALL" ]; then
|
|
|
|
#fi
|
2021-11-17 16:20:34 +00:00
|
|
|
set +e
|
2021-06-20 20:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
|
|
|
installreqs
|
2019-05-12 14:56:09 +00:00
|
|
|
|
2020-09-16 14:04:51 +00:00
|
|
|
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
|
|
|
|
|
2020-09-16 15:26:43 +00:00
|
|
|
set -eo pipefail
|
|
|
|
|
2017-04-06 16:22:42 +00:00
|
|
|
echo "Compiling SuperBuild"
|
2020-09-16 14:04:51 +00:00
|
|
|
cd ${RUNPATH}/SuperBuild
|
|
|
|
mkdir -p build && cd build
|
|
|
|
cmake .. && make -j$processes
|
2017-04-06 16:22:42 +00:00
|
|
|
|
|
|
|
echo "Configuration Finished"
|
|
|
|
}
|
|
|
|
|
|
|
|
uninstall() {
|
2020-09-09 16:10:24 +00:00
|
|
|
check_version
|
|
|
|
|
2017-04-06 16:22:42 +00:00
|
|
|
echo "Removing SuperBuild and build directories"
|
|
|
|
cd ${RUNPATH}/SuperBuild
|
|
|
|
rm -rfv build src download install
|
|
|
|
cd ../
|
|
|
|
rm -rfv build
|
|
|
|
}
|
|
|
|
|
|
|
|
reinstall() {
|
2020-09-09 16:10:24 +00:00
|
|
|
check_version
|
|
|
|
|
2017-04-06 16:22:42 +00:00
|
|
|
echo "Reinstalling ODM modules"
|
|
|
|
uninstall
|
|
|
|
install
|
|
|
|
}
|
2021-01-24 14:45:00 +00:00
|
|
|
|
|
|
|
clean() {
|
|
|
|
rm -rf \
|
2021-04-28 20:06:27 +00:00
|
|
|
${RUNPATH}/SuperBuild/build \
|
2021-01-24 14:45:00 +00:00
|
|
|
${RUNPATH}/SuperBuild/download \
|
2021-04-28 20:06:27 +00:00
|
|
|
${RUNPATH}/SuperBuild/src
|
2021-01-24 14:45:00 +00:00
|
|
|
|
|
|
|
# find in /code and delete static libraries and intermediate object files
|
|
|
|
find ${RUNPATH} -type f -name "*.a" -delete -or -type f -name "*.o" -delete
|
|
|
|
}
|
|
|
|
|
2017-04-06 16:22:42 +00:00
|
|
|
usage() {
|
|
|
|
echo "Usage:"
|
2021-06-20 20:54:25 +00:00
|
|
|
echo "bash configure.sh <install|update|uninstall|installreqs|help> [nproc]"
|
2017-04-06 16:22:42 +00:00
|
|
|
echo "Subcommands:"
|
|
|
|
echo " install"
|
|
|
|
echo " Installs all dependencies and modules for running OpenDroneMap"
|
2020-11-02 18:35:32 +00:00
|
|
|
echo " installruntimedepsonly"
|
|
|
|
echo " Installs *only* the runtime libraries (used by docker builds). To build from source, use the 'install' command."
|
2017-04-06 16:22:42 +00:00
|
|
|
echo " reinstall"
|
|
|
|
echo " Removes SuperBuild and build modules, then re-installs them. Note this does not update OpenDroneMap to the latest version. "
|
|
|
|
echo " uninstall"
|
|
|
|
echo " Removes SuperBuild and build modules. Does not uninstall dependencies"
|
2021-06-20 20:54:25 +00:00
|
|
|
echo " installreqs"
|
|
|
|
echo " Only installs the requirements (does not build SuperBuild)"
|
2021-01-24 14:45:00 +00:00
|
|
|
echo " clean"
|
|
|
|
echo " Cleans the SuperBuild directory by removing temporary files. "
|
2017-04-06 16:22:42 +00:00
|
|
|
echo " help"
|
|
|
|
echo " Displays this message"
|
2017-09-22 17:51:12 +00:00
|
|
|
echo "[nproc] is an optional argument that can set the number of processes for the make -j tag. By default it uses $(nproc)"
|
2017-04-06 16:22:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-20 20:54:25 +00:00
|
|
|
if [[ $1 =~ ^(install|installruntimedepsonly|reinstall|uninstall|installreqs|clean)$ ]]; then
|
2017-04-06 16:22:42 +00:00
|
|
|
RUNPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
"$1"
|
|
|
|
else
|
|
|
|
echo "Invalid instructions." >&2
|
|
|
|
usage
|
|
|
|
exit 1
|
2017-06-26 04:57:57 +00:00
|
|
|
fi
|