Skip to content

Instantly share code, notes, and snippets.

@awesomebytes
Last active September 18, 2024 08:29
Show Gist options
  • Save awesomebytes/196eab972a94dd8fcdd69adfe3bd1152 to your computer and use it in GitHub Desktop.
Save awesomebytes/196eab972a94dd8fcdd69adfe3bd1152 to your computer and use it in GitHub Desktop.
How to create a debian from a ROS package

How to make a debian from a ROS package

The instructions are based on this answers.ros.org thread.

Get dependencies

You may need the latest pip, follow the official instructions.

Install bloom:

sudo apt-get install python-bloom

or (recommended)

sudo pip install -U bloom

Install fakeroot:

sudo apt-get install fakeroot

Get ready

To make a debian folder structure from the ROS package you must cd into the package to be in the same folder where package.xml file is.

Create debian structure

bloom-generate rosdebian --os-name ubuntu --os-version trusty --ros-distro indigo

You can also let the tool guess some stuff:

bloom-generate rosdebian --ros-distro indigo

You'll get something like this:

~/audio_ws/src/audio_file_player$ bloom-generate rosdebian --os-name ubuntu --os-version trusty --ros-distro indigo
==> Generating debs for ubuntu:trusty for package(s) ['audio_file_player']
No homepage set, defaulting to ''
No historical releaser history, using current maintainer name and email for each versioned changelog entry.
No CHANGELOG.rst found for package 'audio_file_player'
Package 'audio-file-player' has dependencies:
Run Dependencies:
  rosdep key           => trusty key
  rospy                => ['ros-indigo-rospy']
  actionlib_msgs       => ['ros-indigo-actionlib-msgs']
Build and Build Tool Dependencies:
  rosdep key           => trusty key
  rospy                => ['ros-indigo-rospy']
  actionlib_msgs       => ['ros-indigo-actionlib-msgs']
  catkin               => ['ros-indigo-catkin']
==> Placing templates files in the 'debian' folder.
==> In place processing templates in 'debian' folder.
Expanding 'debian/control.em' -> 'debian/control'
Expanding 'debian/changelog.em' -> 'debian/changelog'
Expanding 'debian/compat.em' -> 'debian/compat'
Expanding 'debian/rules.em' -> 'debian/rules'
~/audio_ws/src/audio_file_player$ ls
action  assets  CMakeLists.txt  debian  launch  package.xml  README.md  scripts 
~/audio_ws/src/audio_file_player$ ls debian
changelog  compat  control  rules  source

Create binary debian

Having sourced the necessary dependencies (most probably source /opt/ros/indigo/setup.bash) execute:

fakeroot debian/rules binary

If you get the error:

dh: Command not found

You need to install:

sudo apt-get install dpkg-dev debhelper

In the end you'll get a line like:

dpkg-deb: building package `ros-indigo-audio-file-player' in `../ros-indigo-audio-file-player_0.0.1-0trusty_amd64.deb'.
@FabianSchurig
Copy link

Thanks 👍 Works without any problems!

@awesomebytes
Copy link
Author

Other interesting related bits:

@devenpatel2
Copy link

How does one add the custom packages listed in package.xml? Suppose I have two packages - node_a and node_b . I want to create a debian package of 'node_b'., However, this package has a dependency on 'node_a', which is stated in the package.xml of node_b . When i face this scenario, bloom throws an error saying

Could not resolve rosdep key 'node_a''
Try to resolve the problem with 'node_a' and then continue.

@FabianSchurig
Copy link

You may create a file:
/etc/ros/rosdep/sources.list.d/50-my-packages.list containing the path to a rosdep.

yaml file:///home/<user>/rosdep.yaml

The rosdep.yaml contains sth. to resolve your package (which is already installed locally):

package_a:
  ubuntu: [ros-noetic-package-a]

Then you can build the debian for package_b with the same steps as above.

@devenpatel2
Copy link

