How to Create Debian Package for ROS 2?

Hi all,

Is there a way to build a private .deb release for ROS 2 project? Like calling $ colcon build but instead of generates a build directories, it generates a .deb package.
I’ve already search and found about bloom, buildfarm, jenkins etc. but i still have no idea on how to use those tools or whether those are the right tools to be used.

thanks

2 Likes

have you checked out this answer on ROS answers yet?

even though it’s for ROS 1…I think you should still be able to use the same approach for ROS2 since bloom is used for both.

2 Likes

You could also use cmake and then cpack to generate the .Deb.

https://cmake.org/cmake/help/latest/module/CPack.html

1 Like

Thanks all for the answer, i’m already be able to build the Debian package using the ROS answers that provided by @flynneva. I haven’t tried using CPack for ROS 2 project though, but as in this thread, i think it’s not recommended to used it in ROS 2 project.

Anyway in case you are wondering how to create a Debian package for ROS 2 project, i did it as follows:

  • Prepare bloom, rosdep, and fakeroot.
    $ sudo apt install python3-bloom python3-rosdep fakeroot
    
  • Initialize rosdep.
    $ sudo rosdep init
    $ rosdep update
    
  • cd to the package source (which contains package.xml).
    $ bloom-generate rosdebian
    $ fakeroot debian/rules binary
    
  • The build result then will be available in ../
5 Likes

@threeal This is super useful! Would you be willing to write a short Guide on GitHub - ros2/ros2_documentation: ROS 2 docs repository ?

1 Like

I ended up opening a PR with a short Guide: Add in a guide to making a custom debian package. by clalancette · Pull Request #1514 · ros2/ros2_documentation · GitHub

3 Likes

That’s a nice guide, haven’t seen one too in the ROS documentation. Actually i’m already planned to write it later, but i have been busy doing something else and don’t have time to write that yet.

1 Like

Love where this is headed, and great work on the documentation.

We build debians for our ROS packages for installation on field units (using a private apt server), and I’ve done it 3 ways:

  • using the bloom-generate rosdebian tool
  • manually creating the debian folder and appropriate files (using tools debuild and others)
  • using cpack

Each has pros/cons. cpack is pretty easy but not straightforward. Here’s an example of a library from a vendor we simply forked and added the cpack installation to create a debian.

Using the bloom as a template and then modifying is super useful, as it adds all the ROS niceities, but we ended up wanting to use more of the power of debian (installing other files, postinst setup, configuration, having an actual changelog, etc.) so we opted for setting up and checking in our own debian folder.

The downside is that you’ve got duplication of the dependencies in package.xml and debian/control. Here’s an example of a fork of the realsense-ros lib that has a debian control file for ros1 melodic package creation:

Our circleci uses this to build a debian and install it on our package server(s).

I would love to assist further in helping with the debian-ization in ROS. I’m torn between just using stock debian setup, and the bloom tooling. If I was a good true OSS zealot, I’d insist we just use stock debian tools, if I was a true ROS developer, I’d insist we keep improving bloom. I’m somewhere in between. :wink:

3 Likes

@clalancette Thanks for opening a PR!
There are some packages that contain private dependencies that cannot be installed with the rosdep install command. I think this information will be very useful.
ref: https://answers.ros.org/question/280213/generate-deb-from-dependent-res-package-locally/#280235

I wrote a script using bloom-generate last year, so this may be helpful.
It is not maintained for now…

I think I might be able to help.
What is the best way for you to help?

Hello everyone,

From a jazzy-desktop Docker container I built ROS 2 from source with the intention of generating the rclcpp Debian package.
I followed the steps from @threeal

cd src/ros2/rclcpp/rclcpp
bloom-generate rosdebian --os-name ubuntu --os-version noble --ros-distro jazzy
fakeroot debian/rules binary

It appears rclcpp is rebuilt again and this time I hit the following error

– Found rosidl_adapter: 4.6.4 (/opt/ros/jazzy/share/rosidl_adapter/cmake)
CMake Error at test/CMakeLists.txt:3 (find_package):
By not providing “Findtest_msgs.cmake” in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
“test_msgs”, but CMake did not find one.

Could not find a package configuration file provided by “test_msgs” with
any of the following names:

test_msgsConfig.cmake
test_msgs-config.cmake

Add the installation prefix of “test_msgs” to CMAKE_PREFIX_PATH or set
“test_msgs_DIR” to a directory containing one of the above files. If
“test_msgs” provides a separate development package or SDK, be sure it has
been installed.

Then I started to go down a dependency rabbit hole.
Is there an update to this recipe?

UPDATE:
I got it to work!
The issue was that I wasn’t source the install/setup.bash script before running bloom-generate and fakeroot.

We’re also doing a similar thing, and running into the same issue with duplication of dependencies. In our case we use a .yaml file as a template for the debian, which includes a build_depends and run_depends section.

It’d be nice to automate this, although I’ve found it difficult to do via parsing the packages.xml. Specifically, determining which are ros and which are non-ros, as the former are usually of the form ros-<version>-<package> and the latter of the form lib<package>-dev.

Being able to tag each dependency with a type (e.g. “ros”, “non-ros”) would be really helpful in this regard, though I’m unsure how useful it’d be for other tools which use the package.xml

Relevant to the discussion (?) are,

  • colcon-ros-buildfarm - WIP: Extensions for colcon to utilize ros_buildfarm to build system packages in containers. It was presented at ROSCon 2024 (video).
  • colcon-in-container - Colcon extension to build a colcon workspace in a container (see the release command). It was presented at ROSCon 2023 (video).