Compare commits

...

2 Commits

Author SHA1 Message Date
Julian Oes 115568eb82 setup: pass through Ubuntu setup script
- Add usage function
- Add support for Ubuntu 22.04
- Update arm-none-eabi-gcc to version 10.3
- Remove jMAVSim / Java stuff
- Remove FastRTPS / Java stuff
- Fix some typos
- Add Gazebo Ignition
- Disable Gazebo for Ubuntu 18.04
- Fix some shellcheck issues
- Cleanup apt caches in docker
2022-09-09 14:38:33 +12:00
Ramon Roche c89ae1d690 ubuntu.sh: updated dependencies and output
I double checked each new dependency and made sure to build each target
with the new install script as well as test FastRTPS and Simulations

* removed unused dependencies
* settled on the absolute most updated JDK we could possibly use given
our dependencies (JDK 14)
* added conditional support for use in a container environment via a new
flag --from-docker
* added multi-platform build tools for development
2022-09-09 13:27:34 +12:00
+189 -110
View File
@@ -2,20 +2,29 @@
set -e set -e
## Bash script to setup PX4 development environment on Ubuntu LTS (20.04, 18.04, 16.04). usage() {
## Can also be used in docker. echo "
## Bash script to set up the PX4 development environment on Ubuntu LTS versions
## Installs: - 22.04
## - Common dependencies and tools for nuttx, jMAVSim, Gazebo - 20.04
## - NuttX toolchain (omit with arg: --no-nuttx) - 18.04 (without simulation support)
## - jMAVSim and Gazebo9 simulator (omit with arg: --no-sim-tools)
## The script can be used directly or inside docker
## Not Installs: (use --from-docker when running inside docker).
## - FastRTPS and FastCDR
Installs:
- Build dependencies
- NuttX toolchain (omit with arg: --no-nuttx)
- Gazebo Classic (omit with arg: --no-gazebo-classic)
- Gazebo Ignition (omit with arg: --no-gazebo-ignition)
"
}
INSTALL_NUTTX="true" INSTALL_NUTTX="true"
INSTALL_SIM="true" INSTALL_GAZEBO_CLASSIC="true"
INSTALL_ARCH=`uname -m` INSTALL_GAZEBO_IGNITION="true"
INSTALL_ARCH=$(uname -m)
INSIDE_DOCKER="false"
# Parse arguments # Parse arguments
for arg in "$@" for arg in "$@"
@@ -24,38 +33,38 @@ do
INSTALL_NUTTX="false" INSTALL_NUTTX="false"
fi fi
if [[ $arg == "--no-sim-tools" ]]; then if [[ $arg == "--no-gazebo-classic" ]]; then
INSTALL_SIM="false" INSTALL_GAZEBO_CLASSIC="false"
fi
if [[ $arg == "--no-gazebo-ignition" ]]; then
INSTALL_GAZEBO_IGNITION="false"
fi
if [[ $arg == "--from-docker" ]]; then
INSIDE_DOCKER="true"
fi
if [[ $arg == "--help" ]]; then
usage
exit 0
fi fi
done done
# detect if running in docker # Script directory
if [ -f /.dockerenv ]; then
echo "Running within docker, installing initial dependencies";
apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \
ca-certificates \
gnupg \
lsb-core \
sudo \
wget \
;
fi
# script directory
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# check requirements.txt exists (script not run in source tree) # Check requirements.txt exists (script not run in source tree)
REQUIREMENTS_FILE="requirements.txt" REQUIREMENTS_FILE="requirements.txt"
if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
echo "FAILED: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})." echo "Failed: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})."
return 1 exit 1
fi fi
# check ubuntu version # Check ubuntu version
# otherwise warn and point to docker? UBUNTU_RELEASE=$(lsb_release -rs)
UBUNTU_RELEASE="`lsb_release -rs`"
if [[ "${UBUNTU_RELEASE}" == "14.04" ]]; then if [[ "${UBUNTU_RELEASE}" == "14.04" ]]; then
echo "Ubuntu 14.04 is no longer supported" echo "Ubuntu 14.04 is no longer supported"
@@ -65,24 +74,43 @@ elif [[ "${UBUNTU_RELEASE}" == "16.04" ]]; then
exit 1 exit 1
elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
echo "Ubuntu 18.04" echo "Ubuntu 18.04"
echo "Gazebo Classic and Gazebo Ignition omitted"
INSTALL_GAZEBO_IGNITION="false"
INSTALL_GAZEBO_CLASSIC="false"
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
echo "Ubuntu 20.04" echo "Ubuntu 20.04"
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
echo "Ubuntu 22.04"
fi fi
VERBOSE_BAR="================================================================================"
echo
echo $VERBOSE_BAR
echo "⚡️ Starting PX4 Dependency Installer for Ubuntu ${UBUNTU_RELEASE} (${INSTALL_ARCH})"
echo ""
echo "Options:
- Install NuttX toolchain: ${INSTALL_NUTTX}
- Install Gazebo Classic: ${INSTALL_GAZEBO_CLASSIC}
- Install Gazebo Ignition: ${INSTALL_GAZEBO_IGNITION}"
echo $VERBOSE_BAR
echo
echo echo
echo "Installing PX4 general dependencies" echo $VERBOSE_BAR
echo "🍻 Installing System Dependencies"
echo $VERBOSE_BAR
echo
sudo apt-get update -y --quiet sudo apt-get update -y --quiet
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
astyle \
build-essential \ build-essential \
cmake \
cppcheck \
file \
g++ \ g++ \
gcc \ gcc \
gdb \ gdb \
astyle \
cmake \
cppcheck \
file \
git \ git \
lcov \ lcov \
libxml2-dev \ libxml2-dev \
@@ -98,34 +126,32 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i
shellcheck \ shellcheck \
unzip \ unzip \
zip \ zip \
libssl-dev \
; ;
# Python3 dependencies # Python 3 dependencies
echo echo
echo "Installing PX4 Python3 dependencies" echo $VERBOSE_BAR
if [ -n "$VIRTUAL_ENV" ]; then echo "🍻 Installing Python dependencies"
# virtual environments don't allow --user option echo $VERBOSE_BAR
python -m pip install -r ${DIR}/requirements.txt echo
else
# older versions of Ubuntu require --user option python3 -m pip install -r "$DIR"/requirements.txt
python3 -m pip install --user -r ${DIR}/requirements.txt
fi
# NuttX toolchain (arm-none-eabi-gcc) # NuttX toolchain (arm-none-eabi-gcc)
if [[ $INSTALL_NUTTX == "true" ]]; then if [[ $INSTALL_NUTTX == "true" ]]; then
echo echo
echo "Installing NuttX dependencies" echo $VERBOSE_BAR
echo "🍻 Installing NuttX dependencies"
echo $VERBOSE_BAR
echo
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
automake \ automake \
binutils-dev \ binutils-dev \
bison \ bison \
build-essential \
flex \ flex \
g++-multilib \
gcc-multilib \
gdb-multiarch \
genromfs \ genromfs \
gettext \ gettext \
gperf \ gperf \
@@ -144,99 +170,108 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
texinfo \ texinfo \
u-boot-tools \ u-boot-tools \
util-linux \ util-linux \
vim-common \ g++-arm-linux-gnueabihf \
gcc-arm-linux-gnueabihf \
g++-aarch64-linux-gnu \
gcc-aarch64-linux-gnu \
; ;
if [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
if [[ "${UBUNTU_RELEASE}" == "20.04" ]] || [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
kconfig-frontends \ kconfig-frontends \
; ;
fi fi
if [ -n "$USER" ]; then if [ -n "$USER" ]; then
# add user to dialout group (serial port access) # Add user to dialout group (serial port access)
sudo usermod -a -G dialout $USER sudo usermod -a -G dialout "$USER"
fi fi
# arm-none-eabi-gcc NUTTX_GCC_VERSION="10.3-2021.10"
NUTTX_GCC_VERSION="9-2020-q2-update" echo
NUTTX_GCC_VERSION_SHORT="9-2020q2" echo $VERBOSE_BAR
echo "🍻 Verifying arm-none-eabi-gcc version (${NUTTX_GCC_VERSION}), and installing if not found"
echo
source $HOME/.profile # load changed path for the case the script is reran before relogin source "$HOME/.profile" # load changed path for the case the script is reran before relogin
if [ $(which arm-none-eabi-gcc) ]; then if [ "$(which arm-none-eabi-gcc)" ]; then
GCC_VER_STR=$(arm-none-eabi-gcc --version) GCC_VER_STR=$(arm-none-eabi-gcc --version)
GCC_FOUND_VER=$(echo $GCC_VER_STR | grep -c "${NUTTX_GCC_VERSION}")
fi fi
if [[ "$GCC_FOUND_VER" == "1" ]]; then if [[ $(echo "$GCC_VER_STR" | grep -c "${NUTTX_GCC_VERSION}") == "1" ]]; then
echo "arm-none-eabi-gcc-${NUTTX_GCC_VERSION} found, skipping installation" echo "📌 Skipping installation, the arm cross compiler was found"
echo $VERBOSE_BAR
echo
else else
echo "Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}"; echo "📌 The arm cross compiler was not found";
wget -O /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION_SHORT}/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-${INSTALL_ARCH}-linux.tar.bz2 && \ echo " * Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
sudo tar -jxf /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 -C /opt/; # The arm cross compiler hosting provider is known to throttle download speeds
# for users who reach a certain limit of downloads in a given time frame
# for this reason we allow for using a previously downloaded file
# this is specially helpful when debugging this installer script
# from within a container COMPILER_PATH="/tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2"
COMPILER_NAME="gcc-arm-none-eabi-${NUTTX_GCC_VERSION}"
COMPILER_PATH="/tmp/$COMPILER_NAME-linux.tar.bz2"
if [ ! -f "$COMPILER_PATH" ]; then
wget -O "/tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://developer.arm.com/-/media/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION}/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-${INSTALL_ARCH}-linux.tar.bz2"
fi
sudo tar -jxf $COMPILER_PATH -C /opt/;
# add arm-none-eabi-gcc to user's PATH # add arm-none-eabi-gcc to user's PATH
exportline="export PATH=/opt/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}/bin:\$PATH" exportline="export PATH=\"/opt/${COMPILER_NAME}/bin:\$PATH\""
if [[ $INSIDE_DOCKER == "true" ]]; then
if grep -Fxq "$exportline" $HOME/.profile; then # when running on a docker container its best to set the environment globally
# since we don't know which user is going to be running commands on the container
touch /etc/profile.d/px4env.sh
echo "$exportline" >> /etc/profile.d/px4env.sh
elif grep -Fxq "$exportline" "$HOME"/.profile; then
echo "${NUTTX_GCC_VERSION} path already set."; echo "${NUTTX_GCC_VERSION} path already set.";
else else
echo $exportline >> $HOME/.profile; echo "$exportline" >> "$HOME"/.profile;
fi fi
echo " * arm-none-eabi-gcc (${NUTTX_GCC_VERSION}) Installed successfully to /opt/${COMPILER_NAME}/bin"
echo $VERBOSE_BAR
echo
fi fi
fi fi
# Simulation tools install_gazebo_common() {
if [[ $INSTALL_SIM == "true" ]]; then
echo
echo "Installing PX4 simulation dependencies"
# General simulation dependencies # General simulation dependencies
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
bc \ bc \
; ;
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then # Installing Gazebo and dependencies
java_version=11 # Setup OSRF Gazebo repository
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
java_version=13 wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then # Update list, since new gazebo-stable.list has been added
java_version=11 sudo apt-get update -y --quiet
else }
java_version=14
fi
# Java (jmavsim or fastrtps)
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
ant \
openjdk-$java_version-jre \
openjdk-$java_version-jdk \
libvecmath-java \
;
# Set Java 11 as default # Gazebo Classic
sudo update-alternatives --set java $(update-alternatives --list java | grep "java-$java_version") if [[ $INSTALL_GAZEBO_CLASSIC == "true" ]]; then
# Gazebo echo
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then echo $VERBOSE_BAR
gazebo_version=9 echo "🍻 Installing Gazebo Classic"
gazebo_packages="gazebo$gazebo_version libgazebo$gazebo_version-dev" echo
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
gazebo_packages="gazebo libgazebo-dev"
else
# default and Ubuntu 20.04
gazebo_version=11
gazebo_packages="gazebo$gazebo_version libgazebo$gazebo_version-dev"
fi
echo " * Gazebo Classic (Version 11)"
echo $VERBOSE_BAR
install_gazebo_common
# Installing Gazebo and dependencies
# Setup OSRF Gazebo repository
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
# Update list, since new gazebo-stable.list has been added # Update list, since new gazebo-stable.list has been added
sudo apt-get update -y --quiet sudo apt-get update -y --quiet
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
dmidecode \ dmidecode \
$gazebo_packages \ gazebo libgazebo-dev \
gstreamer1.0-plugins-bad \ gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \ gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \ gstreamer1.0-plugins-good \
@@ -257,7 +292,51 @@ if [[ $INSTALL_SIM == "true" ]]; then
fi fi
fi fi
if [[ $INSTALL_NUTTX == "true" ]]; then # Gazebo Ignition
if [[ $INSTALL_GAZEBO_IGNITION == "true" ]]; then
echo echo
echo "Relogin or reboot computer before attempting to build NuttX targets" echo $VERBOSE_BAR
echo "🍻 Installing Gazebo IGNITION"
echo
echo " * Gazebo Ignition (Version 6 / Fortress)"
echo $VERBOSE_BAR
# We have likely done the common pieces already earlier.
if [[ $INSTALL_GAZEBO_CLASSIC != "true" ]]; then
install_gazebo_common
fi
#
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
ignition-fortress \
;
fi fi
if [[ $INSIDE_DOCKER == "true" ]]; then
# cleanup installation
rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
fi
if [[ $INSIDE_DOCKER == "false" ]] && [[ $INSTALL_NUTTX == "true" ]]; then
echo
echo $VERBOSE_BAR
echo "💡 We recommend you relogin/reboot before attempting to upload NuttX targets"
echo " to be part of the dialout group to have access to serial ports."
echo $VERBOSE_BAR
echo
fi
echo
echo
echo $VERBOSE_BAR
echo "⚡️ PX4 Dependency Installer ended successfully
For more information on PX4 Autopilot check out our docs
at https://docs.px4.io.
If you find a bug please file an issue
on https://github.com/PX4/PX4-Autopilot"
echo $VERBOSE_BAR
echo