Thank you @Bitfroest for the solution. This works perfectly. I had to setup a dependecy yaml which contained the deps mentioned in package.xml and point that yaml in the sourced.list.d

I was hoping that the dependencies mentioned in package.xml should be enough to resolve this, but it seems that we still have to manually setup another dependency list, which seems a bit redundant.

@AnushaPulichintha
Copy link

Hi, Thanks for the solution. This works perfectly for debian package creation. I have problems running installed ros nodes? Did anybody can run/launch the nodes?

Thanks in advance.

@devenpatel2
Copy link

I was able to launch the files that were part of the ROS package that was packaged and installed from a deb file. I should let you know that i am using ROS2 - dashing for this task.

@hsd-dev
Copy link

hsd-dev commented Mar 10, 2021

I am trying to create deb for moveit2. This is my rosdep.yaml:

moveit_planners:
  ubuntu: [ros-foxy-moveit-planners]
moveit_plugins:
  ubuntu: [ros-foxy-moveit-plugins]
moveit_ros:
  ubuntu: [ros-foxy-moveit-ros]
moveit_core:
  ubuntu: [ros-foxy-moveit-core]
moveit_ros:
  ubuntu: [ros-foxy-moveit-ros]

After running the above process, I get:

dpkg-deb: building package 'ros-foxy-moveit' in '../ros-foxy-moveit_2.1.0-0focal_amd64.deb'.

But trying to install the deb gives me the error:

dpkg-deb: building package 'ros-foxy-moveit' in '../ros-foxy-moveit_2.1.0-0focal_amd64.deb'.

$ sudo dpkg -i ros-foxy-moveit_2.1.0-0focal_amd64.deb

(Reading database ... 592421 files and directories currently installed.)
Preparing to unpack ros-foxy-moveit_2.1.0-0focal_amd64.deb ...
Unpacking ros-foxy-moveit (2.1.0-0focal) over (2.1.0-0focal) ...
dpkg: dependency problems prevent configuration of ros-foxy-moveit:
 ros-foxy-moveit depends on ros-foxy-moveit-core; however:
  Package ros-foxy-moveit-core is not installed.
 ros-foxy-moveit depends on ros-foxy-moveit-planners; however:
  Package ros-foxy-moveit-planners is not configured yet.
 ros-foxy-moveit depends on ros-foxy-moveit-plugins; however:
  Package ros-foxy-moveit-plugins is not installed.
 ros-foxy-moveit depends on ros-foxy-moveit-ros; however:
  Package ros-foxy-moveit-ros is not installed.

