Most Debian packages are managed with a version control system (VCS) like git, subversion, bazaar or mercurial. The particularities of the 3.0 (quilt) source format are not without consequences in terms of integration with the VCS. I’ll give you some tips to have a smoother experience.
All the samples given in the article assume that you use git as version control system.
1. Add .pc to the VCS ignore list
.pc is the directory used by quilt to store its internal data (list of applied patches, backup of modified files). It’s also created by dpkg-source so that quilt knows that the patches are in
debian/patches (and not in
patches which is the default directory used by quilt). For that reason, the directory is kept even if you unapply all the patches.
However you don’t want to store this directory in your repository, so it’s best to put it in the VCS ignore list. With git you simply do:
$ echo ".pc" >>.gitignore $ git add .gitignore $ git commit -m "Ignore quilt dir"
.gitignore file is ignored by dpkg-source, so you’re not adding any noise to the generated source package.
2. Unapply patches after the build
If you store upstream sources with non-applied patches (most people do), and if you don’t build packages in a temporary build directory, then you probably want to unapply the patches after the build so that your repository is again in a clean status.
This is now the default since dpkg-source will unapply any patch that it had to apply by itself. Thus if you start the build with a clean tree, you’ll end up with a clean tree.
But you can still force dpkg-source to unapply patches by adding “unapply-patches” to
$ echo "unapply-patches" >>debian/source/local-options $ git add debian/source/local-options $ git commit -m "Unapply patches after build"
svn-buildpackage always builds in a temporary directory so the repository is left exactly like it was before the build, this option is thus useless. git-buildpackage can also be told to build in a temporary directory with
--git-export-dir=../build-area/ (the directory
../build-area/ is the one used by svn-buildpackage, so this option makes git-buildpackage behave like svn-buildpackage in that respect).
3. Manage your quilt patches as a git branch
Instead of using quilt to manage the Debian-specific patches, it’s possible to use git itself. git-buildpackage comes with gbp-pq (“Git-BuildPackage Patch Queue”): it can export the quilt serie in a git branch that you can manipulate like you want. Each commit represents a patch, so you want to rebase that branch to edit intermediary commits. Check out the upstream documentation of this tool to learn how to work with it.
There’s an alternative tool as well: git-dpm. Its website explains the principle very well. It’s a more complicated than gbp-pq but it has the advantage of keeping the history of all branches used to generate the quilt series of all Debian releases. You might want to read a review made by Sam Hartman, it explains the limits of this tool.
4. Document how to review the changes
One of the main benefit of this new source format is that it’s easy to review changes because upstream changes are kept as separate patches properly documented (ideally using the DEP-3 format). With the tools above, the commit message becomes the patch header. Thus it’s important to write meaningful commit messages.
This works well as long as your workflow considers the Debian patches as a branch that you rebase on top of the upstream sources at each release. Some maintainers don’t like this workflow and prefer to have the Debian changes applied directly in the packaging branch. They switch to a new upstream version by merging it in their packaging branch. In that case, it’s difficult to generate a quilt serie out of the VCS. Instead, you should instruct dpkg-source to store all the changes in a single patch (which is then similar to the good old
.diff.gz) and document in the header of that patch how the changes can be better reviewed, for example in the VCS web interface. You do the former with the
--single-debian-patch option and the latter by writing the header in
$ echo "single-debian-patch" >> debian/source/local-options $ cat >debian/source/patch-header <<END This patch contains all the Debian-specific changes mixed together. To review them separately, please inspect the VCS history at http://git.debian.org/?=collab-maint/foo.git