chiark / gitweb /
Split brain: Create debian/patches in case it does not exist
[dgit.git] / dgit.7
1 .TH dgit 7 "" "Debian Project" "dgit"
2 .SH NAME
3 dgit \- principles of operation
4 .SH SUMMARY
5 .B dgit
6 treats the Debian archive as a version control system, and
7 bidirectionally gateways between the archive and git.  The git view of
8 the package can contain the usual upstream git history, and will be
9 augmented by commits representing uploads done by other developers not
10 using dgit.  This git history is stored in a canonical location known
11 as
12 .B dgit-repos
13 which lives on a dedicated git server.
14 .SH MODEL
15 You may use any suitable git workflow with dgit, provided you
16 satisfy dgit's requirements:
17
18 dgit maintains a pseudo-remote called
19 .BR dgit ,
20 with one branch per suite.  This remote cannot be used with
21 plain git.
22
23 The
24 .B dgit-repos
25 repository for each package contains one ref per suite named
26 \fBrefs/dgit/\fR\fIsuite\fR.  These should be pushed to only by
27 dgit.  They are fast forwarding.  Each push on this branch
28 corresponds to an upload (or attempted upload).
29
30 However, it is perfectly fine to have other branches in dgit-repos;
31 normally the dgit-repos repo for the package will be accessible via
32 the remote name `origin'.
33
34 dgit push will also make signed tags called
35 .BI debian/ version
36 (a la DEP-14) and push them to dgit-repos.  These are used at the
37 server to authenticate pushes.
38
39 dgit push can operate on any commit which is a descendant of the
40 current dgit/suite tip in dgit-repos.
41
42 Uploads made by dgit contain an additional field
43 .B Dgit
44 in the source package .dsc.  (This is added by dgit push.)
45 This specifies a commit (an ancestor of the dgit/suite
46 branch) whose tree is identical to the unpacked source upload.
47
48 Uploads not made by dgit are represented in git by commits which are
49 synthesised by dgit.  The tree of each such commit corresponds to the
50 unpacked source; there is an origin commit with the contents, and a
51 psuedo-merge from last known upload - that is, from the contents of
52 the dgit/suite branch.
53
54 dgit expects repos that it works with to have a
55 .B dgit
56 remote.  This refers to the well-known dgit-repos location (on a
57 dedicated Debian VM).  dgit fetch updates the remote tracking branch
58 for dgit/suite.
59
60 dgit does not (currently) represent the orig tarball(s) in git.  The
61 orig tarballs are downloaded (by dgit clone) into the parent
62 directory, as with a traditional (non-gitish) dpkg-source workflow.
63 You need to retain these tarballs in the parent directory for dgit
64 build and dgit push.
65
66 dgit repositories could be cloned with standard (git) methods. The
67 only exception is that for sourceful builds / uploads the orig
68 tarball(s) need to be present in the parent directory.
69
70 To a user looking at the archive, changes pushed using dgit look like
71 changes made in an NMU: in a `3.0 (quilt)' package the delta from the
72 previous upload is recorded in a new patch constructed by dpkg-source.
73 .SH READ-ONLY DISTROS
74 Distros which do not maintain a set of dgit history git repositories
75 can still be used in a read-only mode with dgit.  Currently Ubuntu
76 is configured this way.
77 .SH PACKAGE SOURCE FORMATS
78 If you are not the maintainer, you do not need to worry about the
79 source format of the package.  You can just make changes as you like
80 in git.  If the package is a `3.0 (quilt)' package, the patch stack
81 will usually not be represented in the git history.
82 .SH FORMAT 3.0 (QUILT)
83 For a format `3.0 (quilt)' source package, dgit may have to make a
84 commit on your current branch to contain metadata used by quilt and
85 dpkg-source.
86
87 This is because `3.0 (quilt)' source format represents the patch stack
88 as files in debian/patches/ actually inside the source tree.  This
89 means that, taking the whole tree (as seen by git or ls) (i)
90 dpkg-source cannot represent certain trees, and (ii) packing up a tree
91 in `3.0 (quilt)' and then unpacking it does not always yield the same
92 tree.
93
94 dgit will automatically work around this for you when building and
95 pushing.  The only thing you need to know is that dgit build, sbuild,
96 etc., may make new commits on your HEAD.  If you're not a quilt user
97 this commit won't contain any changes to files you care about.
98
99 You can explicitly request that dgit do just this fixup, by running
100 dgit quilt-fixup.
101
102 If you are a quilt user you need to know that dgit's git trees are
103 `patches applied packaging branches' and do not contain the .pc
104 directory (which is used by quilt to record which patches are
105 applied).  If you want to manipulate the patch stack you probably want
106 to be looking at tools like git-dpm.
107 .SH FILES IN THE SOURCE PACKAGE BUT NOT IN GIT - AUTOTOOLS ETC.
108 This section is mainly of interest to maintainers who want to use dgit
109 with their existing git history for the Debian package.
110
111 Some developers like to have an extra-clean git tree which lacks files
112 which are normally found in source tarballs and therefore in Debian
113 source packages.  For example, it is conventional to ship ./configure
114 in the source tarball, but some people prefer not to have it present
115 in the git view of their project.
116
117 dgit requires that the source package unpacks to exactly the same
118 files as are in the git commit on which dgit push operates.  So if you
119 just try to dgit push directly from one of these extra-clean git
120 branches, it will fail.
121
122 As the maintainer you therefore have the following options:
123 .TP
124 \(bu
125 Persuade upstream that the source code in their git history and the
126 source they ship as tarballs should be identical.  Of course simply
127 removing the files from the tarball may make the tarball hard for
128 people to use.
129 .IP
130 One answer is to commit the (maybe autogenerated)
131 files, perhaps with some simple automation to deal with conflicts and
132 spurious changes.  This has the advantage that someone who clones
133 the git repository finds the program just as easy to build as someone
134 who uses the tarball.
135 .TP
136 \(bu
137 Have separate git branches which do contain the extra files, and after
138 regenerating the extra files (whenever you would have to anyway),
139 commit the result onto those branches.
140 .TP
141 \(bu
142 Provide source packages which lack the files you don't want
143 in git, and arrange for your package build to create them as needed.
144 This may mean not using upstream source tarballs and makes the Debian
145 source package less useful for people without Debian build
146 infrastructure.
147 .LP
148 Of course it may also be that the differences are due to build system
149 bugs, which cause unintended files to end up in the source package.
150 dgit will notice this and complain.  You may have to fix these bugs
151 before you can unify your existing git history with dgit's.
152 .LP
153 .SH FILES IN THE SOURCE PACKAGE BUT NOT IN GIT - DOCS, BINARIES ETC.
154 Some upstream tarballs contain build artifacts which upstream expects
155 some users not to want to rebuild (or indeed to find hard to rebuild),
156 but which in Debian we always rebuild.
157 .LP
158 Examples sometimes include crossbuild firmware binaries and
159 documentation.
160 To avoid problems when building updated source
161 packages
162 (in particular, to avoid trying to represent as changes in
163 the source package uninteresting or perhaps unrepresentable changes
164 to such files)
165 many maintainers arrange for the package clean target
166 to delete these files.
167 .LP
168 dpkg-source does not
169 (with any of the commonly used source formats)
170 represent deletion of files (outside debian/) present in upstream.
171 Thus deleting such files in a dpkg-source working tree does not
172 actually result in them being deleted from the source package.
173 Thus
174 deleting the files in rules clean sweeps this problem under the rug.
175 .LP
176 However, git does always properly record file deletion.
177 Since dgit's
178 principle is that the dgit git tree is the same of dpkg-source -x,
179 that means that a dgit-compatible git tree always contains these
180 files.
181 .LP
182 For the non-maintainer,
183 this can be observed in the following suboptimal occurrences:
184 .TP
185 \(bu
186 The package clean target often deletes these files, making the git
187 tree dirty trying to build the source package, etc.
188 This can be fixed
189 by using
190 .BR "dgit -wg" " aka " "--clean=git" ,
191 so that the package clean target is never run.
192 .TP
193 \(bu
194 The package build modifies these files, so that builds make the git
195 tree dirty.
196 This can be worked around by using `git reset --hard'
197 after each build
198 (or at least before each commit or push).
199 .LP
200 From the maintainer's point of view,
201 the main consequence is that to make a dgit-compatible git branch
202 it is necessary to commit these files to git.
203 The maintainer has a few additional options for mitigation:
204 for example,
205 it may be possible for the rules file to arrange to do the
206 build in a temporary area, which avoids updating the troublesome
207 files;
208 they can then be left in the git tree without seeing trouble.
209 .SH PROBLEMS WITH PACKAGE CLEAN TARGETS ETC.
210 A related problem is other unexpected behaviour by a package's
211 .B clean
212 target.
213 If a package's rules
214 modify files which are distributed in the package,
215 or simply forget to remove certain files,
216 dgit will complain that the tree is dirty.
217 .LP
218 Again, the solution is to use
219 .BR "dgit -wg" " aka " "--clean=git" ,
220 which instructs dgit to use git clean instead of the package's
221 build target,
222 along with perhaps
223 .B git reset --hard
224 before each build.
225 .LP
226 This is 100% reliable, but has the downside
227 that if you forget to git add or to commit, and then use
228 .BR "dgit -wg" " or " "git reset --hard" ,
229 your changes may be lost.
230 .SH SEE ALSO
231 \fBdgit\fP(1).