Robotics StackExchange | Archived questions

Compile ROS2 foxy binaries for other linux distro

I am currently working on a robot project where we are using Debian Buster for an industrial application. Debian is simply more reliable and future-proof than Ubuntu, that is the simple reason we are using Debian.

Since ROS2 Foxy is mainly supported on Ubuntu, I am having a hard time compiling binaries (.deb) for Debian. Building binaries for Ubuntu works fine with bloom-generate and dpkg-buildpackage, but this is not possible for the Debian distro because no Debian apt repositority for ROS2 Foxy exists.

Therefore I want to compile ROS2 Foxy myself for Debian Buster, but I am struggling really hard with it. Everything is dependend on each other, some things won't build, some things don't really work when installed, the ros/opt/foxy/setup.sh is not installed by any binary. In short, horrible experience trying it, but still trying. I don't know how I should tackle this.

I made a script my self which finds every folder with package.xml and than goes to that folder and executes bloom-generate and dpkg-buildpackage and than installing the package after. This works well, but after a while of repeatedly doing this, you start to bump into python packages not being sourced, because the lack of setup.sh. (I think)

I'm wondering if some kind of build script exist, which I can use for building ROS2 Foxy for Debian Buster, which also makes the ros-foxy-desktop or ros-foxy-ros-base package.

Asked by xander-m2k on 2021-11-09 07:50:02 UTC

Comments

Out of the problems you've faced, are you also getting rosdep unresolved dependency errors? For that specific issue, you can probably create a rosdep config file listing the dependencies (even custom packages) for the packages you're building.

https://gist.github.com/awesomebytes/196eab972a94dd8fcdd69adfe3bd1152#gistcomment-3649670

Asked by aprotyas on 2021-11-09 11:36:38 UTC

@aprotyas I have passed that station a while ago... :)

Asked by xander-m2k on 2021-11-09 11:38:31 UTC

Oops - best of luck regardless!

Asked by aprotyas on 2021-11-09 11:48:53 UTC

Perhaps you could take a look at meta-ros. Doing this yourself without the help of some system which takes care of build-ordering and dependency checking for you seems like it shouldn't be necessary.

Note: this is not "some kind of build script" which builds .debs for you. It's a different approach. But in an industrial context, building a complete rootfs may actually be a more viable approach.

Asked by gvdhoorn on 2021-11-09 13:18:11 UTC

@gvdhoorn, correct me if I'm wrong, but I think this repository is more focused on cross-compiling on Yocto (mostly arm64/aarch64), rather than focusing on compiling for another Linux distro. Also, I do actually need the ROS2 Foxy for Buster .debs for compiling my own ROS2 packages for Debian Buster, otherwise dpkg-buildpackage can't find the dependencies.

Asked by xander-m2k on 2021-11-09 13:37:44 UTC

Yocto can certainly be used to build images for non-amd64 architectures, but it's also used for regular Intel/AMD/other-x86 platforms. There's nothing in there specific for cross-compilation.

I do actually need the ROS2 Foxy for Buster .debs for compiling my own ROS2 packages for Debian Buster, otherwise dpkg-buildpackage can't find the dependencies.

As I wrote, this is an entirely different approach. dpkg-buildpackage is not involved (or at least not in the way you're using it now).

Asked by gvdhoorn on 2021-11-09 13:40:06 UTC

@gvdhoorn, thanks for informing me. I will take a look at it and see if it's useful! Still needs the .debs though... For now, I will just build manually, which can be a pain, but I will get there. A big reason for the .debs is also to deploy it in a docker container for releasing my packages, which can just be easily updated and made with existing binaries.

Asked by xander-m2k on 2021-11-09 13:47:50 UTC

Answers

Some suggestions:

1. Study Archlinux PKGBUILDS:

Archlinux lacks ROS2 binaries, so the Arch community created "PKGBUILDS" which are basically shell scripts that build ROS2 from scratch. They are pretty simple and you can easily figure out how they work. See this for foxy package itself and this for external dependencies.

2. Study Ubuntu packages:

This file contains the official packages and provides a list of their ROS and non-ROS dependencies (search for ros2-foxy-desktop for example). However, I couldn't find build instructions of the packages themselves. Studying their CI infrastructure might help but I'm not sure.

Asked by m2-farzan on 2021-11-09 18:41:08 UTC

Comments

Nice answer.

Asked by osilva on 2021-11-09 19:29:29 UTC

The thing is that PKGBUILDS - or in fact, most of the suggestions provided to @xander-m2k so far - builds from source and that's it. He needs some way to create debians after-the-fact.

Asked by aprotyas on 2021-11-10 00:06:17 UTC

I found the ros_buildfarm repository (https://github.com/ros-infrastructure/ros_buildfarm) and I think this might be able to do it. I'm going to put some time in it and see if I get it to do what I want it to do.

Asked by xander-m2k on 2021-11-10 02:31:53 UTC

@m2-farzan Nice find, but this PKGBUILD script just uses colcon as well, nothing special here...
Also, I have just emailed the ros2-foxy-desktop package maintainer, if he could provide the source, so thanks for that.

The CI infrastructure comment you mention is basicly what I am trying to do on a local level, but it is not supported for Debian builds. In short, it's a real pain to set up all the different config files, which are not fully documented.

Asked by xander-m2k on 2021-11-10 10:41:50 UTC

@xander-m2k Sorry, maybe I didn't fully understand the problem. Are you trying to avoid colcon for some reason or you're saying that you already use colcon but the problem is that you don't know which packages to clone before running colcon build? If it is the latter, did you notice the step in PKGBUILD in which it uses a file named ros2.repos to find all the required packages? For a quick glance, see that file online here.

Asked by m2-farzan on 2021-11-10 13:17:44 UTC

I'm not trying to avoid colcon. colcon just does not provide the functionality of building binaries (.debs). It only compiles your project but does not package it. It would be perfect is colcon would have that kind of functionality.

Asked by xander-m2k on 2021-11-10 13:20:15 UTC

Based on what that PKGBUILD does (package() function in the bottom), can't you just make a debian package that contains everything in the install directory that colcon build generates, and copies them to /opt/ros2/foxy directory of target system? Do you have technical problems with creating a debian package that copies some files to a directory or you can do that but you get errors?

Asked by m2-farzan on 2021-11-10 13:31:28 UTC