Browse code

add instructions on Debian/Ubuntu packaging

Christoph Groth authored on 15/12/2017 11:44:26 • Joseph Weston committed on 26/02/2018 16:01:43
Showing 1 changed files
... ...
@@ -1,13 +1,18 @@
1 1
 Making a Kwant release
2 2
 ======================
3
+
3 4
 This document guides a contributor through creating a release of Kwant.
4 5
 
6
+
5 7
 Preflight checks
6 8
 ################
9
+
7 10
 The following checks should be made *before* tagging the release.
8 11
 
12
+
9 13
 Check that all issues are resolved
10 14
 ----------------------------------
15
+
11 16
 Check that all the issues and merge requests for the appropriate
12 17
 `milestone <https://gitlab.kwant-project.org/kwant/kwant/milestones>`
13 18
 have been resolved. Any unresolved issues should have their milestone
... ...
@@ -16,6 +21,7 @@ bumped.
16 21
 
17 22
 Ensure that all tests pass
18 23
 --------------------------
24
+
19 25
 This should be as simple as verifying that the latest CI pipeline succeeded.
20 26
 For major and minor releases we will be tagging the ``master`` branch.
21 27
 For patch releases, the ``stable`` branch.
... ...
@@ -23,6 +29,7 @@ For patch releases, the ``stable`` branch.
23 29
 
24 30
 Inspect the documentation
25 31
 -------------------------
32
+
26 33
 If the CI pipeline succeeded, then the latest docs should be available at:
27 34
 
28 35
     https://test.kwant-project.org/doc/<branch name>
... ...
@@ -32,6 +39,7 @@ Check that there are no glaring deficiencies.
32 39
 
33 40
 Update the ``whatsnew`` file
34 41
 ----------------------------
42
+
35 43
 Check that there is an appropriate ``whatsnew`` file in ``doc/source/pre/whatsnew``.
36 44
 This should be named as::
37 45
 
... ...
@@ -45,28 +53,313 @@ assigned to the release's milestons and get an idea of what was introduced
45 53
 from there.
46 54
 
47 55
 
56
+Make a release, but do not publish it yet
57
+#########################################
58
+
59
+Various problems can surface only during the process of preparing a release and
60
+make it necessary to fix the codebase.  It would be a pity to have to succeed
61
+the freshly released version by a minor release just to correct a glitch that
62
+was detected too late.  Therefore it is a good idea to pursue the release as
63
+far as possible without announcing it, such that it can be undone and corrected
64
+if necessary.  In the past tests that failed on the x86-32 architecture and
65
+wrongly declared dependencies have been detected in this way.
66
+
67
+
48 68
 Tag the release
49
-###############
50
-Make an *annotated*, *signed* tag for the release. The tag must have the semantic
51
-versioning format::
69
+---------------
52 70
 
53
-    v<major>.<minor>.<patch>
71
+A particularly good way to expose hidden problems is building Debian packages
72
+using an isolated minimal build environment (cowbuilder).  This approach is
73
+described here.
54 74
 
55
-Once the tag has been created, push it to Kwant Gitlab.
75
+Make an *annotated*, *signed* tag for the release. The tag must have the name::
56 76
 
77
+    git tag -s v1.2.3 -m "version 1.2.3"
57 78
 
58
-Post-tagging
59
-############
60
-Pushing a new tag to Kwant Gitlab will kick off a few CI jobs, but there is
61
-still some manual work to do.
79
+Be sure to respect the format of the tag name (leading "v").  The tag message
80
+format is the one that has been used so far.
62 81
 
82
+Do *not* yet push the tag anywhere, it might have to be undone!
63 83
 
