On-Build-Time merging

A special feature of svn-buildpackage is so called mergeWithUpstream mode. Many projects do not want to keep the whole upstream source under revision control, eg. because of the large amount of required disc space and process time. Sometimes it makes sense to keep only the debian/ directory any maybe few other files under revision control.

The task of exporting the source from repository and adding it to the upstream source before building becomes annoying after a little time. But the svn-buildpackage tools automate most of this work for you by switching to mergeWithUpstream mode if a special flag has been detected: the mergeWithUpstream (Subversion) property of the debian directory. svn-buildpackage will merge the trunk with upstream source on build time and svn-upgrade will only update the changed files in this case.

To enable this feature during the inital import of the source package, simply add the -o switch to the svn-inject call and it will prepare the source for with mergeWithUpstream mode. This reduces the set of files to those modified for Debian and set the mergeWithUpstream property.

But what, if you decide to switch to mergeWithUpstream-mode after the package has been injected? To do this, checkout the whole repository, remove the files not changed in the Debian package from both upstream source and Debian branch (svn rm) and set the mergeWithUpstream property on debian in the trunk directory with:

svn propset mergeWithUpstream 1 debian

If you actually decide to stop using the mergeWithUpstream mode, unset the mergeWithUpstream property as follows:

svn propdel mergeWithUpstream debian/

If you don't want to store the upstream sources of all your packages in the repository, you can pass the --no-branches switch to svn-inject, which will prevent svn-inject from creating a branches subdirectory.

dpkg-source format 3.0 support

svn-buildpackage can build packages using source format 3.0, including using ../tarballs/foo_1.2.3-1.orig.tar.bz2 in mergeWithUpstream mode. Ensure that debian/source/format exists and has been added to the local subversion working copy.

If debian/source/format exists and contains 3.0 *, svn-buildpackage checks for a .orig.tar.bz2 in the tarballs directory and uses that for the subsequent build.

Example 3.2. checking source formats with dpkg-source

dpkg-source --print-format needs a little help to understand common layouts used with subversion. The command needs two directories - the current working directory is used to find the original tarball and the specified directory is used to locate ./debian/changelog. Change to the directory containing the tarball before running dpkg-source --print-format:

$ svn mkdir debian/source
$ echo "3.0 (quilt)" > debian/source/format
$ svn add debian/source/format
$ pushd ../tarballs/
$ dpkg-source --print-format ../trunk/
3.0 (quilt)
$ popd