summaryrefslogtreecommitdiff
path: root/README.md
blob: cd29047d9e9c01693b6fe6c5b57dceb6fc74888f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# List dependencies that haven't been packaged

Summary: For a given Rust project (crate), list the Rust dependencies
(crates) that it depends on, that aren't packaged for a target
operating system.

## Description

The problem: a Rust project wants to be packaged in various operating
systems, and wants to manage its Rust dependencies to mainly be on
versions of crates that are already packaged. This would make
packaging is less work.

This tool takes a list of packaged crates and versions and compares a
Rust crate's dependencies accordingly.

Operating systems such as Debian package dependencies separately, and
frown upon embedded copies of them, or on downloading dependencies at
build time. Without going into why they do that, it's something
projects using Rust have to live with, if they want their software
packaged for such systems.

Other operating systems don't package dependencies separately. For
those, a Rust program will just use dependencies from crates.io
directly.

This repository contains tooling to make it easier to see what Rust
dependencies (crates) are missing from a target operating system.
There are two parts:

* `debian-crate-packages` is a simple shell script that fetches the
  package list for the Debian "unstable" version, and produces a list
  of Rust crates and versions that have been packaged.

* The Rust program in this crate reads the outputs of the script and
  produces a list of missing crates or versions of some Rust project.

A crate may be entirely missing from the target system, or the target
may have package of an older version. The Rust program looks for both
problems.

The list of missing crates can be used to make informed decisions
about dependencies:

* should Rust project drop the dependency, or ask the target system to
  package it?
* should the Rust project lower the version of the dependency or ask
  the target system to update their package to a newer version?


## Example use

To be run from the source tree of the `missing-dependencies` crate:

