Package: dh-cargo
Version: 31
Severity: normal
Tags: patch

Hi!

Prompted by a discussion about lintian warnings about
Static-Built-Using usage (via Holger Levsen), I realized that dh-cargo
was most probably not using the new substvars assignment syntax to
avoid warning when the variables do not get used.

I'm assuming the cargo:Built-Using and the cargo:X-Cargo-Built-Using
are considered obsolete and supported currently for backwards
compatibility until all rust packages have been switched to use
cargo:Static-Built-Using. But it could be that there are legitimate
uses for cargo:Built-Using (due to license compliance)?

Attached an untested patch improving this. (A similar change was
recently applied for dh-golang, which is in a similar situation.)

Thanks,
Guillem
From 7bac0658d9e09fc4d28bfbddffedbae96feb71a9 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@debian.org>
Date: Sun, 16 Feb 2025 12:03:30 +0100
Subject: [PATCH] dh-cargo-built-using: Use ?= operator for obsolete substvars

The new field to transition to is Static-Built-Using, the other fields
(Built-Using and X-Cargo-Built-Using) are now considered obsolete, and
supported for backwards compatibility until all rust packages have been
switched.

To avoid confusing packagers, use the new substvar assignment syntax (?=,
supported since dpkg 1.21.8) to denote optionally used substvars, which
will avoid emitting a warning if those substvars end up not being used.
---
 dh-cargo-built-using | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dh-cargo-built-using b/dh-cargo-built-using
index 10208fd..b62dd57 100755
--- a/dh-cargo-built-using
+++ b/dh-cargo-built-using
@@ -157,8 +157,8 @@ output_built_using() {
 		esac
 		built_using_x="${built_using_x}$src (= $srcver), "
 	done
-	echo "cargo:Built-Using=${built_using%, }" >> "debian/$binpkg.substvars"
-	echo "cargo:X-Cargo-Built-Using=${built_using_x%, }" >> "debian/$binpkg.substvars"
+	echo "cargo:Built-Using?=${built_using%, }" >> "debian/$binpkg.substvars"
+	echo "cargo:X-Cargo-Built-Using?=${built_using_x%, }" >> "debian/$binpkg.substvars"
 	echo "cargo:Static-Built-Using=${built_using_x%, }" >> "debian/$binpkg.substvars"
 }
 
-- 
2.47.2

Reply via email to