Source: dh-rust
Version: 0.0.11
Severity: wishlist
Tags: patch
X-Debbugs-Cc: noisyc...@tutanota.com
Control: block 1094199 by -1
Control: block 1094483 by -1

Hi Jonas,

I hope you don't mind me filing this bug as a reminder of future work. I'm
afraid if I don't file it now I will forget later :-)

A few moments ago a new `--exclude-lockfile` flag was merged into upstream
cargo for use with `cargo package` [1]. It was merged to cargo 0.88, so it
should be available with rustc 1.87 and later.

The `--exclude-lockfile` flag disables verification/creation of Cargo.lock when
using `cargo package`. It was introduced specifically for packaging workflows
like those we use in Debian [2], where we don't actually care about Cargo.lock,
but its verification/generation nonetheless forces us to populate the local
registry with crates we wouldn't otherwise need (like any dependency with the
'nocheck' build profile, or test dependencies) at package build time. This in
turn causes bugs like #1094199 and #1094483, as I noted previously there.

Using the `--exclude-lockfile` flag should be enough to automatically solve
these bugs, so I'm blocking them by the present one. Feel free to remove the
blocks if you disagree. Additionally, I think the flag will make the packaging
order of crates irrelevant (as it should make it possible to package each of
them stand-alone, independent of the content of the registry). This in turn
should obsolete Hilko's workaround [3] for Bug#1094199. In attachment you will
find a patch to add the new flag. Beware that, as mentioned above, you won't
be able to use it before rustc 1.87 or later is released and uploaded to
unstable (early in the forky release cycle?).

Thanks for all the work.

Cheers!


[1] https://github.com/rust-lang/cargo/pull/15234
[2] https://github.com/rust-lang/cargo/issues/15159
[3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1094199#99
>From 343c4092430594feb4f66b3caaeeea7fa9038830 Mon Sep 17 00:00:00 2001
From: NoisyCoil <noisyc...@tutanota.com>
Date: Fri, 14 Mar 2025 18:01:01 +0100
Subject: [PATCH] add the --exclude-lockfile flag to `cargo package`'s
 invocation

This flag decouples the packaging step from the contents of the local
registry, so that packaging can work with no crates installed
---
 lib/Debian/Debhelper/Buildsystem/rust.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Debian/Debhelper/Buildsystem/rust.pm 
b/lib/Debian/Debhelper/Buildsystem/rust.pm
index 76610d3..d03e94f 100644
--- a/lib/Debian/Debhelper/Buildsystem/rust.pm
+++ b/lib/Debian/Debhelper/Buildsystem/rust.pm
@@ -368,7 +368,7 @@ sub install ( $this, $destdir, @params )
         install_dir($target);
         $this->doit_in_somedir(
             $crate->{sourcepath},
-            qw(cargo package --offline --allow-dirty --no-verify),
+            qw(cargo package --offline --allow-dirty --no-verify 
--exclude-lockfile),
             '--target-dir', cwd . '/target', '--package', $crate->{pkgid}
         );
         $this->doit_in_somedir(
-- 
2.47.2

Reply via email to