Michael Hasselmann

What to do if you do not understand Debian Packaging

Up until now I had only been a consumer of debian packages and had a mostly pleasant experience. Dependancy resolving works and apt-get & friends are reasonable efficient. If everything fails there is always apt-get source. So it was about time to get on the other side of the fence! However, simply searching for HowTos was already irritating enough =) Not that you wouldn't find any documentation, quite the opposite! You find way too many, many of them describing different ways of How To Do It Right TM.

The easy way perhaps is to just start with an already debianized project and perform an update of the sources. That got me to my first debian package quickly (copy this debian folder here, dch -i into a quick "edit-the-changelog" session, debuild the new packages, DONE!) but I didn't understand much at all . Then I thought I'd learn more by debianizing some toy code of mine. Since I was already using autotools it should have been straight forward - get everything created by a "make install" into a binary, or so. Well, I only got the executable included in the end =) The mysteries of the dh_* universe.

Then Daniel pointed me to the Common Debian Build System. It required even more reading (I managed to pick the director's cut, instead of the plot summary) but at least this beast called debian/rules was tame-able now!

CDBS is a true winner in debian maintainer land I guess. Though one detail kept me occupied, and that was how the call to "dh_install -p" didn't extract the appropiate files from my debian/tmp install folder for a multi-binary debianization. It wasn't a case of missing .install files, or misused globbing. CDBS simply doesn't pass the correct --sourcedir path to dh_install! If you don't know the conventions used by dh_* tools then you would hardly guess you have to use the DEB_DH_INSTALL_SOURCEDIR variable in your debian/rules file. But the truly great thing about CDBS is that you can lookup how it invokes dh_install (it's only Makefile magic, after all): fgrep -ri -- '--sourcedir' /usr/share/cdbs/1/rules/, and you'll soon figure it out.

Oh something that I personally found quite clever was the debian/rules shebang: "#!/usr/bin/make -f". I have called Makefiles from other Makefiles in the past but this solution takes the cake, unless of course you think "include /some/other/Makefile" doesn't look nice.

Other useful commands:

Comments

Michael Banck commented on May 29, 2009 at 12:36 p.m.

If you just now look at Debian packaging, maybe debhelper 7 is better suited than CDBS. CDBS has its followers, but there is also a big crowd who don't like it due to its "black box" nature (people disregard the Makefiles in /usr/share/cdbs as unreadable).

debhelper 7 is about as easy to use in debian/rules, but might get the full community mindshare and corner cases might be easier. Of course, if you have trouble, you will have to look at its perl code.

See http://kitenet.net/~joey/blog/entry/c... and http://kitenet.net/~joey/blog/entry/d... they are a bit convoluted, but in the general case, the design looks simple yet flexible.

Disclaimer: I have not yet used it on my own packages.

Michael Hasselmann commented on May 29, 2009 at 3:27 p.m.

Thanks for the links! Well, it certainly tackles the same problem - I'll have to give it a try. Interesting how perl code is preferred over Makefiles though =)

Michael Hasselmann commented on June 3, 2009 at 5:59 p.m.

More documentation links for CDBS
This is long, too [1]. But it has nice pictures to explain the build process [2] and the makefile dependencies [3].

[1] http://build-common.alioth.debian.org...
[2] http://build-common.alioth.debian.org...
[3] http://build-common.alioth.debian.org...

Post a Comment

This site's webmaster failed misserably in upgrading the underlaying web framework.
The comment system is entirely broken right now. Sorry!