Skip to content

Add Debian template for 'cargo' build type#774

Open
Blast545 wants to merge 9 commits into
ros-infrastructure:cottsay/cargofrom
Blast545:blast545/cargo_debian_template
Open

Add Debian template for 'cargo' build type#774
Blast545 wants to merge 9 commits into
ros-infrastructure:cottsay/cargofrom
Blast545:blast545/cargo_debian_template

Conversation

@Blast545

@Blast545 Blast545 commented May 5, 2026

Copy link
Copy Markdown

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.

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Comment thread bloom/generators/debian/templates/cargo/rules.em
@codecov-commenter

codecov-commenter commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (cottsay/cargo@86fe30d). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             cottsay/cargo     #774   +/-   ##
================================================
  Coverage                 ?   52.24%           
================================================
  Files                    ?       57           
  Lines                    ?     6969           
  Branches                 ?     1206           
================================================
  Hits                     ?     3641           
  Misses                   ?     2983           
  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 added 2 commits May 5, 2026 15:26
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
@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
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 and others added 5 commits May 11, 2026 10:47
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 Perez <jjperez@ekumenlabs.com>
@Blast545

Copy link
Copy Markdown
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
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
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
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