Sunday, February 15, 2009

Creating custom deb packages is a pain



As a long time Gentoo user and maintainer I sometimes find myself crying at the time it takes to get a package compiled. Especially if you're updating or installing something that is needed super pronto. Now this is nothing unique to Gentoo, it's a problem for any source-based distro. However, today I got reminded (again) why a source-based solution gives users and developers superior control.

Have you ever tried crating an i686 package for a Debain based system? If not then let me spare you the agony and tell you to not waste your time. Now this is not a shortcoming in the package creating system, which by the way is a nightmare of configuration files and scripts, but rather a deficiency in the package distribution and management system that doesn't allow i686 pages to be installed. Yes, that right, you can run a i686 host and you can compile and run i686 applications, but you can't install them. Well, not at least pure i686 packages. This is being discussed now so hopefully things will improve.

If by any chance you would like to try this is what I did:

First make sure the necessary build tools are available by installing these packages:


apt-get install build-essential pbuilder debhelper dh-make


Then follow the packaging guide and make sure that you at least have your control, copyright and rules files in order. This horribly styled page breaks it down pretty well.

Add these lines to the top of the rules file to override the default compiler and compiler flags. Change according to your needs


CC = gcc
CFLAGS = -march=i686 -02 -pip


Also update the build make target in that file as well, so it looks something like this:


build-stamp: configure-stamp
...
$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)"


To force a special architecture build, in this case i686, use:


dpkg-buildpackage -ai686 -b -uc -rfakeroot


Remember, you probably won't be able to install the resulting .deb unless you tweak the Architecture tag in the control file.

Good luck!

Edit: The above should work to create i686 optimized i386 packages. If that makes any sense...

0 comments: