#942898 debcargo: reduce the impact of debcargo-built crates on the package index, and facilitate debian packaging of crates

Package:
debcargo
Source:
rust-debcargo
Description:
Create a Debian package from a Cargo crate
Submitter:
Daniel Kahn Gillmor
Date:
2025-08-17 17:48:31 UTC
Severity:
normal
Tags:
#942898#5
Date:
2019-10-23 00:34:29 UTC
From:
To:
Hi!  I'm trying to summarize in this report the state of conversation i
had today between members of the FTP team (and others on #debian-ftp)
and members the debian Rust packaging team.

We seem to be in a bit of an impasse, and i'm hoping that we can use
this report to find a concrete way out of the impasse.  This report
explains my understanding of the problem and proposes one way forward.
I'd be very happy for constructive engagement with this report.  If you
think i'm wrong, help explain what would be better, or why my proposed
changes aren't acceptable.


Background
----------

debcargo creates .deb packages corresponding to Rust crates.  I'm going
to focus here on the librust-* .deb binary packages, and ignore the
packages that ship tools that have, for example, a command-line
interface.

Each source package corresponds to a Rust crate, but it might produce
multiple librust-* binary packages -- one for each crate "flavor".

the librust-*.deb files contain mainly a distribution of .rs source
code in /usr/share/cargo/registry/…

Most of the "+flavor" .debs basically have an additional source
dependency on some other rust crate, and also ship a symlink back to the
folder of .rs source code from the standard (non "+flavor") .deb.

For each binary package shipped, it also defines a list of Provides:
that include version numbers in the name.



Problem Statement(s)
--------------------

From talking with the FTP team, the concern appears to be that the large
number of packages, and the large number of Provides produced for some
of the packages is seen as a potential problem for the apt Packages
index.

In particular, a larger Packages index:

 * increases the cost of data transfer for every debian system that does
   updates

 * means that apt has to do more complicated dependency resolution

I have not yet gotten measurements of what kinds of costs we're talking
about with respect to this shared resource.  If someone could provide
some numbers and a methodology for getting them, that would be useful in
figuring out whether any proposed change contributes a substantial
solution to the problem.  Kinds of measurements that might make the
risks a bit clearer for leaning on this shared resource too heavily:

 - size of Packages file
 - RAM needed by aptitude to ingest the Packages file
 - CPU time taken by aptitude to do dependency resolution



Additionally, from the Rust team's perspective, when a crate upstream
proposes a feature, this creates a new binary .deb, which triggers
inclusion in the NEW queue.  The delay in the NEW queue causes friction
which makes packaging Rust-related projects harder to do.

I've experienced this myself, where i spend about an hour or two on rust
packaging, and then find myself waiting for weeks before i can do the
next hour of work -- this isn't conducive to effective maintenance.



Proposed Solutions
------------------

AIUI, the FTP team thinks that debcargo could reduce the impact on the
shared resource of the Packages index by adopting one or both of the
tactics described below:

 0) reduce the number of "+feature" .debs produced by each crate,
    perhaps by creating two base .debs for each package: one with no
    "features" and one that bundles together all of the features that
    are not mutually-exclusive.  Any features that are mutually
    exclusive would still get their own separate "+feature" .deb.

 1) drop version numbering from the Provides: entries for standard
    packages -- this should reduce the number of Provides: by a
    substantial fraction.  Given that crates are expected to hew to
    semantic versioning, a generated version number range should be
    sufficient to declare an API-compatible version dependency.



Concerns
--------

A concern I've heard about tactic (0) is that this approach might result
in dependency loops, as in:

https://github.com/sfackler/cargo-tree/issues/34#issuecomment-394266843

It's conceivable that apt could figure out how to deal with those loops,
and given that these librust-*-dev .debs are basically just sourcecode,
these loops will only affect Rust developers (who might be expected to
have beefier machines than regular end users).

Such a change would also reduce the number of packages


