Wednesday, April 29, 2009

How to build and test packages for GetDeb

This article is addressed to those planning to build packages for GetDeb or which just want to understand how we do it.
Building a package may require a lot of development libraries which are not needed for your regular desktop use - and you also probably don't want to overwrite current working applications with testing packages. For this reason, the recommended procedure is to use an isolated minimal system install that you can use for both building and testing.

This can be achieved by using a virtualization application, however we will be presenting a much simpler and lighter approach using schroot and sbuild.

Getdeb's debfactory is a set of tools designed to assist in package building for developers. The first thing you will need is to get the latest version of the debfactory tools, you can retrieve them with:
bzr co lp:debfactory

Now we need to create the schroot images that will contain the minimal packages for the releases we plan to build for.
To create the schroot images execute:
sudo debfactory/bin/schroot_build.py -b
The -b indicates we will be using the schroots not only for testing but also for building, sbuild will be installed.

You will need to add yourself to the sbuild group with:
sudo usermod -a -G sbuild $USER
Re-login for the change to take effect, you can see the groups your user belongs to with the "id" command.

Now let's manually build a package for isomaster
# Get the isomaster source and debian building rules from getdeb with:
dget -ux http://archive.getdeb.net/getdeb/ubuntu/jaunty/is/isomaster_1.3.5-1~getdeb1.dsc
# Switch to the schroot for the building with:
schroot -c jaunty.i386 -p

# Let's go into the source directory and install the build dependencies defined for the package
cd isomaster-1.3.5
sudo ~/debfactory/bin/satisfydepends

# Now let's build it
debuild -us -uc
# You should now have the file ../isomaster_1.3.5-1~getdeb1_i386.deb that you can install, but first let's exit the schroot with the exit command. All the changes done on the schroot except for /home will be lost, we want to enter the schroot again in it's initial state so that we can check if the package will install and run without problems on a minimal system.
schroot -c jaunty.i386 -p
# Now let's try to install the package
sudo dpkg -i isomaster_1.3.5-1~getdeb1_i386.deb
# Install missing dependencies
sudo apt-get install -f
# Run the application for testing
isomaster
# It's is everything ok ? so just exit

# What if you wanted an automated build after the dget ? just use sbuild:
sbuild -c jaunty.i386 isomaster_1.3.5-1~getdeb1.dsc

That's all for this article - I will present some other getdeb tools and processes in the future.

No comments: