1dgit-maint-merge(7) dgit dgit-maint-merge(7)
2
3
4
6 dgit - tutorial for package maintainers, using a workflow centered
7 around git-merge(1)
8
10 This document describes elements of a workflow for maintaining a non-
11 native Debian package using dgit. The workflow makes the following
12 opinionated assumptions:
13
14 · Git histories should be the non-linear histories produced by
15 git-merge(1), preserving all information about divergent
16 development that was later brought together.
17
18 · Maintaining convenient and powerful git workflows takes priority
19 over the usefulness of the raw Debian source package. The Debian
20 archive is thought of as an output format.
21
22 For example, we don't spend time curating a series of quilt
23 patches. However, in straightforward cases, the information such a
24 series would contain is readily available from dgit-repos.
25
26 · It is more important to have the Debian package's git history be a
27 descendent of upstream's git history than to use exactly the
28 orig.tar that upstream makes available for download.
29
30 This workflow is less suitable for some packages. When the Debian
31 delta contains multiple pieces which interact, or which you aren't
32 going to be able to upstream soon, it might be preferable to maintain
33 the delta as a rebasing patch series. For such a workflow see for
34 example dgit-maint-debrebase(7) and dgit-maint-gbp(7).
35
37 This section explains how to start using this workflow with a new
38 package. It should be skipped when converting an existing package to
39 this workflow.
40
41 When upstream tags releases in git
42 Suppose that the latest stable upstream release is 1.2.2, and this has
43 been tagged '1.2.2' by upstream.
44
45 % git clone -oupstream https://some.upstream/foo.git
46 % cd foo
47 % git verify-tag 1.2.2
48 % git reset --hard 1.2.2
49 % git branch --unset-upstream
50
51 The final command detaches your master branch from the upstream remote,
52 so that git doesn't try to push anything there, or merge unreleased
53 upstream commits. If you want to maintain a copy of your packaging
54 branch on salsa.debian.org in addition to dgit-repos, you can do
55 something like this:
56
57 % git remote add -f origin salsa.debian.org:Debian/foo.git
58 % git push --follow-tags -u origin master
59
60 Now go ahead and Debianise your package. Just make commits on the
61 master branch, adding things in the debian/ directory. If you need to
62 patch the upstream source, just make commits that change files outside
63 of the debian/ directory. It is best to separate commits that touch
64 debian/ from commits that touch upstream source, so that the latter can
65 be cherry-picked by upstream.
66
67 Note that there is no need to maintain a separate 'upstream' branch,
68 unless you also happen to be involved in upstream development. We work
69 with upstream tags rather than any branches, except when forwarding
70 patches (see FORWARDING PATCHES UPSTREAM, below).
71
72 Finally, you need an orig tarball:
73
74 % git deborig
75
76 See git-deborig(1) if this fails.
77
78 This tarball is ephemeral and easily regenerated, so we don't commit it
79 anywhere (e.g. with tools like pristine-tar(1)).
80
81 Verifying upstream's tarball releases
82
83 It can be a good idea to compare upstream's released tarballs with
84 the release tags, at least for the first upload of the package. If
85 they are different, you might need to add some additional steps to
86 your debian/rules, such as running autotools.
87
88 A convenient way to perform this check is to import the tarball as
89 described in the following section, using a different value for
90 'upstream-tag', and then use git-diff(1) to compare the imported
91 tarball to the release tag. If they are the same, you can use
92 upstream's tarball instead of running git-deborig(1).
93
94 When upstream releases only tarballs
95 We need a virtual upstream branch with virtual release tags.
96 gbp-import-orig(1) can manage this for us. To begin
97
98 % mkdir foo
99 % cd foo
100 % git init
101
102 Now create debian/gbp.conf:
103
104 [DEFAULT]
105 upstream-branch = upstream
106 debian-branch = master
107 upstream-tag = %(version)s
108
109 sign-tags = True
110 pristine-tar = False
111 pristine-tar-commit = False
112
113 [import-orig]
114 merge-mode = merge
115
116 gbp-import-orig(1) requires a pre-existing upstream branch:
117
118 % git add debian/gbp.conf && git commit -m "create gbp.conf"
119 % git checkout --orphan upstream
120 % git rm -rf .
121 % git commit --allow-empty -m "initial, empty branch for upstream source"
122 % git checkout -f master
123
124 Then we can import the upstream version:
125
126 % gbp import-orig --merge-mode=replace ../foo_1.2.2.orig.tar.xz
127
128 Our upstream branch cannot be pushed to dgit-repos, but since we will
129 need it whenever we import a new upstream version, we must push it
130 somewhere. The usual choice is salsa.debian.org:
131
132 % git remote add -f origin salsa.debian.org:Debian/foo.git
133 % git push --follow-tags -u origin master upstream
134
135 You are now ready to proceed as above, making commits to both the
136 upstream source and the debian/ directory.
137
139 This section explains how to convert an existing Debian package to this
140 workflow. It should be skipped when debianising a new package.
141
142 No existing git history
143 % dgit clone foo
144 % cd foo
145 % git remote add -f upstream https://some.upstream/foo.git
146
147 Existing git history using another workflow
148 First, if you don't already have the git history locally, clone it, and
149 obtain the corresponding orig.tar from the archive:
150
151 % git clone git.debian.org:collab-maint/foo
152 % cd foo
153 % origtargz
154
155 Now dump any existing patch queue:
156
157 % git rm -rf debian/patches
158 % git commit -m "drop existing quilt patch queue"
159
160 Then make new upstream tags available:
161
162 % git remote add -f upstream https://some.upstream/foo.git
163
164 Now you simply need to ensure that your git HEAD is dgit-compatible,
165 i.e., it is exactly what you would get if you ran dpkg-buildpackage
166 -i'(?:^|/)\.git(?:/|$)' -I.git -S and then unpacked the resultant
167 source package.
168
169 To achieve this, you might need to delete debian/source/local-options.
170 One way to have dgit check your progress is to run dgit build-source.
171
172 The first dgit push will require --overwrite. If this is the first
173 ever dgit push of the package, consider passing
174 --deliberately-not-fast-forward instead of --overwrite. This avoids
175 introducing a new origin commit into your git history. (This origin
176 commit would represent the most recent non-dgit upload of the package,
177 but this should already be represented in your git history.)
178
180 debian/source/options
181 We set some source package options such that dgit can transparently
182 handle the "dropping" and "refreshing" of changes to the upstream
183 source:
184
185 single-debian-patch
186 auto-commit
187
188 You don't need to create this file if you are using the version 1.0
189 source package format.
190
191 Sample text for debian/source/patch-header
192 It is a good idea to explain how a user can obtain a breakdown of the
193 changes to the upstream source:
194
195 The Debian packaging of foo is maintained in git, using the merging
196 workflow described in dgit-maint-merge(7). There isn't a patch
197 queue that can be represented as a quilt series.
198
199 A detailed breakdown of the changes is available from their
200 canonical representation - git commits in the packaging repository.
201 For example, to see the changes made by the Debian maintainer in
202 the first upload of upstream version 1.2.3, you could use:
203
204 % git clone https://git.dgit.debian.org/foo
205 % cd foo
206 % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'
207
208 (If you have dgit, use `dgit clone foo`, rather than plain `git
209 clone`.)
210
211 A single combined diff, containing all the changes, follows.
212
213 If you are using the version 1.0 source package format, this text
214 should be added to README.source instead. The version 1.0 source
215 package format ignores debian/source/patch-header.
216
217 If you're using the version 3.0 (quilt) source package format, you
218 could add this text to README.source instead of
219 debian/source/patch-header, but this might distract from more important
220 information present in README.source.
221
223 Use dgit build, dgit sbuild, dgit pbuilder, dgit cowbuilder, dgit push-
224 source, and dgit push as detailed in dgit(1). If any command fails,
225 dgit will provide a carefully-worded error message explaining what you
226 should do. If it's not clear, file a bug against dgit. Remember to
227 pass --new for the first upload.
228
229 As an alternative to dgit build and friends, you can use a tool like
230 gitpkg(1). This works because like dgit, gitpkg(1) enforces that HEAD
231 has exactly the contents of the source package. gitpkg(1) is highly
232 configurable, and one dgit user reports using it to produce and test
233 multiple source packages, from different branches corresponding to each
234 of the current Debian suites.
235
236 If you want to skip dgit's checks while iterating on a problem with the
237 package build (for example, you don't want to commit your changes to
238 git), you can just run dpkg-buildpackage(1) or debuild(1) instead.
239
241 Obtaining the release
242 When upstream tags releases in git
243
244 % git remote update
245
246 When upstream releases only tarballs
247
248 You will need the debian/gbp.conf from "When upstream releases only
249 tarballs", above. You will also need your upstream branch. Above, we
250 pushed this to salsa.debian.org. You will need to clone or fetch from
251 there, instead of relying on dgit clone/dgit fetch alone.
252
253 Then, either
254
255 % gbp import-orig --no-merge ../foo_1.2.3.orig.tar.xz
256
257 or if you have a working watch file
258
259 % gbp import-orig --no-merge --uscan
260
261 Reviewing & merging the release
262 It's a good idea to preview the merge of the new upstream release.
263 First, just check for any new or deleted files that may need accounting
264 for in your copyright file:
265
266 % git diff --stat master..1.2.3 -- . ':!debian'
267
268 You can then review the full merge diff:
269
270 % git merge-tree `git merge-base master 1.2.3` master 1.2.3 | $PAGER
271
272 Once you're satisfied with what will be merged, update your package:
273
274 % git merge 1.2.3
275 % dch -v1.2.3-1 New upstream release.
276 % git add debian/changelog && git commit -m changelog
277
278 If you obtained a tarball from upstream, you are ready to try a build.
279 If you merged a git tag from upstream, you will first need to generate
280 a tarball:
281
282 % git deborig
283
285 When upstream tags releases in git
286 We create a DFSG-clean tag to merge to master:
287
288 % git checkout -b pre-dfsg 1.2.3
289 % git rm evil.bin
290 % git commit -m "upstream version 1.2.3 DFSG-cleaned"
291 % git tag -s 1.2.3+dfsg
292 % git checkout master
293 % git branch -D pre-dfsg
294
295 Before merging the new 1.2.3+dfsg tag to master, you should first
296 determine whether it would be legally dangerous for the non-free
297 material to be publicly accessible in the git history on dgit-repos.
298
299 If it would be dangerous, there is a big problem; in this case please
300 consult your archive administrators (for Debian this is the dgit
301 administrator dgit-owner@debian.org and the ftpmasters
302 ftpmaster@ftp-master.debian.org).
303
304 When upstream releases only tarballs
305 The easiest way to handle this is to add a Files-Excluded field to
306 debian/copyright, and a uversionmangle setting in debian/watch. See
307 uscan(1). Alternatively, see the --filter option detailed in
308 gbp-import-orig(1).
309
311 The basic steps are:
312
313 1. Create a new branch based off upstream's master branch.
314
315 2. git-cherry-pick(1) commits from your master branch onto your new
316 branch.
317
318 3. Push the branch somewhere and ask upstream to merge it, or use
319 git-format-patch(1) or git-request-pull(1).
320
321 For example (and it is only an example):
322
323 % # fork foo.git on GitHub
324 % git remote add -f fork git@github.com:spwhitton/foo.git
325 % git checkout -b fix-error upstream/master
326 % git config branch.fix-error.pushRemote fork
327 % git cherry-pick master^2
328 % git push
329 % # submit pull request on GitHub
330
331 Note that when you merge an upstream release containing your forwarded
332 patches, git and dgit will transparently handle "dropping" the patches
333 that have been forwarded, "retaining" the ones that haven't.
334
336 % dgit pull
337
338 Alternatively, you can apply the NMU diff to your repository. The next
339 push will then require --overwrite.
340
342 dgit(1), dgit(7)
343
345 This tutorial was written and is maintained by Sean Whitton
346 <spwhitton@spwhitton.name>. It contains contributions from other dgit
347 contributors too - see the dgit copyright file.
348
349
350
351perl v5.28.1 Debian Project dgit-maint-merge(7)