Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Rust vendoring document #66

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

slyon
Copy link
Contributor

@slyon slyon commented Sep 3, 2024

Importing the "RustCodeInMain" wiki page and transforming it to Markdown: https://wiki.ubuntu.com/RustCodeInMain

Also updating the README.md file to reference the documentation around the dh-cargo tooling.

Fixes #65

This comment has been minimized.

@slyon
Copy link
Contributor Author

slyon commented Sep 3, 2024

CC @liushuyu @schopin-pro @samkamer -- Please let me know if you're fine with this move of the page.

@schopin-pro
Copy link

Is this documentation rendered anywhere?

@slyon
Copy link
Contributor Author

slyon commented Sep 3, 2024

Is this documentation rendered anywhere?

Only through GitHub, e.g.: https://github.com/slyon/ubuntu-mir/blob/rust-vendoring/vendoring/Rust.md

Copy link
Contributor

@setharnold setharnold left a comment

Choose a reason for hiding this comment

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

lgtm with a quick nit and an open question. Thanks

@@ -0,0 +1,114 @@
# Rust code in main

Due to the current state of the Rust ecosystem, the MIR rules state that packages in main that contain Rust code should vendor their Rust dependencies rather than rely on the individual package versions, see [cpaelzer/ubuntu-mir#3](https://github.com/cpaelzer/ubuntu-mir/pull/3) for some background on the issue.
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to update this link when appropriate, how do we remember to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The link points to some historical reference, why do you think we should update this? IMO, we should rather re-write our Rust MIR rules (for doing less vendoring) and drop this reference eventually.

We can use this PR for discussing such improvements, but I have the impression we're not yet at a point where we can enforce non-vendored Rust packages. Somebody (Foundations/Toolchain?) still need to lay the groundwork of having a set of core packages available, i.e. as suggested in #35

Copy link
Contributor Author

@slyon slyon Sep 17, 2024

Choose a reason for hiding this comment

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

Actually, I wonder if we should still enforce the vendoring mandate, today. Maybe we should still ALLOW for vendoring Rust crates, but allow package maintainers to use the librust-*-dev packages from the archive, too. That way we could gradually move away from the vendoring, especially for Rust dependencies that are considered to be stable by the package maintainers. And run a proper MIR process on those selected rust-* source packages.

@liushuyu Do you think this would be feasible already, or is the Rust ecosystem still moving too fast?

This would mean we need to also adopt the corresponding section in the README: "The rust ecosystem currently isn't yet considered stable enough for classic lib dependencies and transitions in main; therefore the expectation for those packages is to vendor (and own/test) all dependencies (except those provided by the rust runtime itself)."

vendoring/Rust.md Outdated Show resolved Hide resolved
@jbicha
Copy link
Member

jbicha commented Sep 10, 2024

I believe vendoring directly to vendor/ will cause problems for any packages that are using debian/source/format 3.0 (quilt) where it's not allowed to directly touch things outside of debian/ except via patches or similar.

For gnome-snapshot, I used the Debian Policy § 4.16 convention of using debian/missing-sources\ instead.

So the commands to create and update the vendoring are:

rm -rf debian/missing-sources/
cargo vendor debian/missing-sources
git add -f debian/missing-sources # to avoid missing files because of .gitignore
git commit -m "Vendor Rust crate build dependencies into debian/missing-sources/"

Add a patch like this:

diff --git a/.cargo/config b/.cargo/config
new file mode 100644
index 0000000..8c56c72
--- /dev/null
+++ b/.cargo/config
@@ -0,0 +1,5 @@
+[source.crates-io]
+replace-with = "debian"
+
+[source.debian]
+directory = "debian/missing-sources"

@jbicha

This comment was marked as resolved.

@jbicha

This comment was marked as resolved.

@jbicha
Copy link
Member

jbicha commented Sep 10, 2024

I documented gnome-snapshot's vendoring workflow at https://salsa.debian.org/ubuntu-dev-team/snapshot/-/blob/ubuntu/latest/debian/README.source

@liushuyu
Copy link

I believe vendoring directly to vendor/ will cause problems for any packages that are using debian/source/format 3.0 (quilt) where it's not allowed to directly touch things outside of debian/ except via patches or similar.

Maybe we can take a page from Node.js, where you can have another source package <name>.orig-vendor.tar.xz. Some other Rust packages are doing this way instead.

@slyon
Copy link
Contributor Author

slyon commented Sep 17, 2024

Maybe we can take a page from Node.js, where you can have another source package <name>.orig-vendor.tar.xz. Some other Rust packages are doing this way instead.

@liushuyu I really like this approach. Could you provide an example of such a Rust package and describe how it's being done?

A similar approach of a vendoring .orig tarball has also been suggested by others in the past, e.g.: https://blog.shadura.me/2020/12/22/vendoring-rust-in-debian-derivative/

This comment has been minimized.

@schopin-pro
Copy link

schopin-pro commented Sep 17, 2024 via email

This comment has been minimized.

check-spelling run (pull_request_target) for rust-vendoring

Signed-off-by: check-spelling-bot <[email protected]>
on-behalf-of: @check-spelling <[email protected]>
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.

Document Rust vendoring
5 participants