dpkg: error processing package ros-foxy-moveit (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 ros-foxy-moveit

@hsd-dev
Copy link

hsd-dev commented Mar 10, 2021

OK I started creating debs for ros-foxy-moveit-planners, but I get the error:

dpkg-shlibdeps: error: no dependency information found for /home/user/moveit2_ws/install/moveit_core/lib/libmoveit_planning_interface.so.2.0.0 (used by debian/ros-foxy-moveit-planners-ompl/opt/ros/foxy/lib/libmoveit_ompl_planner_plugin.so.)
Hint: check if the library actually comes from a package.
dh_shlibdeps: error: dpkg-shlibdeps -Tdebian/ros-foxy-moveit-planners-ompl.substvars -l/home/user/moveit2_ws/src/moveit2/moveit_planners/ompl/debian/ros-foxy-moveit-planners-ompl//opt/ros/foxy/lib/ debian/ros-foxy-moveit-planners-ompl/opt/ros/foxy/lib/moveit_planners_ompl/generate_state_database debian/ros-foxy-moveit-planners-ompl/opt/ros/foxy/lib/libmoveit_ompl_planner_plugin.so. debian/ros-foxy-moveit-planners-ompl/opt/ros/foxy/lib/libmoveit_ompl_interface.so. returned exit code 255
dh_shlibdeps: error: Aborting due to earlier error
make[1]: *** [debian/rules:53: override_dh_shlibdeps] Error 2
make[1]: Leaving directory '/home/user/moveit2_ws/src/moveit2/moveit_planners/ompl'
make: *** [debian/rules:22: binary] Error 2

@devenpatel2
Copy link

The first one looks like you had a dependency issue. You should be installing the packages in order of dependencies. i.e
if package-a.deb is dependent on package-b.deb, you'll have to install package-b.deb first

the second one looks like a building error. However i am not sure, since there is a CI failed indicator for the ompl directory for the last commit.

@hsd-dev
Copy link

hsd-dev commented Mar 10, 2021

yes I think the problem was because it was linking to the libs found in install workspace. Once I install the dependency deb, then it works well. Thanks!

@DarkCowMoo
Copy link

Hi @awesomebytes,
Thanks for sharing this information.
I had been wondering about building a ROS package using debuild and reached your guide.
The problem I seem to be facing is that the tools only allows a single package to be built at a time which limits packaging my project.
I tried create my own debian/rules file by overwriting the debian build system to use to colcon build. This, unfortunately did not work.
Using your guide, I was able to generate a rules file which shows the following.

%:
dh $@ -v --buildsystem=cmake --builddirectory=.obj-$(DEB_HOST_GNU_TYPE)

I, however, would like to use something similiar to

%:
dh $@ --buildsystem=colcon

override_dh_auto_build:
dh_auto_build -- colcon build --packages-up-to my_package.

Do you perhaps know if such modification is possible?

Thanks!

@awesomebytes
Copy link
Author

Hello @DarkCowMoo , I'm not familiar with this anymore, so I can't offer much help, sorry.

My first guess would be to:

The problem I seem to be facing is that the tools only allows a single package to be built at a time which limits packaging my project.
Figure out the order of dependencies of your packages and build them in order.

I, however, would like to use something similiar to
You could maybe just replace the rules that you don't like with your own after an initial generation?

@DarkCowMoo
Copy link

Hello @DarkCowMoo , I'm not familiar with this anymore, so I can't offer much help, sorry.

My first guess would be to:

The problem I seem to be facing is that the tools only allows a single package to be built at a time which limits packaging my project.
Figure out the order of dependencies of your packages and build them in order.

I, however, would like to use something similiar to
You could maybe just replace the rules that you don't like with your own after an initial generation?

Thanks for the quick replay.
I would like to use colcon as I find it the most convenient way to handle ROS, especially the ones who have multiple custom dependencies.
If I find a solution, I'll update this thread. Otherwise, would probably have to start working with your method.
Thanks again.

@mjm522
Copy link

mjm522 commented Jul 14, 2023

This is an old post, yet I am trying my luck to get a reply. I made my debians and facing exact problem @ipa-hsd faced here. But in my case the dependency libraries are not debians. They exist in the install folder of the workspace. This workspace is part of a docker image (meaning it is always present there). I want my package to be a debian that can be installed on to this docker image. While instaling it, I want it to pick up libraries from the install folder (it is sourced and all, can see it in the LD_LIBRARY_PATH), but my dpkg -i my_package.deb fails to pick them up. Can anything be done for this?

@pulak-gautam
Copy link

@DarkCowMoo Were you able to find a workaround to your problem? I am currently stuck in the same boat.

@Hawxxer
Copy link

Hawxxer commented Sep 18, 2024

Even if this thread is old, it's the pretty much the only full explanation how this works, when you try to google this issue. As so I want to add some information about issues I stumbled. To compile python ros2 packages you need to install the dh-python package.
apt install dh-python
Also I had dependency issues with my own rosdep.yaml file. The issue was, that my package name has a "_", which need to be written with "-" in the yaml to probably work, even if the package name keep the underscore. For example package name is ros_testpackage, the the rosdep.yaml need to contain

ros_testpackage:
  ubuntu: [ros-humble-ros-testpackage]

Thanks to vunguyen for pointing this out here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment