Debian – Best practices for packaging self created software for Debian

debianmercurialpackaging

I've got Debian packaging for a piece of software I've written. This software probably is too specialized to be part of Debian. In any case, for now I have no plans to try to include it in Debian. However, I'd like to follow best practices to the extent possible.

Currently the Debian packaging is part of the same Mercurial repository as the software, in the subdirectory debian/. I'm wondering if I should put it in a separate repository. Also, currently the package is being built as a Debian native package, which isn't really appropriate. I guess I could add a get-orig-source target for building the orig tarball to rules, but is it Ok to build a orig.tar.gz file from a local repository, or is it necessary to get it from remote? If the former, are there any recommended approaches for, for example, passing the location of the repository to the get-orig-source target?

It was suggested to me that perhaps I could put the debian directory in a separate (presumably named) branch from the actual software, and merge them together when building. That still leaves the question of how to get the orig.tar.gz with get-orig-source.

Best Answer

As you mentioned, it is good practice to have debian/ in a separate branch (not necessarily repository). If other people want to package your software for another distribution or in another way as you do, it is annoying for them if they get your debian/ folder by default.

In general, get-orig-source is recommended, if there are no upstream tarballs available or if you need to modify them for any reason (copyright, unused files etc.). So if you publish tarballs for your software, you do not need get-orig-source.

As there is no general solution for the get-orig-source target, I recommend you to have a look at existing solutions (e.g. on github).

Often they use something like hg archive -X ".hg* ../packagename_$VERSION.orig.tar.gz to build the tarball and dpkg-parsechangelog to extract the current upstream version from debian/changelog.


For packaging, I recommend you mercurial-buildpackage. Its tools allow to maintain orig-tarballs in a separate branch for example.

Related Question