Manage your Debian packages with Subversion and pbuilder

If you are maintaining Debian packages then you probably know the problem that you have a number of upstream versions and revisions flying around your file system. There is a nifty way to handle different revisions through the SubVersion repository system: svn-buildpackage from Eduard Bloch. To make things truly perfect you can even use the pbuilder but then it becomes a mess of different man pages and command line options. I have gone through that so you won't have to. :)

Install the needed packages

apt-get install subversion
apt-get install svn-buildpackage
apt-get install pbuilder

Set up a Subversion repository

Make sure you have a SubVersion repository already created using

svnadmin create ...

Every package is supposed to have a repository of its own.

Import your package into the repository

Using the svn-inject command you will now need to import the package into the repository. First create a directory where you want the repository to be checked out (on your workstation) and run something like this:

svn-inject -c 2 /path/to/old/package/filepp_1.7.1-6.dsc http://my.reposito.ry/svn/filepp

You will probably now have a directory layout similar to this:

Directory

What's in there

tarballs

The *.orig.tar.gz archives (aka upstream tarballs) go here

filepp/trunk

Here is where you will start to build the package. It's the place that contains the debian/ directory.

filepp/branches/upstream

Contains the upstream releases

filepp/tags

Contains tags (copies) of your work for every upload (every time you use dch -i

Note: filepp is just the name of my example package. Yours will probably named differently.

Creating the pbuilder directory

pbuilder is a nice tool that uses debootstrap (another nice tool) to create a clean build environment in a chroot directory. It makes sure that your build dependencies are set correctly and builds your package on a virtual 'sid' without using whatever weird package versions you may use on your workstation.

Put these lines into your ~/.pbuilderrc

MIRRORSITE=http://www.artfiles.org/debian.org
AUTO_DEBSIGN=yes

Use any mirror you like. The default mirror is in Japan which may not be the best choice for you. See /etc/pbuilderrc for more options.

Make sure you can use sudo to gain root privileges for the pbuilder program. Put this line into your /etc/sudoers file:

frederic  ALL=(ALL) /usr/sbin/pbuilder

Assuming that your user name is frederic. :)

Then run...

sudo pbuilder create

Build the package

Change to the filepp/trunk directory and just work on the package like you always did. Once you are happy with your work and want to create binary packages run this command:

svn-buildpackage --svn-builder="pdebuild --buildresult `pwd`/../build-area --debsign-k frederic@debian.org"

You may as well leave out the --debsign-k option if you do not need/want to sign the package.

At the end of the build process you will automatically be shown lintian warnings/errors - if there are any.

If all goes well you will find your package in filepp/build-area. There is one quirk though. There is a superfluous file called something like filepp_1.7.1-7_source.changes. This file was created during the build process. It can confuse your dupload though. So make sure you just remove it before you upload the package. (The svn-buildpackage maintainer told me that it is generated by pbuilder.)

Tagging a revision

Once your package is uploaded you should create a tag from it. In Subversion speak this means creating a copy of your current trunk directory. This way you can always take a historic version in case you need it. Just run:

svn-buildpackage --svn-tag-only

Don't forget to commit the changes (svn ci). A new debian/changelog entry will be started automatically.

Updating to a new upstream version

Once your upstream developers comes up with a new *orig.tar.gz you need to update your package. This is done using the svn-upgrade command. Just give it the new tarball as a parameter and you are set:

svn-upgrade /tmp/filepp-2.0.tar.gz

See also

WorkaroundOrg: SvnBuildpackage (last edited 2006-10-22 09:50:11 by ChristophHaas)