```sh
$ ./debian-crate-packages > crates-in-debian
$ cargo run -- crates-in-debian ~/my/rust/project
Table: Packaged version is not what is required

┌───────────────────────┬──────────────────┬──────────────────┐
│ Crate                 │ Required version │ Packaged version │
├───────────────────────┼──────────────────┼──────────────────┤
│ blobby                │ ^0.1             │ 0.3.1            │
├───────────────────────┼──────────────────┼──────────────────┤
│ block-buffer          │ ^0.7             │ 0.10.2           │
├───────────────────────┼──────────────────┼──────────────────┤
│ block-padding         │ ^0.1             │ 0.2.1            │
├───────────────────────┼──────────────────┼──────────────────┤
│ clap-derive           │ =3.2.17          │ 3.2.15           │
├───────────────────────┼──────────────────┼──────────────────┤
│ deunicode             │ ^0.4.0           │ 1.3.1            │
├───────────────────────┼──────────────────┼──────────────────┤
│ digest                │ ^0.8             │ 0.10.3           │
├───────────────────────┼──────────────────┼──────────────────┤
│ generic-array         │ ^0.12            │ 0.14.4           │
├───────────────────────┼──────────────────┼──────────────────┤
│ hashbrown             │ ^0.8.1           │ 0.12.1           │
├───────────────────────┼──────────────────┼──────────────────┤
│ hyphenation           │ ^0.8.4           │ 0.7.1            │
├───────────────────────┼──────────────────┼──────────────────┤
│ itertools             │ ^0.8             │ 0.10.3           │
├───────────────────────┼──────────────────┼──────────────────┤
│ opaque-debug          │ ^0.2             │ 0.3.0            │
├───────────────────────┼──────────────────┼──────────────────┤
│ proc-macro-error-attr │ =1.0.4           │ 1.0.3            │
├───────────────────────┼──────────────────┼──────────────────┤
│ quick-error           │ ^1.0.0           │ 2.0.1            │
├───────────────────────┼──────────────────┼──────────────────┤
│ remove-dir-all        │ ^0.5             │ 0.7.0            │
├───────────────────────┼──────────────────┼──────────────────┤
│ serde-derive          │ =1.0.136         │ 1.0.142          │
├───────────────────────┼──────────────────┼──────────────────┤
│ sha1-asm              │ ^0.4             │ 0.5.1            │
├───────────────────────┼──────────────────┼──────────────────┤
│ strsim                │ ^0.10            │ 0.9.3            │
├───────────────────────┼──────────────────┼──────────────────┤
│ textwrap              │ ^0.14            │ 0.15.0           │
├───────────────────────┼──────────────────┼──────────────────┤
│ value-bag             │ =1.0.0-alpha.8   │ 1.0.0-alpha.9    │
└───────────────────────┴──────────────────┴──────────────────┘

Table: Required crate is not packaged at all

┌───────────────────────────┬──────────────────┐
│ Crate                     │ Required version │
├───────────────────────────┼──────────────────┤
│ atomic_polyfill           │ ^1               │
├───────────────────────────┼──────────────────┤
│ clippy                    │ 0.*              │
├───────────────────────────┼──────────────────┤
│ directories_next          │ ^2.0.0           │
├───────────────────────────┼──────────────────┤
│ fehler                    │ ^1               │
├───────────────────────────┼──────────────────┤
│ fehler_macros             │ ^1.0.0           │
├───────────────────────────┼──────────────────┤
│ git_testament             │ ^0.2             │
├───────────────────────────┼──────────────────┤
│ git_testament_derive      │ ^0.1.13          │
├───────────────────────────┼──────────────────┤
│ ndarray                   │ ^0.14            │
├───────────────────────────┼──────────────────┤
│ no_std_compat             │ ^0.4             │
├───────────────────────────┼──────────────────┤
│ packed_simd_2             │ ^0.3.7           │
├───────────────────────────┼──────────────────┤
│ pandoc                    │ ^0.8.0           │
├───────────────────────────┼──────────────────┤
│ pandoc_ast                │ ^0.8             │
├───────────────────────────┼──────────────────┤
│ pikchr                    │ ^0.1             │
├───────────────────────────┼──────────────────┤
│ roadmap                   │ ^0.4.4           │
├───────────────────────────┼──────────────────┤
│ rustc_rayon               │ ^0.3             │
├───────────────────────────┼──────────────────┤
│ rustc_std_workspace_alloc │ ^1.0.0           │
├───────────────────────────┼──────────────────┤
│ scale_info                │ ^1.0             │
├───────────────────────────┼──────────────────┤
│ serde_aux                 │ ^3.0             │
├───────────────────────────┼──────────────────┤
│ state                     │ ^0.5             │
├───────────────────────────┼──────────────────┤
│ subplot                   │ ^0.4.3           │
├───────────────────────────┼──────────────────┤
│ subplot_build             │ ^0.4.0           │
├───────────────────────────┼──────────────────┤
│ subplotlib                │ ^0.4.1           │
├───────────────────────────┼──────────────────┤
│ subplotlib_derive         │ ^0.4.0           │
├───────────────────────────┼──────────────────┤
│ sval                      │ =1.0.0-alpha.5   │
├───────────────────────────┼──────────────────┤
│ tempfile_fast             │ ^0.3.1           │
└───────────────────────────┴──────────────────┘
 ERROR missing_dependencies > ERROR: there were 44 missing dependencies
```

Set `RUST_LOG` to `debug` or `info` to get more detailed log messages.


## FAQ

### Why is only Debian supported?

That's the only thing the author uses. Patches to add support for
other operating systems would be greatly appreciated! The best way to
do that is to write a script, similar to `debian-crate-packages`, that
produces a list of names of crates and their versions that are
packaged for an operating system.

The format of the output is one line per crate, with name, a space,
and the version, and nothing else.

The name of the crate should be the name as used by the crate itself.

### Why is only Debian unstable supported?

If Debian needs to package an entirely new crate, it'll be uploaded to
unstable. Likewise new versions of existing crates, except in serious
circumstances, mostly involving security problems. Thus, if a Rust
project wants to consider getting packaged for Debian, it'll need to
target unstable itself.

However, if you have different use case, by all means get in touch and
let's talk about it.