Making packages for Debian derivatives (like Ubuntu) isn’t really hard. It just required some dedication to learn how the packaging system work. Yet, most users don’t know how to make packages for their distribution. In this series, I will try to give a brief introduction packaging.
First, I would like to tell you that, if you never compiled a program before, this short guide will be useless for you. Therefore, I assume that you know and that you did compile a program before. Also, I will use the term “package” to refer to the compiled program package ready to installed on Debian or its derivatives. And, I will use the term “program” to refer to the software, like “GNU Emacs”.
A package consists of two things: the source code of a program and a
debian/ directory which contains information how to build the
program. There is different methods to specify the packaging
information. The most common one, and the one I will discuss here, is
using a tool called
debhelper. This tool makes the packaging process
easier by abstracting the common packaging tasks into little scripts,
run at the build time. The typical directory structure of a package
looks like this:
gnu-hello/ debian/ changelog compat control copyright postinst prerm rules doc/ man/ src/ AUTHORS ChangeLog configure COPYING INSTALL README
Obviously, this example is simplified, but you get the idea. That are the interesting things for a packager. By the way, GNU Hello a good example of package to study. You get it with:
$ apt-get source hello-debhelper
Here, a quick description of the files in the
changelog: The history of the package’s changes.
compat: A file that contains the debhelper version that is used.
control: The description of the package and the list of dependencies.
copyright: A copy of the licence the program uses.
postinst: A post-installation script used to setup things after the package has been unpacked.
prerm: Another script that is run before the removal of the package. It usually used to undo the things
rules: The instructions how to build the package. This is simply a Makefile.
In more complicated programs, there is usually other files. However, I won’t talk about them in this introduction. Anyway, I am out of time. In the second part of this series, I will explain the tools used to build packages.