Control: tags 1023413 + patch

On Sun 2022-11-20 19:03:08 +0100, Niels Thykier wrote:
> As for doing it, you would be adding:
>
>      add_command_options('dh_clean', '-XCargo.toml.orig');
>
> (or something along those lines) to the 
> Debian/Debhelper/Sequence/cargo.pm file.  It would cover the base case 
> where people is using dh with the cargo sequence (and is not overriding 
> dh_clean - it might also work for overrides, I do not remember).
>
>
> While you are at it, I can recommend adding `Provides: 
> dh-sequence-cargo` to the dh-cargo package.  This will enable consumers 
> to enable the `cargo` sequence by using `Build-Depends: 
> dh-sequence-cargo`.  Means less boilerplate for them.

Thanks for these suggestions, Niels.  I've submitted some patches to
dh-cargo that should resolve the problem over here:

https://salsa.debian.org/rust-team/dh-cargo/-/merge_requests/8

the relevant changeset is included in the attachment below.

        --dkg

From df414b1287e8faf8b46f596b7ee5def51fc98dbe Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Wed, 23 Nov 2022 08:29:27 -0500
Subject: [PATCH] Avoid stripping Cargo.toml.orig (Closes: #1023413)

When a Rust crate is published on crates.io, the upstream source
Cargo.toml gets transformed, and the preferred form for editing gets
copied over to Cargo.toml.orig.

Some tooling related to Rust crates (e.g., the document-features
crate) inspects comments in Cargo.toml, which are typically stripped
during the usual transformation, and the only place those comments can
be found is in Cargo.toml.orig.

dh_clean by default strips *.orig, which makes it impossible to use
this kind of tooling.  It also means that the original form of
Cargo.toml is deleted each time the package is built.

This change keeps Cargo.toml.orig around for those situations where
it's useful during the crate build.
---
 Sequence/cargo.pm       | 11 +++++++++++
 debian/dh-cargo.install |  1 +
 2 files changed, 12 insertions(+)
 create mode 100644 Sequence/cargo.pm

diff --git a/Sequence/cargo.pm b/Sequence/cargo.pm
new file mode 100644
index 0000000..22b975c
--- /dev/null
+++ b/Sequence/cargo.pm
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+# debhelper sequence file for packaging Rust crates with cargo
+
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+# See https://bugs.debian.org/1023413 
+add_command_options('dh_clean', '-XCargo.toml.orig');
+
+1;
diff --git a/debian/dh-cargo.install b/debian/dh-cargo.install
index 758346f..3a8c779 100644
--- a/debian/dh-cargo.install
+++ b/debian/dh-cargo.install
@@ -1,3 +1,4 @@
+Sequence/cargo.pm    /usr/share/perl5/Debian/Debhelper/Sequence/
 cargo-auto-test      /usr/share/cargo/bin
 cargo.pm             /usr/share/perl5/Debian/Debhelper/Buildsystem/
 dh-cargo-built-using /usr/share/cargo/bin
-- 
2.35.1

Attachment: signature.asc
Description: PGP signature

Reply via email to