Is it possible to run code during the `build sourcedeb` step?

I am dealing with a packaging problem in the foxglove_msgs package, where custom message types are missing from the final deb, although they work when I build locally. I suspect the issue may be that the .msg files are copied during the build step:

These files are coming from a parent directory. If the debian source package does not include the parent directory, then when the build runs from the source package, the files would not be present.

Is it possible to run this code (or another script) during the “build sourcedeb” step so that I can ensure the necessary files are included in the source package?

So to your question there are ways to invoke processes at that stage.

However they will not solve your problem. Bloom will already have isolated the package source directory (example foxglove_msgs for Jammy on Foxy which is what is checked out for the sourcedeb build) and at any stage on the buildfarm you will be running in an anonymous isolated directory with only the resources available in the checkout.

It looks like you’re generating the msg files and committing them into the repository. As such I’d suggest just committing them into the package such that they’re available to build the package instead of having the package reach out and attempt to pull in content from outside of itself.

In general ROS source packages should expect to be relocatable and be checked out into anyone’s workspace with the deployers choice of peers including fully isolated. (subject to appropriate dependencies on the system etc.) As such a well formed package can’t rely on any parent or peer directories existing. The current approach will only work if a developer directly checks out your github repository, and will break if using the release tarballs and other mechanisms like the binary builds that you’ve pointed to above.

Thanks, I came to this same realization shortly after writing the post. Here is my fix: Fix ROS packaging again by jtbandes · Pull Request #40 · foxglove/schemas · GitHub

Just to reiterate what @tfoote said as a general rule (for anyone else reading this):

Packages should never reference files outside of the package’s source directory (directory containing the package.xml) relatively.
Instead they should only ever reference files from other packages through the install space, even if they’re in the same repository.

The ament_index exists, in part, to facilitate this.

You cannot assume that your package is built in the original source layout of your repository (only the layout of the package directory is guaranteed not to change), nor that it is in the same workspace as any other package, nor that it is installed to the same place as any other packages.

Hopefully that makes sense, it’s a nuanced issue.