On April 19, 2024 8:44:12 PM GMT+02:00, Miguel Ojeda 
<miguel.ojeda.sando...@gmail.com> wrote:
>On Fri, Apr 19, 2024 at 8:13 PM Fabian Grünbichler
><debian@fabian.gruenbichler.email> wrote:
>>
>> Yes, all crates packaged by the Rust team (and most packaged for consumption 
>> by other packages/as build-deps by people outside of the team) ship their 
>> (patched for distro use) sources in a subdir there. The patches (except for 
>> wholesale exclusions of bundled C code and similar things, which is done via 
>> orig tarball repacking) are also shipped there, so the delta is easily 
>> reviewable. The whole directory structure can be used as (partial) drop-in 
>> for crates.io by configuring cargo accordingly (in Debian packaging this is 
>> done by a cargo wrapper shipped in /usr/share/cargo/bin/cargo, but that one 
>> is probably not suitable as-is for kernel stuff - it or rather its output 
>> might serve as an example for the needed cargo config runes though ;))
>
>Thanks for the quick reply!
>
>I see -- in principle, we only need the sources, i.e. we would not
>compile the crates using Cargo. Are the patches applied to the sources
>already, or are they applied by that cargo wrapper you mention at
>build time? (Well, assuming users should use the patched versions).

No, the patches are already applied in the source files shipped by 
librust-xxx-dev, if there are any. The cargo wrapper takes care of other 
things, like instructing cargo to use the packaged sources and setting 
rustflags and similar options. You should be able to use the same sources with 
manual rustc invocations without cargo or our wrapper just fine :) 

There's a bit of peculiarity around the versioning - the librust-.. packages 
provide all the semver prefixes of their version as well, so you can express "I 
want crate X in a semver compatible version of at least 2.3" via a versioned 
dependency (by depending on librust-x-2-dev with a version of at least 2.3), 
but also the more restricted variants (e.g., X in some 2.3.n version, or a 
specific 2.3.4 version, by depending on librust-2.3-dev resp. 
librust-2.3.4-dev). Normally, the actual package providing all of those is 
librust-X-dev, except when we need to package more than one version of X, then 
there might be a librust-X-dev in version A (providing all the semver prefixes 
of A), and another package librust-X-B-dev, where B is the shortest 
semver-breaking prefix of a semver incompatible version older than A (providing 
all semver prefixes of that version). A might be 2.3.4 and B 1 (with B's full 
version being 1.2.0, for example). Most of that won't be relevant for you - 
except that you want to depend on e.g. librust-syn-1-dev if you want syn 1.x, 
even if the actual "real" package is called librust-syn-dev, as the latter 
might also contain syn 0.x or 2.x in other distros/releases. Hope this was not 
too confusing ;)

Reply via email to