Home Page

Tips page

University Page

Programming

Debian & Linux

Some works

About me

Del.icio.us Bookmarks

BOINC Combined Statistics

Site Statistics

Contact me sending an e-mail (antispam defense activated)

debian

hacker emblem

blogger

GeoURL

View Sandro Tosi's profile on LinkedIn

This is my Google PageRank

Some Debian Packaging Tips

Some Debian Packaging Tips

 Sandro Tosi, 01 August 2006


It's been about 6/8 months since my first attempt of packaging a tool for Debian, and during this time I've collected some tips that could be useful to share.

1. First phases of packaging a new tool

There are mainly two categories of packages: brand new (ie, you're packaging an application that new for Debian) or upgrades (ie, you're upgrading an appplication already in Debian).

The second category could be the easier one, since someone else has already done all the configuration for the packaging, but the first category is the one where you can learn more about creation and maintenance of a Debian package. Note, don't give up! It might seem too difficult, but if I was able to forge a package, everybody can! :)

Ok, so you'd like to package something for Debian; so, first you have to choose what to package: you could have found a tool no already package, and so start from that one (this is a good choise, since usually you will use that software, so you can notice bugs and corrections needed to increase usability of that program) or, if you have still nothing to package, you can go to a webpage where Debian users request a tool to be packaged.

Before start with the real activity of packaging, you'll have to install some support tools, useful during packaging; I suggest the following packages: ***** debhelper? debian-policy? maint-guide? debuild? lintian? linda? svn-buildpackage? pbuilder? cvs-buildpackage?

2. Initial steps of packaging

Following you can find a list of steps you'll have to follow in order to setup a nice Debian package starting from an upstream tarball (let's suppose the tool you're going to package is called foobar and the version is 1.4:

  1. download the tarball from upstream author (ok, that's obvious...), let's say foobar-1.4.tar.bz2;
  2. extract it into a directory called <name>-<version>: for our example the directory will be called foobar-1.4;
  3. cd into that dir, and type dh_make -f ../foobar-1.4.tar.bz2 (supposing that foobar-1.4.tar.bz2 is in .., if not change it); this command creates debian/ dir containing templates for the file you'll need to complete;
  4. now go into debian/ directory and start modifing the files in there (or removing if you don't need some of them); to do that, follow New Maintainers' Guide and Debian Policy, which you should read, read again, understand, read another time, apply :) . Sometimes, you are requested to modify the upstream source code, to respect the policy.
  5. when you think the package is ready to be build, from the dir foobar-1.4 exec debuild -us -uc; you can call directly dpkg-buildpackage, but I suggest to use debuild.
  6. check the generated package (usually stored in ..) with lintian and linda; in case of warnings/errors, correct them and re-iter points 4-5-6.

3. Handle packages with source code management systems

For the first times, the previous sequence could be good, but if you go further, you'll need some different package source management. As you may already heard, there are some source code versioning tools, to handle code, the most famous are CVS and Subversion (SVN). Some Debian Developers (you may find them called simply DD) have written tools to use both SVN and CVS to manage the package creation, keeping track of the modifications, and easy the package creation and upgrade to a new upstream version. I suggest to use SVN, since is the de-facto standard.

In order to take advance from SVN, you have to follow a different path from the previous one; the first three steps as valid even here, then the difference (I suppose you have already a SVN repository where to store package code, if not, create one; I suppose you have it in /SNV/ directory):

  1. exec debuild -S -us -uc to generate an unsigned (-us -uc options) source (-S option) package; this generates the source package in the upper directory, made by some files, foobar_1.4-1*;
  2. now, move to the directory where you wish to create packages, for example I use ~/deb/ ; in that dir, svn-<tools> will create a working copy of package, called the name of the package (in this case foobar), than the dir build-area, used to build a package, and the dir tarballs, where upstream tarballs are store;
  3. in that dir, exec svn-inject /path/to/foobar_1.4-1.dsc file:///SVN/ ; this command inject the source package in the SVN repository and checkout a working copy in the current directory.

and now you can continue with the previous 4-5-6 steps.

Injecting the source package in its first phase of creation, allow to store the whole history of creation. Someone may argue that's not needed to inject a rough package (with all dh_make templates in debian/) but I'd rather this way: you are free to choose when to inport you package into the repository, at the beginning, or at the end of package setup.

Now, when you need to create a package, you have to commit the changes done in the working copy to the repository and exec svn-buildpackage (take a look at its manpage for some explaination).