Warning:This article is out of date and should not be used for creating new packages. Please refer to the Debian New Maintainers Guide instead.

Making a Debian Package

Now you've installed the right packages and read the documentation, you are ready to begin. As an example we will make a Debian package for empire. This is a strategy game where you build an empire.

So the first thing to do is to find and download the original package. Sunsite is the biggest Linux mirror so I looked for it at my local sunsite mirror and found it here

There are two types of packages you can make, source and binary. A source package contains code which you can compile into a program. A binary package contains just the finished program. If you wish to contribute a package to the official Debian distribution it has to come with freely usable source. See the Debian Free Software Guidelines for exact details. Empire comes with source so we will make both a source and a binary package.

Debmake wants source to be in a directory called <packagename>-<version number> so lets create a directory called empire-1.1 and uncompress the .tgz file into it. (I got the version number from the lsm file that acompanies every program uploaded to sunsite.)

$ mkdir empire-1.1
$ mv empire.tar.gz empire-1.1
$ cd empire-1.1
$ tar -xvzf empire.tar.gz

And then if all goes well

$ rm empire.tar.gz

When you run deb-make some information will come up. The most important of these is your email address which will included in the package so people can contact you if they have problems. If you want a different address than your current one to be put in there set the EMAIL environment variable to the address you want before running deb-make like this.

$ export EMAIL=jaldhar@debian.org

You will be asked you what kind of package you want to generate.

Now lets run deb-make. Pick single for this package.

$ deb-make

When deb-make is finished. if you cd .. you'll see a new directory has been created called empire-1.1.orig which contains the original source code which will hereafter remain untouched. The empire-1.1 directory still exists. This is where you will make changes. There is a new subdirectory here called debian. Take a look at it.

$ cd empire-1.1/debian

There are a number of files in this directory. We will be editing these in order to customize the behavior of the package.

This file contains various values which dpkg and dselect will use to manage the package. Here is the control file deb-make creates for us.

1  Source: empire
2  Section: unknown
3  Priority: extra
4  Maintainer: Jaldhar H. Vyas <jaldhar@debian.org>
5  Standards-Version:
7  Package: empire
8  Architecture: any
9  Depends: ${shlibs:Depends}
10 Description: Missing
11  Missing

(I've added the line numbers.)

Lines 1-5 are the control information for the source package. Line 1 is the name of the source package.

Line 2 is the section of the distribution this package goes into. Lets change it to games.

Line 3 describes how important it is that the user install this package. As, alas, our game is completely unimportant we'll leave it as extra. Section and priority are actually only used by dselect when it sorts packages and selects defaults. See the policy manual for guidance on what to set these fields to.

Line 4 is the name and email address of the maintainer.

Line 5 is the version of the Debian policy standards this package follows.

Lines 7-11 are the control information for the binary package.

Line 7 is the name of the binary package.

Line 8 describes the CPU architecture the binary package was compiled for. We can leave this as any as dpkg-gencontrol(1) will fill in the appropriate value.

Line 9 shows one of the most powerful features of the Debian packaging system. Packages can relate to each other in various ways. Apart from depends other relationship fields are Recommends:, Suggests:, Pre-depends: Conflicts:, Provides:, and Replaces: . This is what they mean:

Depends dpkg and dselect will not install your program unless the packages it depends on are installed. Use this if your program absolutely will not run unless a particular package is present.
Recommends dselect will not install your package unless the packages it recommends are installed. dpkg will let you do it though. Use this for packages that are not strictly neccessary but are typically used with your program.
Suggests When a user installs your program dselect will prompt them to install any package it suggests. dpkg doesn't care. Use this for packages which will work nicely with your program but are not neccessary.
Pre-depends This is stronger than depends. dpkg and dselect will not install your program unless the packages it Pre-depends on are installed and correctly configured. Use this vry sparingly and only after discussing it on the debian-devel mailing list.
Conflicts dpkg and dselect will not install your program until all the packages it conflicts with have been removed.
Provides For some types of packages where there are multiple alternatives virtual names have been defined. You can get the full list in /usr/doc/debian-policy/virtual-package-names-list.text.gz. Use this if your program provides a virtual package.
Replaces Use this when your program replaces another package. dpkg and dselect will remove replaced packages before installing yours.

These fields all have a uniform syntax. They are a list of package names separated by commas. These package names may also be lists of alternative package names, separated by vertical bar symbols | (pipe symbols). The fields may restrict their applicability to particular versions of each named package. This is done in parentheses after each individual package name; the parentheses should contain a relation from the list below followed by a version number. The relations allowed are <<, <=, =, >= and >> for strictly earlier, earlier or equal, exactly equal, later or equal and strictly later, respectively. The last feature I want to show you is $(shlibs:Depends) This will be automatically filled in by debmake with the names of any shared libraries (DLLs) such as libc6 this program uses so you don't have to specify them yourself. Having said all that, we can leave line 9 exactly as it is as Empire won't depend on any other package.

Line 10 is the short description. Most peoples screens are 80 columns wide so this shouldn't be longer that about 50 characters. Lets change it to "an empire-building strategy game"

Line 11 is where the long description goes. This should be a paragraph which gives more detail about the package. Column 1 of each line should be empty. There should be no blank lines. Put a . in column 2 to simulate this.

Here is the updated control file:

1   Source: empire
2   Section: games
3   Priority: extra
4   Maintainer: Jaldhar H. Vyas <jaldhar@debian.org>
5   Standards-Version:
7   Package: empire
8   Architecture: any
9   Depends: ${shlibs:Depends}
10  Description: an empire-building strategy game
11   A solitaire empire game (sometimes called 'VMS Empire'), colorized and
11a  speed tuned and with a save-interval option.
11b  .
11c  In this game a player has to try to build and defend an empire.

Previous page
Next Page

By Jaldhar Vyas
November 11, 1997