Using svn-buildpackage with native packages

A native package is designed to work with Debian rather than general GNU/Linux distributions, many depend directly on specific Debian behaviour or other Debian native tools. svn-buildpackage is one such native package.

With a native package, the contents of the debian/ directory are included in the source tarball (which uses a plain .tar.gz suffix not the .orig.tar.gz suffix) and no .diff.gz is generated.

The principal marker for a native package is the Debian version string. An upstream package uses:

 foo (0.1.2-3)

A native package uses:

 foo (0.1.2)

Compiled native packages

Some native packages are compiled from source code and a lot of these packages use autotools like ./configure, autoreconf and make dist. Such packages can use autotools support to generate a typical GNU or autotools style tarball with support for EXTRA_DIST and similar rules in Makefile.am. This allows the maintainers to not need to keep generated files (configure, aclocal.m4, ltmain.sh and libtool) in the subversion repository. With this support, the package can directly control which files are included into the source for the native package.

To build such packages with svn-buildpackage, mergeWithUpstream can be used even if the Debian version string indicates a native package. The upstream tarball is the one created by the make dist target and the maintainer can choose how to make that tarball available to svn-buildpackage:

Example 3.3. Using a native tarball and mergeWithUpstream

Makefile.am

all-local: Makefile
	ln -sf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)_$(VERSION).orig.tar.gz

(Yes, this is an artefact of using mergeWithUpstream. The .orig.tar.gz is not actually used - the Debian version string overrides the merge property.)


SVN properties:

$ svn proplist ./debian/
Properties on 'debian':
  mergeWithUpstream

Example 3.4. Output of using mergeWithUpstream inside a native package

The tarball generated by make dist is located using the origDir property, in this example, set to the top level package directory where make dist would normally create it and where the symlink is also created, as above.

svn-buildpackage output:

(using langupdate as the example package)

$ svn-buildpackage -us -uc
	origDir: ./
Complete layout information:
	buildArea=/opt/working/emdebian/host/trunk/langupdate/build-area
	origDir=./
	tagsDir=/opt/working/emdebian/host/trunk/langupdate/tags
	tagsUrl=svn+ssh://codehelp@buildd.emdebian.org/var/emdebian/svn/current/host/trunk/langupdate/tags
	trunkDir=/opt/working/emdebian/host/trunk/langupdate/trunk
	trunkUrl=svn+ssh://codehelp@buildd.emdebian.org/var/emdebian/svn/current/host/trunk/langupdate/trunk
mergeWithUpstream mode detected, looking for .//langupdate_0.1.1.orig.tar.gz
I: mergeWithUpstream property set, looking for upstream source tarball...
 tar --no-same-owner --no-same-permissions --extract --gzip --file /opt/working/emdebian/host/trunk/langupdate/trunk/langupdate-0.1.1.tar.gz --directory <1 more argument>
 mv /opt/working/emdebian/host/trunk/langupdate/build-area/tmp-0.15173904069616/langupdate-0.1.1 /opt/working/emdebian/host/trunk/langupdate/build-area/langupdate-0.1.1
svn --force export /opt/working/emdebian/host/trunk/langupdate/trunk /opt/working/emdebian/host/trunk/langupdate/build-area/langupdate-0.1.1
Export complete.

Note how the tarball (created by make dist and located by mergeWithUpstream due to the symlink) is unpacked and then the exported SVN is applied on top. This allows maintainers to test local changes using --svn-ignore.


Native packages not using autotools

The useNativeDist property.

When make dist is not available, there are still situations where generated files may need to be included into the source tarball of the native package. svn-buildpackage supports the useNativeDist SVN property (applied to the ./debian/ directory) which allows for customised make native-dist target to be run immediately after the svn export.

Example 3.5. The useNativeDist property.

svn-buildpackage uses this feature to include the POT file to aid translators. The custom make rule needs to be defined in the top level Makefile:

# adds the POT file to the source tarball
native-dist: Makefile
	po4a-build --pot-only

The native-dist target needs to be idempotent and able to run straight from the SVN export. Any changes made by running the target will be directly reflected in the source tarball. Ensure that no files are removed that would prevent the package being built as a normal Debian package, using only the resulting source package. (e.g. cd into the build-area, unpacking the .dsc with dpkg-source -x and rebuild the package, then remove the test directory.)

The net result is that the resulting source tarball includes the po/svn-buildpackage.pot generated by the make native-dist target without needing to add the generated POT file to SVN (and requiring repeated commits each time the POT file is timestamped).