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