A concern i've heard about tactic (1) is that it makes it harder to ship
a two versions of a crate in a given debian distro.  For example, we
might want to ship librust-foo-dev version 1.x alongside librust-foo-dev
version 2.x.  If they have the same package name (librust-foo-dev) then
they can't both be in the archive at once.

We currently do ship librust-foo-dev (meaning "the latest version"), and
we create a new package librust-foo-1-dev for when we intend to maintain
a stable API for an older release.  I don't think anyone wants that to
change (many C library packages use the same pattern based on their
SONAMEs).

The use of Provides: makes it so that a package can directly Depend: on
the package with the API in the name, rather than depending on a
versioned range.  But perhaps the fix is to make the dependencies
marginally more complex, rather than stuffing lots of Provides in each
binary package.  For example, a package that depends on the foo crate at
1.2 or higher could use:

   Depend: librust-foo-dev (>= 1.2) (<< 2) || librust-foo-1-dev (>= 1.2)


Do the above approaches seem feasible?  Would they satisfy both the FTP
team and the Rust packaging team?  Are they implementable?

Sorry that i don't have the capacity to actually implement them myself,
i just want to identify a way forward that will make both Debian and the
Rust ecosystem more compatible.

Regards,

#942898#12
Date:
2019-10-23 13:27:00 UTC
From:
To:
Daniel Kahn Gillmor:

As a user, I haven't noticed Debian slowing down because of rust packages.

As a volunteer, I have better things to do with my free time than "fix" a non-problem because someone else thinks something else is too big.

If you like to see other people fix this bug, please provide more detailed information that clearly indicates that the current situation in concretely problematic, to convince them to fix it.

If you would like to fix this bug yourself, please suggest a concrete solution and we can comment on whether it's feasible/sustainable/maintainable.

X

#942898#19
Date:
2019-10-23 13:45:00 UTC
From:
To:
Daniel Kahn Gillmor:

Detecting "mutually-exclusive" isn't straightforward as you'd have to detect the cycles we mentioned below. I can't be bothered writing this code, the cost-benefit tradeoff is not worth it.

This isn't possible due to #901827.

The solution that we're already doing (I'll refer to this as "solution A" for future reference) for exceptionally large crates like web-sys is to just patch out the unused features. This is by far the easiest option that cuts away most of the size, whilst retaining the other benefits of the current automation.

So I don't see anything additional to do on this topic.

X

#942898#24
Date:
2019-10-24 16:10:27 UTC
From:
To:
I've certainly noticed that apt takes longer reading the index than it
used to take back when i started using debian.  And we have much more
powerful machines today.

Clearly, we can't attribute that to the rust ecosystem specifically, but
it's also evident that this is a shared resource and if everyone grabs
more of it just because we can, we'll all be worse off.

That said, it would be good to have someone take the time to measure
these costs specifically.

Over on #942893 i've done baseline measurements for the size of the
Packages file, and proposed a way to cut that down by 13%.  Perhaps
someone else who is better with profiling could do some comparable
baselines for RAM and CPU time if they want to demonstrate a concrete
problem?

#942898#29
Date:
2020-08-09 21:21:45 UTC
From:
To:
Control: merge 945542 942898

In https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=945542#94
is this text
| it's not clear to me how this bug report is supposed to be distinct
| from #942898, which already captures some of these details.  if the
| reporter or maintainer wants to merge them, i think that'd be reasonable

That merge is now done.  No, I'm not the maintainer of debcargo,
I'm a DD that wants Rust packages in Debian. Infact I want a
smooth way from Rusts dependency resolve and builder 'cargo'
to the Debian archive.  I'm fully aware it will take effort
both from Rust team and FTP team


Links for clicking to the bug reports
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=945542
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=942898


Regards
Geert Stappers

#942898#34
Date:
2020-08-09 21:39:01 UTC
From:
To:
Control: affects 945542 ftp.debian.org
Control: merge 945542 942898