Skip to content

Add Debian template for 'cargo' build type - #774

Merged
cottsay merged 10 commits into
ros-infrastructure:masterfrom
Blast545:blast545/cargo_debian_template
Jul 23, 2026
Merged

cottsay merged 10 commits into
ros-infrastructure:masterfrom
Blast545:blast545/cargo_debian_template

Conversation

@Blast545

@Blast545 Blast545 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Adds a Debian/Ubuntu packaging template for the cargo build_type, mirroring the scope of #763 (RPM cargo template).

  • Embeds a dependency SBOM in shipped binaries via cargo auditable (compressed JSON in a .dep-v0 ELF section)
  • v1 lets cargo fetch from crates.io at build time.

Comment thread bloom/generators/debian/templates/cargo/rules.em
@codecov-commenter

codecov-commenter commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@e8f9f9e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
bloom/generators/debian/generator.py 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #774   +/-   ##
=========================================
  Coverage          ?   52.31%           
=========================================
  Files             ?       57           
  Lines             ?     6960           
  Branches          ?     1202           
=========================================
  Hits              ?     3641           
  Misses            ?     2974           
  Partials          ?      345           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Blast545
Blast545 force-pushed the blast545/cargo_debian_template branch from d6f4f07 to ac4dc6f Compare May 5, 2026 18:37
@Blast545
Blast545 changed the base branch from master to cottsay/cargo May 5, 2026 18:38
Comment thread bloom/generators/debian/templates/cargo/control.em Outdated
Comment thread bloom/generators/debian/templates/cargo/rules.em
Comment thread bloom/generators/debian/templates/cargo/control.em
Comment thread bloom/generators/debian/generator.py Outdated
Comment thread bloom/generators/debian/templates/cargo/rules.em Outdated
if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi
cargo test || true

override_dh_auto_install:

@cottsay cottsay May 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By overriding dh-cargo's install we're missing out on this whole section, which is responsible for installing the unpacked crate to <prefix>/share/cargo/registry/

https://github.com/deepin-community/dh-cargo/blob/00d6ee3b093ef085d02302bc9fc1e4bdc821fc14/cargo.pm#L177-L186

(sorry I couldn't figure out how to link to dh-cargo's actual upstream source code, but this fork/mirror seems to work)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the output path is hard-coded in that snippet, so I wonder if the best thing to do is maybe to let the install happen to /usr/share/cargo/registry and then blindly move the results (if any) to @(InstallationPrefix)/share/cargo/registry.

@Blast545 Blast545 May 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's no simple way to rely on their code to do what they do with our custom naming/path needs, so I think we can just try to go on our own route. At least for the proof of concept

@Blast545

Copy link
Copy Markdown
Contributor Author

Do not review, iterating on this one. After I recalled that crates are separated debians/libs, see: https://github.com/deepin-community/dh-cargo/blob/00d6ee3b093ef085d02302bc9fc1e4bdc821fc14/cargo.pm#L177-L186, I created a more complete example for testing this PR and it's not completely working yet.

@Blast545

Copy link
Copy Markdown
Contributor Author

Ok, I tested this with: https://github.com/Blast545/testing_colcon_ros_buildfarm_cargo. There's a lot of llm generated doc, but the interesting parts of the setup that are worth checking:

Some dependencies we need in the buildfarm to build cargo stuff: https://github.com/Blast545/testing_colcon_ros_buildfarm_cargo/tree/main#patches-applied-to-the-venv-install
(Including how do we want to install pallet-patcher, which is not available via apt right now)

rosdistro/distribution.yaml: https://github.com/Blast545/testing_colcon_ros_buildfarm_cargo/blob/main/configs/rosdistro/rolling/distribution.yaml

The rust crates under the test:
https://github.com/Blast545/ros_rust_lib_demo/blob/main/package.xml
https://github.com/Blast545/ros_rust_app_demo/blob/main/package.xml

@Blast545
Blast545 marked this pull request as ready for review May 21, 2026 19:29
Comment on lines +84 to +85
HAS_LIB=$$(printf '%s' "$$META" | python3 -c "import sys,json;p=json.load(sys.stdin)['packages'][0];L={'lib','rlib','dylib','cdylib','staticlib','proc-macro'};print(int(any(k in L for t in p['targets'] for k in t['kind'])))") ; \
HAS_BIN=$$(printf '%s' "$$META" | python3 -c "import sys,json;p=json.load(sys.stdin)['packages'][0];print(int(any('bin' in t['kind'] for t in p['targets'])))") ; \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there's a simpler way to detect if a specific package has libraries or is it only binary.

@Blast545
Blast545 requested a review from cottsay May 21, 2026 20:00
@cottsay
cottsay deleted the branch ros-infrastructure:master July 23, 2026 16:47
@cottsay cottsay closed this Jul 23, 2026
@cottsay cottsay reopened this Jul 23, 2026
@cottsay
cottsay changed the base branch from cottsay/cargo to master July 23, 2026 16:49
Blast545 and others added 10 commits July 23, 2026 11:50
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Co-authored-by: Scott K Logan <logans@cottsay.net>
Co-authored-by: Scott K Logan <logans@cottsay.net>
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge J. Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge J. Perez <jjperez@ekumenlabs.com>
@cottsay
cottsay force-pushed the blast545/cargo_debian_template branch from e1667fc to 360e387 Compare July 23, 2026 16:50
@cottsay
cottsay merged commit 5377c14 into ros-infrastructure:master Jul 23, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants