#1076434 dh-rust: support appending subproject version to binary package version

#1076434#5
Date:
2024-07-16 10:44:40 UTC
From:
To:
An upstream project may consist of multiple parts,
each versioned differently,
where binary packages need to include tracking
of the version(s) contained subprojects.

One example is Mediasoup,
where the NodeJS NPM project "mediasoup" version 3.13.12
contains the Rust Cargo subproject "mediasoup" version 0.13.0.

Another example is Oxigraph,
where an unnambed Rust Cargo workspace version 0.4.0-alpha.7
contains crate "oxigraph" versioned same as the workspace
and crate "oxrdf" version 0.2.0-alpha.5
(as well as other crates, irrelevant for this example).

D::D::Buildsystem::rust already resolves the version of each crate
in a Cargo multi-crate workspace.

I think dh_rust should introduce two debhelper scripts:

## dh_rust_substvars

Resolves ${rustPkg_PKG:Version} variable for each subproject,
where PKG is the real of virtual package providing the subproject,
and the value is the Debian version derived from subproject version
and source package version.

For Mediasoup, it should resolve this variable:

rustPkg-librust-mediasoup-dev:Version=0.13.0+3.13.12

For Oxigraph, it should resolve these variables:

rustPkg-oxigraph:Version=0.4.0~alpha7
rustPkg-librust-oxrdf-dev:Version=0.2.0~alpha5+0.4.0~alpha7

## dh_rust_gencontrol

Sets ${rustPkg_PKG:Version} for virtual and real rust-* packages.

Multiple packages would benefit from this,
currently duplicating a pattern of overriding dh_gencontrol
with multiple custom calls to custom make function crate_version(),
which crudely resolves crate versions using a regex.

 - Jonas
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEn+Ppw2aRpp/1PMaELHwxRsGgASEFAmaWTxUACgkQLHwxRsGg
ASGodRAArRUu5/iyyS96NYFdU3zZhlDzaMOuYMrioWD9iqh+G6/9x7dnquWp80p+
hzCf51Muwc6QruLRzdgaRoUhcm4mWdrF5IpNaYItEh7RkDnlVmLTzVhvVyo/D+G8
mGGaLkFhqLrDyApG6cq+HaIF8kkUasbFHbybzOFfCJhozIb53Tm15T9/GGi1MY/D
jFS8587C2iPiQrVwwhYb+PHYOoKcfqtQHnhS8Yf2KVsFQywq0j3DdQ83wWsdZXpz
aW14whp+24wG/e7F1kzxxLX+tttn+eq8twTg4tDOWmm+DyTQZiqaNwTDZAxOcEWT
OYMxLBWUMKQGOpqXrIWrItVGdthE4oLRCWtALft818qwkUMjmN5O1xkCfJPwklvc
8rRhreT+Tt6s1m/j18ftgTiUMxc2HjulOrn9nRrHi8aM9N+lz/T8sIjGga5l3Fc+
R3Vnf24crO/XcYfPA33wJxNnLf191yfcSBjcMkSS3UdB0IEoAR//r+83CTbhvWPX
UFe6KbZO8B+3s/W+MvT38qG+jA37IudZMR7mMctsvepBJsYPQdvKAn1RpXbN1JvD
88MPvF5F0U+6aLhJIMCmHxPF302+90C7LneUwBcVABAESi6njm7Si0cGsbA9Pam0
z+WKakcrPX48Atx6TFkRfJccC2XlsYENN8p+4oPxqM2Bt97qniA=
=TgiU
-----END PGP SIGNATURE-----

#1076434#12
Date:
2024-07-16 10:57:57 UTC
From:
To:
A common workaround for this is a pattern of overriding dh_gencontrol
with multiple custom calls to custom make function crate_version(),
which crudely resolves crate versions using a regex.

(workaround reposted as an initial paragraph, for use as bug summary)

#1076434#19
Date:
2024-07-16 11:02:29 UTC
From:
To:
On 16/07/2024 18:44, Jonas Smedegaard wrote:
(...)

This feels rather bizarre. Though somehow works, it's probably better added in
dh proper support for producing binpkgs with versions different than their
srcpkg, if that's a trend in upstream?

#1076434#24
Date:
2024-07-16 11:17:16 UTC
From:
To:
Quoting Jonas Smedegaard (2024-07-16 12:44:40)
[...]

Current make-based workaround use shorter variables,
based on stem of conventional rust-*-dev package naming,
like this:

rust-oxrdf:Version=0.2.0~alpha5+0.4.0~alpha7

That's tempting, but I imagine some may need to involve packages
that does not follow that naming convention.

 - Jonas

#1076434#29
Date:
2024-07-16 11:23:13 UTC
From:
To:
Quoting Blair Noctis (2024-07-16 13:02:29)
as affected by this bugreport - e.g. oxigraph.

What is not in core debhelper, and cannot be, is when to use which
version.

 - Jonas

#1076434#34
Date:
2024-07-16 13:58:23 UTC
From:
To:
Quoting Jonas Smedegaard (2024-07-16 13:17:16)

I just noticed (while reading `man dh_builtusing`)
that substvars can contain multiple colons.

I will now¹ change all affected packages to use substvar like this:

rust:Version:oxigraph=0.4.0~alpha7
rust:Version:librust-oxrdf-dev=0.2.0~alpha5+0.4.0~alpha7

 - Jonas

¹ Those changes won't be in released packages yet,
as I am waiting from adoption of dh-rust to transition to testing.