1dgit-maint-merge(7)                  dgit                  dgit-maint-merge(7)
2
3
4

NAME

6       dgit - tutorial for package maintainers, using a workflow centered
7       around git-merge(1)
8

INTRODUCTION

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

INITIAL DEBIANISATION

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       Using untagged upstream commits
95
96           Sometimes upstream does not tag their releases, or you want to
97           package an unreleased git snapshot.  In such a case you can create
98           your own upstream release tag, of the form upstream/ver, where ver
99           is the upstream version you plan to put in debian/changelog.  The
100           upstream/ prefix ensures that your tag will not clash with any tags
101           upstream later creates.
102
103           For example, suppose that the latest upstream release is 1.2.2 and
104           you want to package git commit ab34c21 which was made on
105           2013-12-11.  A common convention is to use the upstream version
106           number 1.2.2+git20131211.ab34c21 and so you could use
107
108               % git tag -s upstream/1.2.2+git20131211.ab34c21 ab34c21
109
110           to obtain a release tag, and then proceed as above.
111
112           One can generate such a versioned tag using git show's --pretty
113           option.  e.g.:
114
115               % git tag -s upstream/$(git show --date=format:%Y%m%d --pretty=format:"1.2.2+git%cd.%h" --quiet upstream/main) upstream/main
116
117   When upstream releases only tarballs
118       We need a virtual upstream branch with virtual release tags.
119       gbp-import-orig(1) can manage this for us.  To begin
120
121           % mkdir foo
122           % cd foo
123           % git init
124
125       Now create debian/gbp.conf:
126
127           [DEFAULT]
128           upstream-branch = upstream
129           debian-branch = master
130           upstream-tag = upstream/%(version)s
131
132           sign-tags = True
133           pristine-tar = False
134           pristine-tar-commit = False
135
136           [import-orig]
137           merge-mode = merge
138           merge = False
139
140       gbp-import-orig(1) requires a pre-existing upstream branch:
141
142           % git add debian/gbp.conf && git commit -m "create gbp.conf"
143           % git checkout --orphan upstream
144           % git rm -rf .
145           % git commit --allow-empty -m "initial, empty branch for upstream source"
146           % git checkout -f master
147
148       Then we can import the upstream version:
149
150           % gbp import-orig --merge --merge-mode=replace ../foo_1.2.2.orig.tar.xz
151
152       Our upstream branch cannot be pushed to dgit-repos, but since we will
153       need it whenever we import a new upstream version, we must push it
154       somewhere.  The usual choice is salsa.debian.org:
155
156           % git remote add -f origin salsa.debian.org:Debian/foo.git
157           % git push --follow-tags -u origin master upstream
158
159       You are now ready to proceed as above, making commits to both the
160       upstream source and the debian/ directory.
161

CONVERTING AN EXISTING PACKAGE

163       This section explains how to convert an existing Debian package to this
164       workflow.  It should be skipped when debianising a new package.
165
166   No existing git history
167           % dgit clone foo
168           % cd foo
169           % git remote add -f upstream https://some.upstream/foo.git
170
171   Existing git history using another workflow
172       First, if you don't already have the git history locally, clone it, and
173       obtain the corresponding orig.tar from the archive:
174
175           % git clone git.debian.org:collab-maint/foo
176           % cd foo
177           % origtargz
178
179       Now dump any existing patch queue:
180
181           % git rm -rf debian/patches
182           % git commit -m "drop existing quilt patch queue"
183
184       Then make new upstream tags available:
185
186           % git remote add -f upstream https://some.upstream/foo.git
187
188       Now you simply need to ensure that your git HEAD is dgit-compatible,
189       i.e., it is exactly what you would get if you ran dpkg-buildpackage
190       -i'(?:^|/)\.git(?:/|$)' -I.git -S and then unpacked the resultant
191       source package.
192
193       To achieve this, you might need to delete debian/source/local-options.
194       One way to have dgit check your progress is to run dgit build-source.
195
196       The first dgit push will require --overwrite.  If this is the first
197       ever dgit push of the package, consider passing
198       --deliberately-not-fast-forward instead of --overwrite.  This avoids
199       introducing a new origin commit into your git history.  (This origin
200       commit would represent the most recent non-dgit upload of the package,
201       but this should already be represented in your git history.)
202

SOURCE PACKAGE AND GIT CONFIGURATION

204   dgit configuration
205       We must tell dgit not to try to maintain a linear queue of patches to
206       the upstream source:
207
208           git config dgit.default.quilt-mode single
209
210       This command should be executed in each git clone of this package,
211       including your co-maintainer's.  Don't set it more globally, because it
212       is not a good default for working on Debian source packages in general.
213
214   debian/source/options
215       We set a source package option to help dpkg handle changes to the
216       upstream source:
217
218           auto-commit
219
220       You don't need to create this file if you are using the version 1.0
221       source package format.
222

BUILDING AND UPLOADING

