Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup: fixes ubuntu 22.04 & 24.04 #23745

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/test_setup_tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# NOTE: this workflow is now running on Dronecode / PX4 AWS account.
# - If you want to keep the tests running in GitHub Actions you need to uncomment the "runs-on: ubuntu-latest" lines
# and comment the "runs-on: [runs-on,runner=..." lines.
# - If you would like to duplicate this setup try setting up "RunsOn" on your own AWS account try https://runs-on.com

name: Setup Tools Test (Ubuntu)

on:
push:
branches:
- 'main'
- 'stable'
- 'beta'
- 'release/*'
pull_request:
branches:
- '*'

jobs:
ubuntu-run:
strategy:
fail-fast: false
matrix:
version: [22, 24]
# runs-on: ubuntu-latest
runs-on: [runs-on,runner=8cpu-linux-x64,"image=ubuntu${{ matrix.version }}-full-x64","run-id=${{ github.run_id }}"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# - name: ownership workaround
# run: git config --system --add safe.directory '*'

Copy link

@TannerGilbert TannerGilbert Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following step seems to fix the the failing builds.

Suggested change
- name: Install pre-requisites
run: |
# Install ZeroMQ library
sudo apt-get update -y
sudo apt-get install -y libzmq3-dev libunwind-dev
# Clone and install cppzmq
git clone https://github.com/zeromq/cppzmq.git
cd cppzmq
mkdir build
cd build
cmake ..
sudo make install
cd ../..

Installing libunwind-dev seems to be required for both Ubuntu 22.04 and Ubuntu 24.04 but the zmq and cppzmq install seems to me to be only needed for Ubuntu 24.04. Unfortunately I didn't find out where ZMQ is actually used as I didn't find it directly in the PX4 code and I'm therefore unsure whether it makes sense to also include the ZMQ install in the ubuntu.sh script of if it's better to add it to the pipeline and then for example add an additional note in the documentation.

Successful pipeline run: https://github.com/TannerGilbert/PX4-Autopilot/actions/runs/11123812177/job/30908037123

Regardless I hope this is useful in some way.

Best regards,
Gilbert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @TannerGilbert. I also couldn't track down where we use ZeroMQ; perhaps @dagar can help here.

Either way, instead of fixing it for CI, I added the dependencies to the Ubuntu.sh install script since our users will be running into these problems when they upgrade to 22.04 and 24.04

- name: Install Dependencies
run: |
./Tools/setup/ubuntu.sh

- name: Make Default Build
run: |
make px4_sitl_default
78 changes: 50 additions & 28 deletions Tools/setup/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

## Bash script to setup PX4 development environment on Ubuntu LTS (22.04, 20.04, 18.04).
## Bash script to setup PX4 development environment on Ubuntu LTS (24.04, 22.04, 20.04, 18.04).
## Can also be used in docker.
##
## Installs:
Expand Down Expand Up @@ -49,28 +49,17 @@ if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
return 1
fi


# check ubuntu version
# otherwise warn and point to docker?
UBUNTU_RELEASE="`lsb_release -rs`"

if [[ "${UBUNTU_RELEASE}" == "14.04" ]]; then
echo "Ubuntu 14.04 is no longer supported"
exit 1
elif [[ "${UBUNTU_RELEASE}" == "16.04" ]]; then
echo "Ubuntu 16.04 is no longer supported"
UBUNTU_RELEASE="$(lsb_release -rs)"
SUPPORTED_UBUNTU_VERSIONS=("18.04" "20.04" "22.04" "24.04")
if [[ ! " ${SUPPORTED_UBUNTU_VERSIONS[*]} " =~ ${UBUNTU_RELEASE} ]]; then
echo "Unsupported Ubuntu version: ${UBUNTU_RELEASE}"
exit 1
elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
echo "Ubuntu 18.04"
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
echo "Ubuntu 20.04"
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
echo "Ubuntu 22.04"
elif [[ "${UBUNTU_RELEASE}" == "21.3" ]]; then
echo "Linux Mint 21.3"
else
echo "Ubuntu ${UBUNTU_RELEASE}"
fi


echo
echo "Installing PX4 general dependencies"

Expand Down Expand Up @@ -105,12 +94,17 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i
# Python3 dependencies
echo
echo "Installing PX4 Python3 dependencies"
if [ -n "$VIRTUAL_ENV" ]; then
# virtual environments don't allow --user option
python -m pip install -r ${DIR}/requirements.txt
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
REQUIRED_VERSION="3.11"
if [[ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" == "$REQUIRED_VERSION" ]]; then
python3 -m pip install --break-system-packages -r ${DIR}/requirements.txt
else
# older versions of Ubuntu require --user option
python3 -m pip install --user -r ${DIR}/requirements.txt
if [ -n "$VIRTUAL_ENV" ]; then
# virtual environments don't allow --user option
python -m pip install -r ${DIR}/requirements.txt
else
python3 -m pip install --user -r ${DIR}/requirements.txt
fi
fi

# NuttX toolchain (arm-none-eabi-gcc)
Expand All @@ -137,9 +131,6 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
libisl-dev \
libmpc-dev \
libmpfr-dev \
libncurses5 \
libncurses5-dev \
libncursesw5-dev \
libtool \
pkg-config \
screen \
Expand All @@ -153,7 +144,36 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
kconfig-frontends \
;
fi

if [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
libunwind-dev \
;
fi
if [[ "${UBUNTU_RELEASE}" == "24.04" ]]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
kconfig-frontends \
libncurses6 \
libncurses-dev \
libncursesw6 \
libzmq3-dev \
libunwind-dev \
;

# Ubuntu 24.04 requires ZeroMQ
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for what?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea. I couldn't trace it either. Maybe dependency inception? if you have a few minutes it would be ideal to check

git clone https://github.com/zeromq/cppzmq.git
cd cppzmq
mkdir build
cd build
cmake ..
sudo make install
cd ../..
else
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
libncurses5 \
libncurses5-dev \
libncursesw5-dev \
;
fi

if [ -n "$USER" ]; then
# add user to dialout group (serial port access)
Expand Down Expand Up @@ -209,6 +229,8 @@ if [[ $INSTALL_SIM == "true" ]]; then
java_version=11
elif [[ "${UBUNTU_RELEASE}" == "21.3" ]]; then
java_version=11
elif [[ "${UBUNTU_RELEASE}" == "24.04" ]]; then
java_version=11
else
java_version=14
fi
Expand All @@ -224,7 +246,7 @@ if [[ $INSTALL_SIM == "true" ]]; then
sudo update-alternatives --set java $(update-alternatives --list java | grep "java-$java_version")

# Gazebo / Gazebo classic installation
if [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
if [[ "${UBUNTU_RELEASE}" == "22.04" || "${UBUNTU_RELEASE}" == "24.04" ]]; then
echo "Gazebo (Harmonic) will be installed"
echo "Earlier versions will be removed"
# Add Gazebo binary repository
Expand Down
Loading