]> git.proxmox.com Git - debcargo-conf.git/blob - README.rst
Merge remote-tracking branch 'origin/pending-signal-hook-registry'
[debcargo-conf.git] / README.rst
1 Instructions
2 ============
3
4 To get set up, run::
5
6 apt update && apt install debcargo
7
8 Then for each new package:
9
10 To package a new crate, or to update an existing crate
11 ------------------------------------------------------
12
13 ::
14
15 ./new-package.sh <rust-crate-name> # or
16 ./update.sh <rust-crate-name>
17
18 and follow its instructions.
19
20 Note that ``new-package.sh`` is just a symlink to ``update.sh``, to help newcomers.
21
22 To package an older version of a crate
23 --------------------------------------
24
25 To maintain an old version of a crate alongside the latest one, first make sure
26 the latest version is packaged by doing all of the above, then run::
27
28 ./new-package.sh <rust-crate-name> <old-version> # or
29 ./update.sh <rust-crate-name> <old-version>
30
31 and follow its instructions. To save time, you can first copy anything relevant
32 from ``src/<rust-crate-name>`` to ``src/<rust-crate-name>-<old-version>``, then
33 adapt it as needed.
34
35 To prepare a release
36 --------------------
37
38 ::
39
40 ./release.sh <rust-crate-name> # or
41 ./release.sh <rust-crate-name> <old-version> # as appropriate
42 DISTRO=experimental ./release.sh <rust-crate-name> # to target another distro
43
44 This prepares the necessary Debian files in ``build/``, and creates a git
45 branch to manage the packaging until it is accepted in Debian itself. You need
46 to run additional commands after this - more specific instructions are given to
47 you about this, by the script after you run it.
48
49 Holding packages at old versions
50 --------------------------------
51
52 If you need to keep the latest version in Debian at an older version than is
53 released on crates.io, e.g. to upload an important bugfix without being blocked
54 on having to package all the dependencies of the newest version, you can::
55
56 REALVER=<old-version> ./update.sh <rust-crate-name> # then
57 REALVER=<old-version> ./release.sh <rust-crate-name>
58
59
60 General packaging tips
61 ======================
62
63 Dependencies on clippy
64 ----------------------
65
66 Patch away dependencies on "clippy" unless it is a "real" dependency. Usually
67 crates only use clippy to lint themselves and it is not a "real" dependency
68 in the sense that they actually import clippy's code for what they do.
69
70 If you want to be sure, `rg clippy` and check that all the usages of it are
71 inside `cfg_attr` declarations. If so, then just get rid of it.
72
73 OS-specific crates
74 ------------------
75
76 See redox-syscall for examples on how to deal with these.
77
78 If this is unclear, ask on IRC.
79
80 Architecture-specific crates
81 ----------------------------
82
83 This is a bit harder. Usually there are two options:
84
85 1. The crate should build a dummy/no-op version of itself "out-of-the-box"
86 on the architectures it doesn't work on.
87 2. Dependent crates should depend on it with a platform-specific dependency,
88 see https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies
89
90 (1) involves less burden for others, both for dependent crates and for us
91 packagers, since we don't have to override d/rules to ignore test failures on
92 non-working architectures. You should communicate to upstream that this is
93 the preferred approach.
94
95 In the case of (2), the crate should document exactly what conditional should
96 be used, and keep this documentation up-to-date. This allows us to easily
97 determine if dependent crates are using the correct conditional. You will then
98 have to override d/rules for this crate, see src/simd for an example.
99
100 You should file a bug upstream if the crate does neither (1) nor document the
101 conditions for (2), e.g. https://github.com/hsivonen/simd/issues/25
102
103 (Actually the above applies even for "OS-specific crates" but then (2) is
104 obvious so documentation is less necessary, and dependent crates all do it
105 correctly already.)
106
107 Changed orig tarballs
108 ---------------------
109
110 Sometimes the orig.tar generated by debcargo might change e.g. if you are using
111 a newer version of debcargo and one of the dependencies relating to generating
112 the tarball was updated and its behaviour changed - compression settings,
113 tarball archive ordering, etc. This will cause your upload to get REJECTED by
114 the Debian FTP archive for having a different orig.tar. In this case, set
115 REUSE_EXISTING_ORIG_TARBALL=1 when running ``./release.sh``.
116
117 ITPs
118 ----
119
120 Don't file ITPs for library crates, but do file them for binary crates.
121
122 For now (updated 2018-09) we have several hundred crates to upload. Submitting
123 ITPs for these is unnecessary since we're the only ones uploading and there is
124 no chance of conflict. It would only be spam for the bug tracker. Please
125 instead co-ordinate uploads on the #debian-rust IRC channel.
126
127 Testing
128 -------
129
130 For now, testsuites aren't executed for library.
131 However, for binary, it is strongly recommended to run the testsuites.
132 See ripgrep as example.
133
134 Updating the dependencies
135 -------------------------
136
137 In some cases, libraries/programs are forcing an old version of a library as
138 dependencies. In order to limit the number of duplicated libraries in the
139 archive, please try to evaluate if a newer version of the dependencies could be
140 used.
141
142 To achieve that, after ./update.sh, try::
143
144 $ cd build/<package>/
145 $ rm -rf .pc # sometimes this is necessary due to minor debcargo bug
146 $ quilt push -a
147 $ quilt new relax-dep.diff
148 $ quilt edit Cargo.toml
149 $ quilt refresh
150 $ cargo build # check that it works. if it does, then
151 $ cp -R patches ../../src/<package>/debian
152
153 Suppose you want to change the dependency from 0.3 to 0.5. If the crate builds
154 with no further source changes, then we would change the required version in
155 ``Cargo.toml`` from ``0.3`` to ``>= 0.3, < 0.6`` or something like that. Then
156 the convention is to put all these changes into a single patch called
157 ``relax-dep-versions.patch``.
158
159 OTOH, if the cargo build fails, and you can fix it up by editing the source
160 code in a minor way to use the new crate API, then: for each crate that needs
161 to be updated, you should instead name the patch ``update-dep-<crate>.patch``
162 and add both the ``Cargo.toml`` and the source code changes to it. Use
163 ``quilt rename`` if that helps you.
164
165
166 DD instructions
167 ===============
168
169 To set up a suitable build environment for ``./build.sh``::
170
171 $ sudo apt-get install devscripts reprepro debootstrap sbuild dh-cargo
172 $ sudo sbuild-createchroot --include=eatmydata,ccache,gnupg,dh-cargo,cargo,lintian,perl-openssl-defaults \
173 --chroot-prefix debcargo-unstable unstable \
174 /srv/chroot/debcargo-unstable-amd64-sbuild http://deb.debian.org/debian
175
176 Normally, ``./build.sh`` will fail early if not all the build dependencies are
177 available in your local apt cache. If you are packaging a large dependency tree
178 however, to avoid many round-trips through NEW it is possible to bypass this
179 check and build all the packages together. Suppose package B depends on package
180 A, then you can run something like::
181
182 $ export IGNORE_MISSING_BUILD_DEPS=1
183 $ ./release.sh A
184 $ ( cd build && ./build.sh A )
185 # push pending and checkout master
186 $ ./release.sh B
187 $ ( cd build && ./build.sh B librust-A*.deb )
188
189 The extra arguments after ``./build.sh B <args>`` is extra deb files to pass to
190 sbuild to use as dependencies. In this case, ``librust-A*.deb`` should have
191 been built by the previous step.
192
193 After everything is built successfully, you can ``dput`` all of them and then
194 push all the ``pending-*`` branches as normal.
195
196 Packaging the existing revision
197 ===============================
198
199 In order to build a package A already in ``debcargo-conf/src``
200 in the exact version which is present here, do the following::
201
202 $ ./repackage.sh A
203 $ cd build
204 $ ./build.sh A