From ce550557b61d8fc444b41551fd229b5532460328 Mon Sep 17 00:00:00 2001 From: Sam Privett Date: Sun, 29 Jun 2025 12:11:40 -0700 Subject: [PATCH 1/4] Add rosidl_rust in an overlay sourced in the dev container via an entrypoint. Move any logic that will change between distros into shell scripts for more flexibility. --- Dockerfile | 13 +++++++++---- docker/install_colcon_plugins.sh | 8 ++++++++ docker/rosidl_rust_entrypoint.sh | 12 ++++++++++++ docker/rosidl_rust_setup.sh | 17 +++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100755 docker/install_colcon_plugins.sh create mode 100755 docker/rosidl_rust_entrypoint.sh create mode 100755 docker/rosidl_rust_setup.sh diff --git a/Dockerfile b/Dockerfile index bf470ef3c..07cb6970d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,10 +15,15 @@ RUN apt-get update && apt-get install -y \ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.75.0 -y ENV PATH=/root/.cargo/bin:$PATH -# Install the colcon-cargo and colcon-ros-cargo plugins -RUN if [ "$ROS_DISTRO" = "humble" ] ; \ - then pip install --upgrade pytest && pip install colcon-ros-cargo ; \ - else pip install --break-system-packages pytest colcon-ros-cargo ; fi +COPY src/ros2_rust/docker/install_colcon_plugins.sh / +RUN ./install_colcon_plugins.sh + +COPY src/ros2_rust/docker/rosidl_rust_setup.sh / +RUN ./rosidl_rust_setup.sh RUN mkdir -p /workspace && echo "Did you forget to mount the repository into the Docker container?" > /workspace/HELLO.txt WORKDIR /workspace + +COPY src/ros2_rust/docker/rosidl_rust_entrypoint.sh / +ENTRYPOINT ["/rosidl_rust_entrypoint.sh"] +CMD ["/bin/bash"] diff --git a/docker/install_colcon_plugins.sh b/docker/install_colcon_plugins.sh new file mode 100755 index 000000000..1bcb36ee6 --- /dev/null +++ b/docker/install_colcon_plugins.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ "$ROS_DISTRO" = "humble" ]; then + pip install --upgrade pytest + pip install colcon-ros-cargo +else + pip install --break-system-packages pytest colcon-ros-cargo +fi diff --git a/docker/rosidl_rust_entrypoint.sh b/docker/rosidl_rust_entrypoint.sh new file mode 100755 index 000000000..70a85a0ac --- /dev/null +++ b/docker/rosidl_rust_entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +# setup ros2 environment +source "/opt/ros/$ROS_DISTRO/setup.bash" -- + +# If we're a distro that needs the overlay built, then source it +if [ -f "/tmp/rosidl_rust_overlay/install/setup.bash" ]; then + source /tmp/rosidl_rust_overlay/install/setup.bash -- +fi + +exec "$@" diff --git a/docker/rosidl_rust_setup.sh b/docker/rosidl_rust_setup.sh new file mode 100755 index 000000000..c5b05092e --- /dev/null +++ b/docker/rosidl_rust_setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Depending on the ROS_DISTRO, make sure we've got rosidl_generator_rs +# sourced and available in working directory workspace + +if [ "$ROS_DISTRO" = "rolling" ]; then + apt-get update && apt-get install -y ros-$ROS_DISTRO-rosidl-generator-rs +else + # Temporarily add `rosidl_rust` to an overlay, build, and source it. + mkdir -p /tmp/rosidl_rust_overlay/src + git clone https://github.com/ros2-rust/rosidl_rust /tmp/rosidl_rust_overlay/src + + cd /tmp/rosidl_rust_overlay + + . /opt/ros/$ROS_DISTRO/setup.sh + colcon build +fi From 62abac36c60dd4af0ed505f35f3f6cda6ed4db09 Mon Sep 17 00:00:00 2001 From: Sam Privett Date: Sun, 3 Aug 2025 10:09:51 -0700 Subject: [PATCH 2/4] Install the latest colcon-cargo and colcon-ros-cargo --- docker/install_colcon_plugins.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docker/install_colcon_plugins.sh b/docker/install_colcon_plugins.sh index 1bcb36ee6..813a34f52 100755 --- a/docker/install_colcon_plugins.sh +++ b/docker/install_colcon_plugins.sh @@ -2,7 +2,11 @@ if [ "$ROS_DISTRO" = "humble" ]; then pip install --upgrade pytest - pip install colcon-ros-cargo + pip install \ + git+https://github.com/colcon/colcon-cargo.git \ + git+https://github.com/colcon/colcon-ros-cargo.git else - pip install --break-system-packages pytest colcon-ros-cargo + pip install --break-system-packages pytest \ + git+https://github.com/colcon/colcon-cargo.git \ + git+https://github.com/colcon/colcon-ros-cargo.git fi From 1fd5e45c07fc541055e5a73917c0f919a37f461c Mon Sep 17 00:00:00 2001 From: Sam Privett Date: Sun, 3 Aug 2025 10:27:33 -0700 Subject: [PATCH 3/4] trigger ci --- docker/install_colcon_plugins.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/install_colcon_plugins.sh b/docker/install_colcon_plugins.sh index 813a34f52..bc857f446 100755 --- a/docker/install_colcon_plugins.sh +++ b/docker/install_colcon_plugins.sh @@ -4,7 +4,7 @@ if [ "$ROS_DISTRO" = "humble" ]; then pip install --upgrade pytest pip install \ git+https://github.com/colcon/colcon-cargo.git \ - git+https://github.com/colcon/colcon-ros-cargo.git + git+https://github.com/colcon/colcon-ros-cargo.git else pip install --break-system-packages pytest \ git+https://github.com/colcon/colcon-cargo.git \ From faf29da01e8ab117f34c32dcb7dd20b49b5a92b1 Mon Sep 17 00:00:00 2001 From: Sam Privett Date: Sun, 3 Aug 2025 11:13:07 -0700 Subject: [PATCH 4/4] trigger ci --- docker/install_colcon_plugins.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/install_colcon_plugins.sh b/docker/install_colcon_plugins.sh index bc857f446..813a34f52 100755 --- a/docker/install_colcon_plugins.sh +++ b/docker/install_colcon_plugins.sh @@ -4,7 +4,7 @@ if [ "$ROS_DISTRO" = "humble" ]; then pip install --upgrade pytest pip install \ git+https://github.com/colcon/colcon-cargo.git \ - git+https://github.com/colcon/colcon-ros-cargo.git + git+https://github.com/colcon/colcon-ros-cargo.git else pip install --break-system-packages pytest \ git+https://github.com/colcon/colcon-cargo.git \