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 ../
3 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

2 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?