224       Use dgit build, dgit sbuild, dgit pbuilder, dgit cowbuilder, dgit push-
225       source, and dgit push-built as detailed in dgit(1).  If any command
226       fails, dgit will provide a carefully-worded error message explaining
227       what you should do.  If it's not clear, file a bug against dgit.
228       Remember to pass --new for the first upload.
229
230       If you want to upload with git-debpush(1), for the first upload you
231       should pass the --quilt=single quilt mode option (see git-debpush(1)).
232
233       As another alternative to dgit build and friends, you can use a tool
234       like gitpkg(1).  This works because like dgit, gitpkg(1) enforces that
235       HEAD has exactly the contents of the source package.  gitpkg(1) is
236       highly configurable, and one dgit user reports using it to produce and
237       test multiple source packages, from different branches corresponding to
238       each of the current Debian suites.
239
240       If you want to skip dgit's checks while iterating on a problem with the
241       package build (for example, you don't want to commit your changes to
242       git), you can just run dpkg-buildpackage(1) or debuild(1) instead.
243

NEW UPSTREAM RELEASES

245   Obtaining the release
246       When upstream tags releases in git
247
248           % git fetch --tags upstream
249
250       If you want to package an untagged upstream commit (because upstream
251       does not tag releases or because you want to package an upstream
252       development snapshot), see "Using untagged upstream commits" above.
253
254       When upstream releases only tarballs
255
256       You will need the debian/gbp.conf from "When upstream releases only
257       tarballs", above.  You will also need your upstream branch.  Above, we
258       pushed this to salsa.debian.org.  You will need to clone or fetch from
259       there, instead of relying on dgit clone/dgit fetch alone.
260
261       Then, either
262
263           % gbp import-orig ../foo_1.2.3.orig.tar.xz
264
265       or if you have a working watch file
266
267           % gbp import-orig --uscan
268
269       In the following, replace 1.2.3 with upstream/1.2.3.
270
271   Reviewing & merging the release
272       It's a good idea to preview the merge of the new upstream release.
273       First, just check for any new or deleted files that may need accounting
274       for in your copyright file:
275
276           % git diff --name-status --diff-filter=ADR master..1.2.3 -- . ':!debian'
277
278       You can then review the full merge diff:
279
280           % git merge-tree `git merge-base master 1.2.3` master 1.2.3 | $PAGER
281
282       Once you're satisfied with what will be merged, update your package:
283
284           % git merge 1.2.3
285           % dch -v1.2.3-1 New upstream release.
286           % git add debian/changelog && git commit -m changelog
287
288       If you obtained a tarball from upstream, you are ready to try a build.
289       If you merged a git tag from upstream, you will first need to generate
290       a tarball:
291
292           % git deborig
293

HANDLING DFSG-NON-FREE MATERIAL

295   When upstream tags releases in git
296       We create a DFSG-clean tag to merge to master:
297
298           % git checkout -b pre-dfsg 1.2.3
299           % git rm evil.bin
300           % git commit -m "upstream version 1.2.3 DFSG-cleaned"
301           % git tag -s 1.2.3+dfsg
302           % git checkout master
303           % git branch -D pre-dfsg
304
305       Before merging the new 1.2.3+dfsg tag to master, you should first
306       determine whether it would be legally dangerous for the non-free
307       material to be publicly accessible in the git history on dgit-repos.
308
309       If it would be dangerous, there is a big problem; in this case please
310       consult your archive administrators (for Debian this is the dgit
311       administrator dgit-owner@debian.org and the ftpmasters
312       ftpmaster@ftp-master.debian.org).
313
314   When upstream releases only tarballs
315       The easiest way to handle this is to add a Files-Excluded field to
316       debian/copyright, and a uversionmangle setting in debian/watch.  See
317       uscan(1).  Alternatively, see the --filter option detailed in
318       gbp-import-orig(1).
319

FORWARDING PATCHES UPSTREAM

321       The basic steps are:
322
323       1.  Create a new branch based off upstream's master branch.
324
325       2.  git-cherry-pick(1) commits from your master branch onto your new
326           branch.
327
328       3.  Push the branch somewhere and ask upstream to merge it, or use
329           git-format-patch(1) or git-request-pull(1).
330
331       For example (and it is only an example):
332
333           % # fork foo.git on GitHub
334           % git remote add -f fork git@github.com:spwhitton/foo.git
335           % git checkout -b fix-error upstream/master
336           % git config branch.fix-error.pushRemote fork
337           % git cherry-pick master^2
338           % git push
339           % # submit pull request on GitHub
340
341       Note that when you merge an upstream release containing your forwarded
342       patches, git and dgit will transparently handle "dropping" the patches
343       that have been forwarded, "retaining" the ones that haven't.
344

INCORPORATING NMUS

346           % dgit pull
347
348       Alternatively, you can apply the NMU diff to your repository.  The next
349       push will then require --overwrite.
350

SEE ALSO

352       dgit(1), dgit(7), gitrevisions(7)
353

AUTHOR

355       This tutorial was written and is maintained by Sean Whitton
356       <spwhitton@spwhitton.name>.  It contains contributions from other dgit
357       contributors too - see the dgit copyright file.
358
359
360
361perl v5.36.1                    Debian Project             dgit-maint-merge(7)
Impressum