64
-Prepare the Debian package
84
+
85
+Build a source taball and inspect it
86
+------------------------------------
87
+
88
+    ./setup.py sdist
89
+
90
+This creates the file dist/kwant-1.2.3.tar.gz.  It is a good idea to unpack it
91
+in /tmp and inspect that builds in isolation and that the tests run::
92
+
93
+    cd /tmp
94
+    tar xzf ~/src/kwant/dist/kwant-1.2.3.tar.gz
95
+    cd kwant-1.2.3
96
+    ./setup.py test
97
+
98
+
99
+Clone the repository of the Kwant Debian package
100
+------------------------------------------------
101
+
102
+This step needs to be performed only once.  The cloned repository can be reused
103
+for subsequent releases.
104
+
105
+Clone the "kwant-debian" repository and go into its root directory.  If you
106
+keep the Kwant source in "src/kwant", a good location for the Debian package
107
+repository is "src/debian/kwant".  The packaging process creates many files
108
+that are placed into the parent directory of the packaging repository, hence
109
+having an additional directory level ("src/debian") is a good way to keep these
110
+files separate::
111
+
112
+    mkdir debian
113
+    cd debian
114
+    git clone ssh://git@gitlab.kwant-project.org:443/kwant/debian-kwant.git kwant
115
+    cd kwant
116
+
117
+Create a local upstream branch::
118
+
119
+    git branch upstream origin/upstream
120
+
121
+Add a remote for the repository that contains the previously created tag::
122
+
123
+    git remote add upstream_repo ~/src/kwant
124
+
125
+Make sure that::
126
+
127
+    git config --get user.name
128
+    git config --get user.email
129
+
130
+show correct information.
131
+
132
+
133
+Release a new version of the Kwant Debian package
134
+-------------------------------------------------
135
+
136
+Fetch the git tag created above into the packaging repo::
137
+
138
+    git fetch --all
139
+
140
+Now there are two options.  If, as recommended above, the tarball of the new
141
+version has not been made public yet, it must be imported as follows::
142
+
143
+    gbp import-orig ~/src/kwant/dist/kwant-1.2.3.tar.gz
144
+
145
+Alternatively, the following commands will import the newest version from PyPI::
146
+
147
+    uscan --report      # This will report if a newer version exists on PyPI
148
+    gbp import-orig --uscan
149
+
150
+Update the debian changelog.  Add a point "New upstream release" if there was
151
+one, and describe any other changes to the Debian *packaging*::
152
+
153
+    DEBEMAIL=your.email@somewhere.org gbp dch -R --commit --distribution testing
154
+
155
+Now the package can be built with::
156
+
157
+    git clean -i
158
+    gbp buildpackage
159
+
160
+But this is *not* how the package should be built for distribution.  For that,
161
+see the following two sections.
162
+
163
+
164
+Setup git-pbuilder to build Debian packages
165
+-------------------------------------------
166
+
167
+Pbuilder is a tool to build Debian packages in an isolated chroot.  This allows
168
+to verify that the package indeed only has the declared dependencies.  It also
169
+allows to cross-build packages for i386 on amd64.
170
+
171
+The following describes how to setup git-pbuilder, see also
172
+https://wiki.debian.org/git-pbuilder.  This procedure needs to be executed only
173
+once for a Debian system.
174
+
175
+Install the Debian package git-buildpackage.
176
+
177
+As root, add the following lines to /etc/sudoers or /etc/sudoers.d/local
178
+
179
+    Cmnd_Alias BUILD = /usr/sbin/cowbuilder
180
+
181
+and
182
+
183
+    user     ALL = SETENV: BUILD
184
+
185
+Now create pbuilder images.  In the following, replace "buster" by the current
186
+Debian testing codename::
187
+
188
+    ARCH=i386 DIST=buster git-pbuilder create
189
+    ARCH=amd64 DIST=buster git-pbuilder create
190
+
191
+If the packages to be built have special dependencies, use the trick described in https://wiki.debian.org/git-pbuilder#Using_Local_Packages
192
+
193
+
194
+Build Kwant packages using git-pbuilder
195
+---------------------------------------
196
+
197
+Update the builder environment (again, replace "buster" with the name of the
198
+current Debian testing)::
199
+
200
+    ARCH=i386 DIST=buster git-pbuilder update
201
+    ARCH=amd64 DIST=buster git-pbuilder update
202
+
203
+Now build the packages.  First the i386 package.  The option "--git-tag" tags
204
+and signs the tag if the build is successful.  In a second step, the package is
205
+built for amd64, but only the architecture-dependent files (not the
206
+documentation package)::
207
+
208
+    gbp buildpackage --git-pbuilder --git-arch=i386 --git-dist=buster --git-tag
209
+    gbp buildpackage --git-pbuilder --git-arch=amd64 --git-dist=buster --git-pbuilder-options='--binary-arch'
210
+
211
+Another example: build source package only::
212
+
213
+    gbp buildpackage --git-export-dir=/tmp -S
214
+
215
+Build packports for the current Debian stable
216
+---------------------------------------------
217
+
218
+Create a changelog entry for the backport::
219
+
220
+    DEBEMAIL=your.email@somewhere.org dch --bpo
221
+
222
+Build backported packages::
223
+
224
+    gbp buildpackage --git-pbuilder --git-ignore-new --git-arch=i386 --git-dist=stretch
225
+    gbp buildpackage --git-pbuilder --git-ignore-new --git-arch=amd64 --git-dist=stretch --git-pbuilder-options='--binary-arch'
226
+
227
+Do not commit anything.
228
+
229
+Publish the release
230
+###################
231
+
232
+If the Debian packages build correctly that means that all tests pass both on
233
+i386 and amd64, and that no undeclared dependencies are needed.  We can be
234
+reasonable sure that the release is ready to be published.
235
+
236
+git
237
+---
238
+
239
+Push the tag to the official Kwant repository::
240
+
241
+    git push origin v1.2.3
242
+
243
+PyPI
244
+----
245
+
246
+PyPI (this requires a file ~/.pypirc with a vaild username and password)::
247
+
248
+    twine upload -s dist/kwant-1.2.3.tar.gz
249
+
250
+It is very important that the tarball uploaded here is the same (bit-by-bit,
251
+not only the contents) as the one used for the Debian packaging.  Otherwise it
252
+will not be possible to build the Debian package based on the tarball from
253
+PyPI.
254
+
255
+Kwant website
256
+-------------
257
+
258
+The tarball and its signature (generated by the twine command above) should be
259
+also made available on the website::
260
+
261
+    scp dist/kwant-1.2.3.tar.gz* kwant-website-downloads:downloads/kwant
262
+
263
+Debian packages
264
+---------------
265
+
266
+Go to the Debian packaging repository and push out everything::
267
+
268
+    git push --all --tags origin
269
+
270
+Now the Debian packages that we built previously need to be added to the
271
+repository of Debian packages on the Kwant website.  So far this the full
272
+version of this repository is kept on Christoph Groth's machine, so this
273
+instructions are for reference only.
274
+
275
+Go to the reprepro repository directory and verify that the configuration file
276
+"conf/distributions" looks up-to-date.  It should look something like this::
277
+
278
+    Origin: Kwant project
279
+    Suite: stretch-backports
280
+    Codename: stretch-backports
281
+    Version: 9.0
282
+    Architectures: i386 amd64 source
283
+    Components: main
284
+    Description: Unofficial Debian package repository of http://kwant-project.org/
285
+    SignWith: C3F147F5980F3535
286
+    
287
+    Origin: Kwant project
288
+    Suite: testing
289
+    Codename: buster
290
+    Version: 10.0
291
+    Architectures: i386 amd64 source
292
+    Components: main
293
+    Description: Unofficial Debian package repository of http://kwant-project.org/
294
+    SignWith: C3F147F5980F3535
295
+
296
+If the config had to be updated execute::
297
+
298
+    reprepro export
299
+    reprepro --delete createsymlinks
300
+
301
+Now the source and binary Debian packages can be added.  The last line has to
302
+be executed for all the .deb files and may be automated with a shell loop. (Be
303
+sure to use the appropriate <dist>: either testing or stretch-backports.)::
304
+
305
+    reprepro includedsc <dist> ../../src/kwant_1.2.3-1.dsc
306
+    reprepro includedeb <dist> python3-kwant_1.2.3-1_amd64.deb
307
+
308
+Once all the packages have been added, upload the repository::
309
+
310
+    rsync -avz --delete dists pool wfw:webapps/downloads/debian
311
+
312
+Ubuntu packages
313
+---------------
314
+
315
+Make sure ~/.dput.cf has something like this::
316
+    [ubuntu-ppa-kwant]
317
+    fqdn = ppa.launchpad.net
318
+    method = ftp
319
+    incoming = ~kwant-project/ppa/ubuntu/
320
+    login = anonymous
321
+    allow_unsigned_uploads = 0
322
+
323
+We will also use the following script (prepare_ppa_upload)::
324
+    #!/bin/sh
325
+    
326
+    if [ $# -eq 0 ]; then
327
+        echo -e "\nUsage: $(basename $0) lousy mourning2 nasty\n"
328
+        exit
329
+    fi
330
+    
331
+    version=`dpkg-parsechangelog --show-field Version`
332
+    mv debian/changelog /tmp/changelog.$$
333
+    
334
+    for release in $@; do
335
+        cp /tmp/changelog.$$ debian/changelog
336
+        DEBEMAIL=christoph.groth@cea.fr dch -b -v "$version~$release" -u low 'Ubuntu PPA upload'
337
+        sed -i -e "1,1 s/UNRELEASED/$release/" debian/changelog
338
+        debuild -S -sa
339
+    done
340
+    
341
+    mv /tmp/changelog.$$ debian/changelog
342
+
343
+Make sure that the Debian package builds correctly and go to its directory.
344
+
345
+Check https://wiki.ubuntu.com/Releases for the current releases and execute::
346
+    prepare_ppa_upload trusty vivid wily
347
+
348
+(if a second upload of the same Debian version is needed, something like vivid2 can be used)
349
+
350
+Now the changes files are "put" to start the build process on the PPA servers::
351
+
352
+    cd ..
353
+    dput ubuntu-ppa-kwant *~*.changes
65 354
 
66 355
 
67 356
 Gather the autobuilt packages from CI
68 357
 -------------------------------------
358
+
359
+(This section needs to be updated.  Using the sdist package as generated by
360
+PyPI requires pushing the tag to gitlab and as such is incompatible with doing
361
+the Debian packaging with an unpublished tag.)
362
+
69 363
 CI automatically generates:
70 364
 
71 365
 + HTML documentation
... ...
@@ -80,6 +373,10 @@ These can be found in the artifacts of the last CI job in the pipeline,
80 373
 
81 374
 Publish to the Kwant website
82 375
 ----------------------------
376
+
377
+(This section needs to be updated.  The twine tool creates the signature file
378
+during the upload.)
379
+
83 380
 To do the following you will need access to the webroots of ``downloads.kwant-project.org``
84 381
 and ``kwant-project.org``. Ask Christoph Groth if you need to be granted access.
85 382
 
... ...
@@ -104,6 +401,9 @@ on ``kwant-project.org``. Point the symbolic link ``<major>`` to this directory.
104 401
 
105 402
 Publish to PyPI
106 403
 ---------------
404
+
405
+(This also needs to be updated.)
406
+
107 407
 Install `twine <https://pypi.python.org/pypi/twine>` and use it to upload
108 408
 the tar archive in the ``sdist`` directory of the Ci artifacts downloaded
109 409
 in the previous step::
... ...
@@ -121,6 +421,7 @@ Publish to Launchpad
121 421
 
122 422
 Publish to Conda forge
123 423
 ----------------------
424
+
124 425
 Conda forge automates build/deploy by using CI on Github repositoried containing
125 426
 recipes for making packages from their source distributions.
126 427
 
... ...
@@ -139,6 +440,7 @@ to review and accept the pull request, so that Kwant will be rebuilt.
139 440
 
140 441
 Announce the release
141 442
 --------------------
443
+
142 444
 Write a short post summarizing the highlights of the release on the
143 445
 `Kwant website <https://gitlab.kwant-project.org/kwant/website>`, then
144 446
 post this to the mailing list kwant-discuss@kwant-project.org.
... ...
@@ -146,6 +448,7 @@ post this to the mailing list kwant-discuss@kwant-project.org.
146 448
 
147 449
 Working towards the next release
148 450
 ################################
451
+
149 452
 After finalizing a release, a new ``whatsnew`` file should be created for
150 453
 the *next* release, and this addition should be committed and tagged as::
151 454