Skip to content

Commit 0d4d682

Browse files
Debian-docker: Use rosinstall_generator for dependency resolution (#685)
* Use rosinstall_generator for dependency resolution * Add badges for other platforms * Resort README * TMP: don't use cache * Fix paths * Revert "TMP: don't use cache" This reverts commit d48eb22. * Fix bash->sh script * Fix exclude path * Update comments * Exclude mujoco and gz * Fix "" * Exclude ign * Explicitely exclude ros_gz* * Don't build rviz2 * Only add deps to repos file * Only build pinocchio in the end * Don't build eigenpy (not needed by pinocchio with BUILD_PYTHON_INTERFACE=OFF * Skip gz_ros2_control_demos (implies gz_sim_vendor) * Don't build hpp-fcl * Remove release flag * Skip eigenpy and hpp-fcl already from rosinstall-generator * Skip the gz demos in the stack build
1 parent aad62f9 commit 0d4d682

4 files changed

Lines changed: 108 additions & 81 deletions

File tree

.github/workflows/build_and_publish_debian_docker.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
paths:
1414
- '.github/workflows/build_and_publish_debian_docker.yaml'
1515
- 'ros2_debian/**'
16+
- 'ros_controls.*.repos'
1617
schedule:
1718
- cron: '0 1 * * MON'
1819

@@ -33,16 +34,16 @@ jobs:
3334
include:
3435
- ros_distro: 'humble'
3536
debian_version: 'debian11'
36-
source_packages: filters xacro diagnostic_updater backward_ros generate_parameter_library angles ackermann_msgs pal_statistics topic_tools
37+
exclude_packages: ''
3738
- ros_distro: 'jazzy'
3839
debian_version: 'debian12'
39-
source_packages: filters xacro diagnostic_updater backward_ros generate_parameter_library angles ackermann_msgs sdformat_urdf pal_statistics pinocchio topic_tools
40+
exclude_packages: ''
4041
- ros_distro: 'kilted'
4142
debian_version: 'debian12'
42-
source_packages: filters xacro diagnostic_updater backward_ros generate_parameter_library angles ackermann_msgs sdformat_urdf pal_statistics pinocchio topic_tools
43+
exclude_packages: ''
4344
- ros_distro: 'rolling'
4445
debian_version: 'debian12'
45-
source_packages: filters xacro diagnostic_updater backward_ros generate_parameter_library angles ackermann_msgs sdformat_urdf pal_statistics pinocchio topic_tools
46+
exclude_packages: ''
4647

4748
steps:
4849
- uses: actions/checkout@v6
@@ -63,7 +64,7 @@ jobs:
6364
- name: Build and push image
6465
uses: docker/build-push-action@v6
6566
with:
66-
context: ros2_debian
67+
context: .
6768
push: true
6869
provenance: false
6970
sbom: false
@@ -77,7 +78,7 @@ jobs:
7778
cache-to: type=gha,scope=debian-${{ matrix.ros_distro }},mode=max
7879
build-args: |
7980
ROS_DISTRO=${{ matrix.ros_distro }}
80-
SOURCE_PACKAGES=${{ matrix.source_packages }}
81+
EXCLUDE_PACKAGES=gz_ros2_control gz_ros2_control_demos ign_ros2_control mujoco_ros2_control ros_gz_sim ros_gz_bridge rviz2 eigenpy hpp-fcl ${{ matrix.exclude_packages }}
8182
8283
stack-build:
8384
if: ${{ github.event_name == 'pull_request' }}

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ Within this repo the full ros2_control stack is built and tested once per day.
99

1010
## Released versions
1111

12-
[![Rolling Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rolling-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rolling-binary-build.yml)
13-
14-
[![Kilted Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/kilted-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/kilted-binary-build.yml)
15-
16-
[![Jazzy Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/jazzy-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/jazzy-binary-build.yml)
17-
18-
[![Humble Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/humble-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/humble-binary-build.yml)
12+
| Platform | Build status |
13+
| --- | --- |
14+
| Ubuntu | [![Rolling Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rolling-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rolling-binary-build.yml) [![Kilted Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/kilted-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/kilted-binary-build.yml) [![Jazzy Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/jazzy-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/jazzy-binary-build.yml) [![Humble Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/humble-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/humble-binary-build.yml) |
15+
| Debian | [![Debian Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/debian-stack-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/debian-stack-build.yml) |
16+
| RHEL | [![RHEL Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rhel-stack-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rhel-stack-build.yml) |
17+
| Windows | [![Windows Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/windows-stack-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/windows-stack-build.yml) |
1918

2019
## Compatibility versions
2120
We thrive to make the rolling development version of the ros2_control stack compatible with earlier releases of ROS 2. This is done by building the rolling version of the stack from source with the earlier releases of ROS 2.
@@ -26,15 +25,16 @@ We thrive to make the rolling development version of the ros2_control stack comp
2625

2726
[![Check Rolling Compatibility on Humble with Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rolling-compatibility-humble-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rolling-compatibility-humble-binary-build.yml)
2827

29-
## ros2_ubuntu
28+
## Docker images
29+
### ros2_ubuntu
3030
Extension of the [official OSRF docker images](https://github.com/osrf/docker_images), but with versions for `ros2`(main) and `ros2-testing` binaries.
3131

32-
## ros2_rhel
32+
### ros2_rhel
3333
This is a sample Dockerfile that show ros2 installed on almalinux based on the [binary installation instructions at docs.ros.org](https://docs.ros.org/en/rolling/Installation/RHEL-Install-RPMs.html). The most recent public build can be found with the docker tag: `ghcr.io/ros-controls/ros:<ROS_DISTRO>-rhel` where `<ROS_DISTRO>` is replaced with the ros distribution you are targeting.
3434

3535
The image tries to emulate the official ros2 images but on alma (downstream RHEL) linux. Therefore a few extra packages can be found within this repo that are not mentioned at the above link, i.e. colcon, etc.
3636

37-
## ros2_debian
37+
### ros2_debian
3838
Provides docker images for building ros2_control on debian.
3939

4040
Pull and run the images with:

ros2_debian/Dockerfile.debian11

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ FROM ${from}
44

55
ARG CMAKE_INSTALL_PREFIX=/usr/local
66
ARG NUM_THREADS=8
7+
ARG EXCLUDE_PACKAGES=""
78

89
# Avoid warnings by switching to noninteractive
910
ENV DEBIAN_FRONTEND=noninteractive
@@ -142,43 +143,58 @@ RUN \
142143
# ---- ROS ----
143144
# clone source, ROS core
144145
ENV ROS2_WS=/opt/ros2_ws
145-
ARG SOURCE_PACKAGES=""
146146
WORKDIR $ROS2_WS
147+
COPY ros_controls.*.repos /tmp/
147148
RUN \
148-
: "build ROS core from source" && \
149-
mkdir -p src/ros2 && \
150-
vcs import --input https://raw.githubusercontent.com/ros2/ros2/$ROS_DISTRO/ros2.repos src/ros2 && \
151-
if [ -n "$SOURCE_PACKAGES" ]; then \
152-
# get the release repos from gpb and its dependencies not included in ros2.repos
153-
for i in {1..5}; do \
154-
rosinstall_generator $SOURCE_PACKAGES --exclude-path src/ros2 --rosdistro $ROS_DISTRO --deps \
155-
> deps.repos && break || echo "retry #${i} .." && sleep 60; \
156-
done && \
157-
mkdir -p src/additional_pkgs && \
158-
vcs import src/additional_pkgs < deps.repos && \
159-
apt-get update -y -qq && \
160-
# install only dependencies for additional_pkgs, not for ros2.repos
161-
ROS_PACKAGE_PATH=$ROS2_WS rosdep install -iyr --from-path src/additional_pkgs || true ; \
149+
: "build dependencies for ros-controls stack from release repos" && \
150+
repo_file=/tmp/ros_controls.${ROS_DISTRO}.repos && \
151+
if [ ! -f "$repo_file" ]; then \
152+
echo "Missing repos file: $repo_file" >&2; \
153+
exit 1; \
162154
fi && \
163-
# build source, ROS core
155+
mkdir -p src/imported_pkgs && \
156+
vcs import src/imported_pkgs < "$repo_file" && \
157+
TARGET_PACKAGES=$(colcon list --base-paths src/imported_pkgs --names-only | tr '\n' ' ') && \
158+
if [ -z "$TARGET_PACKAGES" ]; then \
159+
echo "No packages found in imported repos" >&2; \
160+
exit 1; \
161+
fi && \
162+
EXCLUDE_ARGS="" && \
163+
if [ -n "$EXCLUDE_PACKAGES" ]; then \
164+
EXCLUDE_ARGS="--exclude $EXCLUDE_PACKAGES"; \
165+
fi && \
166+
success=0 && \
167+
for i in 1 2 3 4 5; do \
168+
if rosinstall_generator $TARGET_PACKAGES --rosdistro $ROS_DISTRO --deps --deps-only --format repos $EXCLUDE_ARGS > deps.repos; then \
169+
success=1; \
170+
break; \
171+
fi; \
172+
echo "retry #${i} .."; \
173+
sleep 60; \
174+
done && \
175+
if [ "$success" -ne 1 ] || [ ! -s deps.repos ]; then \
176+
echo "Failed to generate deps.repos" >&2; \
177+
exit 1; \
178+
fi && \
179+
rm -rf src/imported_pkgs && \
180+
mkdir -p src/generated && \
181+
vcs import src/generated < deps.repos && \
182+
apt-get update -y -qq && \
183+
ROS_PACKAGE_PATH=$ROS2_WS rosdep install -iyr --from-path src/generated || true && \
184+
# build generated stack
164185
colcon build \
165186
--mixin release build-testing-off \
166-
--cmake-args --no-warn-unused-cli \
167-
--packages-up-to robot_state_publisher tf2_ros tf2_eigen tf2_kdl tf2_eigen_kdl yaml_cpp_vendor filters \
168-
ros2param ros2interface ros2topic ros2action ros2lifecycle ros2launch ros2run ros_testing \
169-
xacro diagnostic_updater generate_parameter_library angles example_interfaces \
170-
backward_ros pal_statistics topic_tools \
171-
ackermann_msgs trajectory_msgs tf2_msgs tf2_geometry_msgs sensor_msgs geometry_msgs nav_msgs && \
172-
rm -rf log src build *.repos
187+
--cmake-args --no-warn-unused-cli && \
188+
rm -rf log src build *.repos /tmp/ros_controls.*.repos
173189

174190
# add default.yaml to the image
175-
COPY defaults.yaml /root/.colcon/defaults.yaml
191+
COPY ros2_debian/defaults.yaml /root/.colcon/defaults.yaml
176192

177193
# there is no python3-graphviz on debian11, so install it via pip
178194
RUN pip3 install --no-cache-dir graphviz
179195

180196
# Setup entrypoint (sourcing of ROS)
181-
COPY ./ros_entrypoint.sh /
197+
COPY ros2_debian/ros_entrypoint.sh /
182198
RUN chmod +x /ros_entrypoint.sh
183199
ENTRYPOINT [ "/ros_entrypoint.sh" ]
184200
CMD ["bash"]

ros2_debian/Dockerfile.debian12

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ${from}
33

44
ARG CMAKE_INSTALL_PREFIX=/usr/local
55
ARG NUM_THREADS=8
6+
ARG EXCLUDE_PACKAGES=""
67

78
# Avoid warnings by switching to noninteractive
89
ENV DEBIAN_FRONTEND=noninteractive
@@ -151,62 +152,71 @@ RUN \
151152
# clone source, ROS core
152153
ENV ROS2_WS=/opt/ros2_ws
153154
WORKDIR $ROS2_WS
154-
ARG SOURCE_PACKAGES=""
155+
COPY ros_controls.*.repos /tmp/
155156
RUN \
156-
: "build ROS core from source" && \
157+
: "build dependencies for ros-controls stack from release repos" && \
157158
. "$HOME/.cargo/env" && \
158-
mkdir -p src/ros2 && \
159-
vcs import --input https://raw.githubusercontent.com/ros2/ros2/$ROS_DISTRO/ros2.repos src/ros2 && \
160-
if [ -n "$SOURCE_PACKAGES" ]; then \
161-
# get the release repos from gpb and its dependencies not included in ros2.repos
162-
for i in {1..5}; do \
163-
rosinstall_generator $SOURCE_PACKAGES --exclude-path src/ros2 --rosdistro $ROS_DISTRO --deps \
164-
> deps.repos && break || echo "retry #${i} .." && sleep 60; \
165-
done && \
166-
mkdir -p src/additional_pkgs && \
167-
vcs import src/additional_pkgs < deps.repos && \
168-
apt-get update -y -qq && \
169-
# install only dependencies for additional_pkgs, not for ros2.repos
170-
ROS_PACKAGE_PATH=$ROS2_WS rosdep install -iyr --from-path src/additional_pkgs || true ; \
159+
repo_file=/tmp/ros_controls.${ROS_DISTRO}.repos && \
160+
if [ ! -f "$repo_file" ]; then \
161+
echo "Missing repos file: $repo_file" >&2; \
162+
exit 1; \
171163
fi && \
172-
if [ $ROS_DISTRO = "rolling" ]; then \
173-
apt-get update -y -qq && \
174-
# we don't want to install all system dependencies for ros2.repos
175-
# https://github.com/ros2/geometry2/pull/826
176-
# https://github.com/ros2/launch/pull/817
177-
apt-get -y install --no-install-recommends liborocos-kdl-dev liborocos-kdl1.5 python3-osrf-pycommon ;\
164+
mkdir -p src/imported_pkgs && \
165+
vcs import src/imported_pkgs < "$repo_file" && \
166+
TARGET_PACKAGES=$(colcon list --base-paths src/imported_pkgs --names-only | tr '\n' ' ') && \
167+
if [ -z "$TARGET_PACKAGES" ]; then \
168+
echo "No packages found in imported repos" >&2; \
169+
exit 1; \
178170
fi && \
179-
# build source, ROS core
180-
colcon build \
181-
--mixin release build-testing-off \
182-
--cmake-args --no-warn-unused-cli -DCMAKE_CXX_FLAGS="-Wno-maybe-uninitialized" \
183-
--packages-up-to robot_state_publisher tf2_ros tf2_eigen tf2_kdl tf2_eigen_kdl yaml_cpp_vendor filters \
184-
ros2param ros2interface ros2topic ros2action ros2lifecycle ros2launch ros2run ros_testing \
185-
xacro diagnostic_updater generate_parameter_library angles example_interfaces \
186-
backward_ros pal_statistics topic_tools ros_environment \
187-
ackermann_msgs trajectory_msgs tf2_msgs tf2_geometry_msgs sensor_msgs geometry_msgs nav_msgs \
188-
sdformat_urdf && \
189-
# build pinocchio from source with different cmake args
190-
. install/setup.sh && \
171+
EXCLUDE_ARGS="" && \
172+
if [ -n "$EXCLUDE_PACKAGES" ]; then \
173+
EXCLUDE_ARGS="--exclude $EXCLUDE_PACKAGES"; \
174+
fi && \
175+
success=0 && \
176+
for i in 1 2 3 4 5; do \
177+
if rosinstall_generator $TARGET_PACKAGES --rosdistro $ROS_DISTRO --deps --deps-only --format repos $EXCLUDE_ARGS > deps.repos; then \
178+
success=1; \
179+
break; \
180+
fi; \
181+
echo "retry #${i} .."; \
182+
sleep 60; \
183+
done && \
184+
if [ "$success" -ne 1 ] || [ ! -s deps.repos ]; then \
185+
echo "Failed to generate deps.repos" >&2; \
186+
exit 1; \
187+
fi && \
188+
rm -rf src/imported_pkgs && \
189+
mkdir -p src/generated && \
190+
vcs import src/generated < deps.repos && \
191+
apt-get update -y -qq && \
192+
ROS_PACKAGE_PATH=$ROS2_WS rosdep install -iyr --from-path src/generated || true && \
193+
# build generated stack, then build pinocchio with special flags when package is present
191194
colcon build \
192-
--mixin release build-testing-off \
193-
--cmake-args --no-warn-unused-cli -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON_INTERFACE=OFF \
194-
-DBUILD_WITH_COLLISION_SUPPORT=OFF -DBUILD_WITH_HPP_FCL_SUPPORT=OFF \
195-
--base-path src/additional_pkgs --packages-up-to pinocchio && \
195+
--mixin build-testing-off \
196+
--cmake-args --no-warn-unused-cli -DCMAKE_CXX_FLAGS="-Wno-maybe-uninitialized" \
197+
--packages-skip pinocchio && \
198+
if colcon list --base-paths src/generated --names-only | grep -qx pinocchio; then \
199+
. install/setup.sh && \
200+
colcon build \
201+
--cmake-args --no-warn-unused-cli -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON_INTERFACE=OFF \
202+
-DBUILD_WITH_COLLISION_SUPPORT=OFF -DBUILD_WITH_HPP_FCL_SUPPORT=OFF \
203+
--continue-on-error \
204+
--packages-select pinocchio; \
205+
fi && \
196206
# cleanup
197-
rm -rf log src build *.repos \
207+
rm -rf log src build *.repos /tmp/ros_controls.*.repos \
198208
&& \
199209
: "remove cache" && \
200210
rm -rf /var/lib/apt/lists/*
201211

202212
# add default.yaml to the image
203-
COPY defaults.yaml /root/.colcon/defaults.yaml
213+
COPY ros2_debian/defaults.yaml /root/.colcon/defaults.yaml
204214

205215
# there is no python3-graphviz on debian12, so install it via pip
206216
RUN pip3 install --no-cache-dir graphviz --break-system-packages
207217

208218
# Setup entrypoint (sourcing of ROS)
209-
COPY ./ros_entrypoint.sh /
219+
COPY ros2_debian/ros_entrypoint.sh /
210220
RUN chmod +x /ros_entrypoint.sh
211221
ENTRYPOINT [ "/ros_entrypoint.sh" ]
212222
CMD ["bash"]

0 commit comments

Comments
 (0)