Creating Debian Packages

From IHRIS Wiki
Revision as of 09:47, 8 October 2007 by MarkAHershberger (talk | contribs)

This document describes the decisions made in packaging and descrbes the steps taken.

For the purpose of this discussion, we'll consider the build directory to be at ~/build.

Bazaar

$ sudo aptitude install bzr

If you are creating a new project, then make a directory for the project and put it under version control. For example:

$ bzr init ihris-qualify-debian

Since you are probably dealing with code already under version control, you can just check it out. For example, to check out the my build scripts for the i2ce project from Launchpad:

$ bzr co lp:~hexmode/i2ce/debian-dev i2ce-debian
$ ls
i2ce-debian

bzr-builddeb

$ sudo aptitude install bzr-builddeb

The build scripts are kept separate repository and kept under version control. To enable this (and keep the number of revision control systems in use to a minimum), I use bzr-builddeb to build packages directly from the bzr repository.

This package generation tool can keep the debian directory under revision control. If you look at my debian repositories, you'll see that the repositories are the contents of the debian directory. During the build process, bzr-builddeb merges the directory with the pristine source tree and performs all build operations there.

bzr-builddeb uses several configuration files to control its operation. The only one we're concerned with here is the default.conf file under the .bzr-builddeb directory. This stores the defaults for this package. The contents of ~/build/i2ce-debian/.bzr-debbuild/default.conf:

[BUILDDEB]
merge = True
export-upstream = http://bazaar.launchpad.net/%7Eintrahealth%2Binformatics/i2ce/main/

The first line just confirms that this is a bzr-builddeb configuration package.

The second line (merge = True) tells bzr-builddeb to merge this directory (in this case, ~/build/i2ce-debian with the the upstream source.

The third line (export-upstream = …) gives the location of the original source in Bazaar to check out.

Running bzr builddeb from within the i2ce-debian directory will create a ~/build/build-area/i2ce-2.0 directory, check out the code from Launchpad, put the contents of the current directory in the debian subdirectory, and build the package. After the package is built, the ~/build/build-area/i2ce-2.0 directory will be removed.

dpatch

dpatch is a patch management system that I used to alter the pristine configuration files so that they would work in the Debian packages.

Patches are stored in the patches sub-directory and are applied in the order listed in the 00list file in that directory.

To apply all the patches, the command dpatch apply-all is executed. To remove all patches (i.e. in a “clean” operation), use the command dpatch deapply-all. To create a new patch, see “Creating dpatch scriptlets” in the dpatch man page.

dbconfig-common

dbconfig-common is used to set up the database structure for the i2ce. If there is any need to provide initial database data for other packages, this package should be used to handle the installation.

To setup a database, two things must be done. First, the database data must be provided. Second, the dbconfig-common post-installation hooks must be called.

The SQL data is provided during the package building process by putting an SQL file at /usr/share/dbconfig-common/data/package/install/mysql. PostgreSQL setup can be done in a similar way.

Important: Since dbconfig-common creates a database as well as a user for the application, do not perform these steps in your database setup.

In the post-installation script, a few environment variables are set to tell dbconfig-common where to place the templates it produces and then the dbconfig-common hooks are called. These hooks take care of collecting and assigning passords; creating the user and database for the application; and loading the data into the database.

Files in the Debian directory