This post is for all people that need debian packages for their software but are far too lazy to really learn all this packaging from the beginning. But be aware that it is really easy to build broken packages. I will not explain how to build packages for simple applications since this is explained quite good in the Debian packaging guide. Anyway, it does not explain library-packaging at all.

Packaging a library is not really difficult most of the time. Given that most GNOME libraries share a very common build system layout it would be a waste of time to start from scratch. So we search for a library the seems to be a good starting point for our own package. In my case, packaging libnotifymm, this was obviously glibmm. So first step, get the sources of that package:

apt-get source libglibmm-2.4-dev

Next step, copy the debian directory over to your project, not very tricky either, and delete the useless changelog:

cp -r glibmm-2.4-2.13.3/debian libnotifymm
cd libnotifymm/debian
rm changelog

Now, you end up with some files in the debian directory:

  • copyright: Check the license, put your name in, etc
  • control: The most important file. Replace the name of the library you took as sample with the name of your actual library, take care of the versions and update the dependencies. With an appropriate sample file the format is quite obvious.
  • *.dirs, *.install: These file show where the library gets installed on the system. Normally you should not have to change much here apart from renaming the files from oldlib.dirs to newlib.dirs. But always take a look a the files as there is probably mentioning the old package somewhere and you want to change that.
  • rules: Do not touch for now. Hopefully it will just work, otherwise you will notice that later

In the end, create a changelog using this command which will ensure you have the correct format:

dch --create

Now, let’s give it a go:

dpkg-buildpackage -rfakeroot

If you are (too) lucky, you will have fresh debian packages now. If not, it’s time to check the rules file for stupid shell scripting. The error messages normally give you some indication what could have been wrong. You may need some tries before everything works smoothly.

When you have finished, check if the packages install cleanly on your system and explore them with file-roller to see if they really install all the files needed.

As said before, this is really not the greatest way to create packages and you will do better if you read all the documentation about building packages. But often you get the idea from looking at other packages.

4 Responses to “Building .debs the quick’n’dirty way”

  1. John Says:

    Just use dh_make instead of copying the debian\* files from another package that could be completely incompatible.

  2. Ross Says:

    .dirs files are obsolete, you can delete any you come across.

  3. Chipzz Says:

    changelogs are NOT unnecessary, they’re needed for some debhelper commands (dh_*)

  4. Jon Says:

    @chipzz: yes, he creates a changelog using dch –create, but there’s nothing in other package’s changelog which is of relevance to this one.

Comments are closed.